User prompt
polis daha iyi oynasın
User prompt
Remove the gun tissue from the police's hand but still keep shooting
User prompt
When the character comes to a car, he controls the car and when he gets in the car, his speed increases.
User prompt
When the character hovers over a car, he becomes invisible and controls the car. When he gets into the car, his speed increases.
User prompt
move the health bar to the bottom left
User prompt
Add a health indicator as assets to the bottom right
User prompt
Move it a little further to the left and add the arrow keys as assets
User prompt
Make the arrow keys a little larger and move the keys to the bottom right
User prompt
Add touch-sensitive arrow keys to the game so we can move the player.
User prompt
Add a texture to the game at the bottom left, when you press that texture, the language selection screen will appear and there will be "English" and "Turkish" options. When you press the "Turkish" option, the game will be in "Turkish". When you press the "English" option, the game will be in "English" language.
User prompt
Translate the game's texts into "Turkish" language
User prompt
Enlarge the health text at the bottom right a bit
User prompt
Let there be a maximum of 7 men
User prompt
Add a text like this at the bottom: "Health: (health number)" instead of (health number), you write our health. The game starts with 900 and every time we buy a bullet, it decreases by 300.
User prompt
Cars, you shouldn't be born surrounded by cars
User prompt
Let the maximum number of houses be 10
User prompt
Have small random spaces between houses, but don't overdo it
User prompt
If you haven't added a health bar at the bottom right, add it now.
User prompt
Add a life bar at the bottom right, the game will start with 100 full, when you get 3 bullets, the life bar will run out and the game will end.
User prompt
add a health bar to the top right of the game
User prompt
People shouldn't move nonsense, just move left and right in order.
User prompt
Let only one police officer be born
User prompt
The cars should not move, they should stay where they are
User prompt
buildings should not be up or down
User prompt
Buildings should not be everywhere, only in rows on the edges
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Building class
var Building = Container.expand(function () {
var self = Container.call(this);
var bldg = self.attachAsset('building', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
// Car class
var Car = Container.expand(function () {
var self = Container.call(this);
var carSprite = self.attachAsset('car', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 18;
self.direction = 0; // in radians, 0 = right
self.driver = null; // Player or null
self.ai = false;
self.aiTarget = null;
self.update = function () {
// Store previous position for collision revert
var prevX = self.x;
var prevY = self.y;
// Cars do not move; skip player and AI movement logic
// Prevent passing through buildings
for (var i = 0; typeof buildings !== "undefined" && i < buildings.length; i++) {
if (self.intersects(buildings[i])) {
self.x = prevX;
self.y = prevY;
break;
}
}
// Clamp to city bounds
if (self.x < 90) self.x = 90;
if (self.x > 2048 - 90) self.x = 2048 - 90;
if (self.y < 100) self.y = 100;
if (self.y > 2732 - 90) self.y = 2732 - 90;
};
return self;
});
// Mission marker class
var MissionMarker = Container.expand(function () {
var self = Container.call(this);
var marker = self.attachAsset('mission', {
anchorX: 0.5,
anchorY: 0.5
});
self.active = true;
return self;
});
// Pedestrian class
var Pedestrian = Container.expand(function () {
var self = Container.call(this);
var pedSprite = self.attachAsset('pedestrian', {
anchorX: 0.5,
anchorY: 0.5
});
// Pedestrians only move left and right in order
self.speed = 4 + Math.random() * 4;
self.direction = Math.random() < 0.5 ? 0 : Math.PI; // 0 = right, PI = left
self.update = function () {
var prevX = self.x;
var prevY = self.y;
// Move only in X direction (left/right)
self.x += Math.cos(self.direction) * self.speed;
// No Y movement
// Prevent passing through buildings
for (var i = 0; typeof buildings !== "undefined" && i < buildings.length; i++) {
if (self.intersects(buildings[i])) {
self.x = prevX;
self.y = prevY;
// Reverse direction on building collision
self.direction = self.direction === 0 ? Math.PI : 0;
break;
}
}
// Bounce off city bounds (left/right only)
if (self.x < 60) {
self.x = 60;
self.direction = 0; // move right
}
if (self.x > 2048 - 60) {
self.x = 2048 - 60;
self.direction = Math.PI; // move left
}
};
return self;
});
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerSprite = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 12;
self.inCar = false;
self.car = null;
self.direction = {
x: 0,
y: 0
}; // For movement
self.update = function () {
if (!self.inCar) {
// Store previous position
var prevX = self.x;
var prevY = self.y;
self.x += self.direction.x * self.speed;
self.y += self.direction.y * self.speed;
// Prevent passing through buildings
for (var i = 0; typeof buildings !== "undefined" && i < buildings.length; i++) {
if (self.intersects(buildings[i])) {
self.x = prevX;
self.y = prevY;
break;
}
}
// Clamp to city bounds
if (self.x < 50) self.x = 50;
if (self.x > 2048 - 50) self.x = 2048 - 50;
if (self.y < 100) self.y = 100;
if (self.y > 2732 - 50) self.y = 2732 - 50;
} else if (self.car) {
// Follow car position
self.x = self.car.x;
self.y = self.car.y;
}
};
return self;
});
// Police bullet class
var PoliceBullet = Container.expand(function () {
var self = Container.call(this);
var bulletSprite = self.attachAsset('mission', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
});
self.speed = 16;
self.direction = 0;
self.lifetime = 60; // frames
self.update = function () {
if (typeof self.lastX === "undefined") self.lastX = self.x;
if (typeof self.lastY === "undefined") self.lastY = self.y;
self.x += Math.cos(self.direction) * self.speed;
self.y += Math.sin(self.direction) * self.speed;
self.lifetime--;
// Remove if out of bounds or expired
if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732 || self.lifetime <= 0) {
if (typeof policeBullets !== "undefined") {
for (var i = 0; i < policeBullets.length; i++) {
if (policeBullets[i] === self) {
policeBullets.splice(i, 1);
break;
}
}
}
self.destroy();
return;
}
self.lastX = self.x;
self.lastY = self.y;
};
return self;
});
// Police car class
var PoliceCar = Container.expand(function () {
var self = Container.call(this);
var policeSprite = self.attachAsset('police', {
anchorX: 0.5,
anchorY: 0.5
});
// Attach gun to police hand
var gunSprite = self.attachAsset('police_gun', {
anchorX: 0.1,
anchorY: 0.5
});
// Position gun at right hand (relative to policeSprite)
gunSprite.x = 50;
gunSprite.y = 20;
self.addChild(gunSprite);
self.speed = 4;
self.direction = 0;
self.target = null; // Player or car
self.sirenOn = false;
self.bulletCooldown = 0;
self.update = function () {
if (self.target) {
var prevX = self.x;
var prevY = self.y;
var tx = self.target.x - self.x;
var ty = self.target.y - self.y;
var dist = Math.sqrt(tx * tx + ty * ty);
if (dist > 10) {
self.direction = Math.atan2(ty, tx);
self.x += Math.cos(self.direction) * self.speed;
self.y += Math.sin(self.direction) * self.speed;
// Prevent passing through buildings
for (var i = 0; typeof buildings !== "undefined" && i < buildings.length; i++) {
if (self.intersects(buildings[i])) {
self.x = prevX;
self.y = prevY;
break;
}
}
}
// Fire bullet if close enough and cooldown is 0
if (dist < 600 && self.bulletCooldown <= 0 && typeof policeBullets !== "undefined") {
var bullet = new PoliceBullet();
bullet.x = self.x + Math.cos(self.direction) * 70;
bullet.y = self.y + Math.sin(self.direction) * 70;
bullet.direction = self.direction;
policeBullets.push(bullet);
if (typeof game !== "undefined") game.addChild(bullet);
self.bulletCooldown = 90 + Math.floor(Math.random() * 60); // 1.5s-2.5s
}
if (self.bulletCooldown > 0) self.bulletCooldown--;
}
// Clamp to city bounds
if (self.x < 90) self.x = 90;
if (self.x > 2048 - 90) self.x = 2048 - 90;
if (self.y < 100) self.y = 100;
if (self.y > 2732 - 90) self.y = 2732 - 90;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222222
});
/****
* Game Code
****/
// City layout
// Player character: red box
// Car: blue box
// Police car: white box with blue
// Pedestrian: green ellipse
// Road: gray box
// Building: dark gray box
// Mission marker: yellow ellipse
// Sound effects
var buildings = [];
var cars = [];
var policeCars = [];
var pedestrians = [];
var missionMarkers = [];
var score = 0;
var wantedLevel = 0;
var missionActive = false;
var missionTarget = null;
var missionText = null;
var dragNode = null;
var policeBullets = [];
var lastTouch = {
x: 0,
y: 0
};
var policeSirenTimer = 0;
// Add road background
var road = LK.getAsset('road', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
game.addChild(road);
// Add buildings only in columns along the left and right edges (no top/bottom rows)
// Left column
for (var j = 0; j < 11; j++) {
var b = new Building();
b.x = 150;
b.y = 200 + j * 210;
buildings.push(b);
game.addChild(b);
}
// Right column
for (var j = 0; j < 11; j++) {
var b = new Building();
b.x = 2048 - 150;
b.y = 200 + j * 210;
buildings.push(b);
game.addChild(b);
}
// Helper: get a random position not inside any building
function getValidSpawnPosition(minX, maxX, minY, maxY, margin, entityWidth, entityHeight) {
var tries = 0;
var x, y, tempObj;
margin = margin || 0;
entityWidth = entityWidth || 60;
entityHeight = entityHeight || 60;
do {
x = minX + Math.random() * (maxX - minX);
y = minY + Math.random() * (maxY - minY);
// Create a temp object to check intersection
tempObj = {
x: x,
y: y,
width: entityWidth,
height: entityHeight,
intersects: function intersects(b) {
// Simple AABB check
var ax1 = this.x - this.width / 2,
ay1 = this.y - this.height / 2,
ax2 = this.x + this.width / 2,
ay2 = this.y + this.height / 2;
var bx1 = b.x - 135,
by1 = b.y - 135,
bx2 = b.x + 135,
by2 = b.y + 135;
return !(ax2 < bx1 || ax1 > bx2 || ay2 < by1 || ay1 > by2);
}
};
var inside = false;
for (var i = 0; i < buildings.length; i++) {
if (tempObj.intersects(buildings[i])) {
inside = true;
break;
}
}
tries++;
if (tries > 100) break; // fallback, shouldn't happen
} while (inside);
return {
x: x,
y: y
};
}
// Add mission marker
function spawnMission() {
if (missionTarget) {
missionTarget.destroy();
}
var marker = new MissionMarker();
var pos = getValidSpawnPosition(400, 1600, 400, 2200, 0, 80, 80);
marker.x = pos.x;
marker.y = pos.y;
missionMarkers = [marker];
missionTarget = marker;
game.addChild(marker);
missionActive = true;
if (missionText) {
missionText.setText("Go to the yellow marker!");
}
}
spawnMission();
// Add player
var player = new Player();
var playerPos = getValidSpawnPosition(300, 1748, 2732 - 600, 2732 - 100, 0, 120, 120);
player.x = playerPos.x;
player.y = playerPos.y;
game.addChild(player);
// Add cars (AI)
for (var i = 0; i < 5; i++) {
var c = new Car();
var carPos = getValidSpawnPosition(400, 1600, 400, 2200, 0, 180, 90);
c.x = carPos.x;
c.y = carPos.y;
c.ai = true;
var tgt = getValidSpawnPosition(400, 1600, 400, 2200, 0, 180, 90);
c.aiTarget = {
x: tgt.x,
y: tgt.y
};
cars.push(c);
game.addChild(c);
}
// Add police car (starts inactive)
function spawnPolice() {
var pc = new PoliceCar();
var policePos = getValidSpawnPosition(200, 1800, 200, 2200, 0, 130, 130);
pc.x = policePos.x;
pc.y = policePos.y;
pc.target = player;
policeCars.push(pc);
game.addChild(pc);
}
function removeAllPolice() {
for (var i = 0; i < policeCars.length; i++) {
policeCars[i].destroy();
}
policeCars = [];
}
// Add pedestrians
for (var i = 0; i < 10; i++) {
var p = new Pedestrian();
var pedPos = getValidSpawnPosition(200, 1800, 200, 2400, 0, 120, 120);
p.x = pedPos.x;
p.y = pedPos.y;
pedestrians.push(p);
game.addChild(p);
}
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 90,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Health bar (top right)
var maxHealth = 5;
var playerHealth = maxHealth;
var healthBarWidth = 400;
var healthBarHeight = 40;
var healthBarBg = LK.getAsset('road', {
width: healthBarWidth,
height: healthBarHeight,
color: 0x222222,
anchorX: 1,
anchorY: 0,
x: 2048,
y: 0
});
var healthBarFg = LK.getAsset('mission', {
width: healthBarWidth - 8,
height: healthBarHeight - 8,
color: 0x44ff44,
anchorX: 1,
anchorY: 0,
x: 2048 - 4,
y: 4
});
LK.gui.topRight.addChild(healthBarBg);
LK.gui.topRight.addChild(healthBarFg);
// Wanted level display
var wantedTxt = new Text2('Wanted: 0', {
size: 70,
fill: 0xFF4444
});
wantedTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(wantedTxt);
wantedTxt.y = 100;
// Mission text
missionText = new Text2('Go to the yellow marker!', {
size: 70,
fill: 0xFFE100
});
missionText.anchor.set(0.5, 0);
LK.gui.top.addChild(missionText);
missionText.y = 200;
// Touch controls
var moveTouchId = null;
var moveStart = null;
var moveDir = {
x: 0,
y: 0
};
// Helper: get direction from drag
function getDir(from, to) {
var dx = to.x - from.x;
var dy = to.y - from.y;
var len = Math.sqrt(dx * dx + dy * dy);
if (len < 30) return {
x: 0,
y: 0
};
return {
x: dx / len,
y: dy / len
};
}
// Touch down: start movement or enter/exit car
game.down = function (x, y, obj) {
lastTouch.x = x;
lastTouch.y = y;
// If player is near a car and not in car, enter car
if (!player.inCar) {
for (var i = 0; i < cars.length; i++) {
var c = cars[i];
if (!c.driver && Math.abs(player.x - c.x) < 120 && Math.abs(player.y - c.y) < 90) {
// Enter car
player.inCar = true;
player.car = c;
c.driver = player;
LK.getSound('car_enter').play();
return;
}
}
} else if (player.inCar) {
// Exit car
var c = player.car;
player.inCar = false;
player.car = null;
if (c) c.driver = null;
LK.getSound('car_exit').play();
return;
}
// Set player direction toward touch/cursor
if (!player.inCar) {
var dx = x - player.x;
var dy = y - player.y;
var len = Math.sqrt(dx * dx + dy * dy);
if (len > 10) {
player.direction = {
x: dx / len,
y: dy / len
};
} else {
player.direction = {
x: 0,
y: 0
};
}
}
moveTouchId = true;
};
// Touch move: update direction
game.move = function (x, y, obj) {
lastTouch.x = x;
lastTouch.y = y;
if (moveTouchId && !player.inCar) {
var dx = x - player.x;
var dy = y - player.y;
var len = Math.sqrt(dx * dx + dy * dy);
if (len > 10) {
player.direction = {
x: dx / len,
y: dy / len
};
} else {
player.direction = {
x: 0,
y: 0
};
}
}
};
// Touch up: stop movement
game.up = function (x, y, obj) {
moveTouchId = null;
player.direction = {
x: 0,
y: 0
};
};
// Main update loop
game.update = function () {
// Update player
player.update();
// Update cars
for (var i = 0; i < cars.length; i++) {
cars[i].update();
// AI: cars do not move, so do not pick new targets
}
// Update police
for (var i = 0; i < policeCars.length; i++) {
policeCars[i].update();
// Siren sound
if (wantedLevel > 0 && LK.ticks % 60 === 0) {
LK.getSound('police_siren').play();
}
// Police catch player
// (No game over when police touch player or player's car)
if (policeCars[i].intersects(player)) {
// Optionally, you could add a visual effect or wanted level increase here
}
// Police catch player's car
if (player.inCar && policeCars[i].intersects(player.car)) {
// Optionally, you could add a visual effect or wanted level increase here
}
}
// Update police bullets and check collision with player
for (var i = policeBullets.length - 1; i >= 0; i--) {
var bullet = policeBullets[i];
bullet.update();
// Only check collision if bullet is still in game
if (bullet && player && bullet.intersects(player)) {
LK.effects.flashScreen(0xff0000, 800);
playerHealth = Math.max(0, playerHealth - 1);
// Update health bar width
var healthFrac = playerHealth / maxHealth;
healthBarFg.width = (healthBarWidth - 8) * healthFrac;
if (playerHealth <= 0) {
LK.showGameOver();
return;
}
// Remove bullet after hit
bullet.destroy();
policeBullets.splice(i, 1);
continue;
}
}
// Update pedestrians
for (var i = 0; i < pedestrians.length; i++) {
pedestrians[i].update();
// If player or car hits pedestrian, increase wanted level
if (!player.inCar && player.intersects(pedestrians[i])) {
wantedLevel = Math.min(5, wantedLevel + 1);
LK.effects.flashObject(pedestrians[i], 0xff0000, 500);
}
if (player.inCar && player.car && player.car.intersects(pedestrians[i])) {
wantedLevel = Math.min(5, wantedLevel + 1);
LK.effects.flashObject(pedestrians[i], 0xff0000, 500);
}
}
// Update mission marker
if (missionActive && missionTarget && player.intersects(missionTarget)) {
// Complete mission
LK.getSound('mission_complete').play();
score += 100;
scoreTxt.setText('Score: ' + score);
missionActive = false;
missionTarget.destroy();
missionTarget = null;
missionText.setText("Mission Complete!");
// Next mission after short delay
LK.setTimeout(function () {
spawnMission();
}, 1200);
}
// Update wanted level
wantedTxt.setText('Wanted: ' + wantedLevel);
// Police spawn logic
if (wantedLevel > 0 && policeCars.length < 1) {
spawnPolice();
}
if (wantedLevel === 0 && policeCars.length > 0) {
removeAllPolice();
}
// Wanted level decay
if (wantedLevel > 0 && LK.ticks % 180 === 0) {
wantedLevel--;
}
// Win condition: score
if (score >= 1000) {
LK.showYouWin();
return;
}
};
// Prevent elements in top left 100x100
// (All GUI elements are centered or offset downward)
// End of MVP code for GTA7: Micro City Mayhem ===================================================================
--- original.js
+++ change.js
@@ -411,8 +411,33 @@
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
+// Health bar (top right)
+var maxHealth = 5;
+var playerHealth = maxHealth;
+var healthBarWidth = 400;
+var healthBarHeight = 40;
+var healthBarBg = LK.getAsset('road', {
+ width: healthBarWidth,
+ height: healthBarHeight,
+ color: 0x222222,
+ anchorX: 1,
+ anchorY: 0,
+ x: 2048,
+ y: 0
+});
+var healthBarFg = LK.getAsset('mission', {
+ width: healthBarWidth - 8,
+ height: healthBarHeight - 8,
+ color: 0x44ff44,
+ anchorX: 1,
+ anchorY: 0,
+ x: 2048 - 4,
+ y: 4
+});
+LK.gui.topRight.addChild(healthBarBg);
+LK.gui.topRight.addChild(healthBarFg);
// Wanted level display
var wantedTxt = new Text2('Wanted: 0', {
size: 70,
fill: 0xFF4444
@@ -555,10 +580,20 @@
bullet.update();
// Only check collision if bullet is still in game
if (bullet && player && bullet.intersects(player)) {
LK.effects.flashScreen(0xff0000, 800);
- LK.showGameOver();
- return;
+ playerHealth = Math.max(0, playerHealth - 1);
+ // Update health bar width
+ var healthFrac = playerHealth / maxHealth;
+ healthBarFg.width = (healthBarWidth - 8) * healthFrac;
+ if (playerHealth <= 0) {
+ LK.showGameOver();
+ return;
+ }
+ // Remove bullet after hit
+ bullet.destroy();
+ policeBullets.splice(i, 1);
+ continue;
}
}
// Update pedestrians
for (var i = 0; i < pedestrians.length; i++) {
the modern gun. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
delete background
delete background
delete background
Draw a modern road viewed from above. In-Game asset. 2d. High contrast. No shadows
delete background
arrow pointing up. In-Game asset. 2d. High contrast. No shadows
arrow pointing down. In-Game asset. 2d. High contrast. No shadows
arrow pointing right. In-Game asset. 2d. High contrast. No shadows
arrow pointing left. In-Game asset. 2d. High contrast. No shadows
delete background
delete background