User prompt
Add drags for all cars. improve play experience
User prompt
Explosion effect should not cover all screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make police spawn from the edge of screen. Make map repeat and never end.
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 719
User prompt
Crash effect more explosive. increase all speeds by 3 times ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make sure player car is a little bit faster than police cars for lower levels, increase difficulty with time, diamonds and police crashes. Place player car in the middle through game
User prompt
Enable to move car not map itself, create a repeating-itself to make sure game is endless. Enable player moves not only rotation
User prompt
Decrease police car spawn interval (more common). Make map moves according to button moves. Place player car always in the middle.
User prompt
İncrease car speed
User prompt
Place right button more left and down, remove left button
User prompt
Buttons are not visible?
User prompt
Both buttons to more to middle
User prompt
Place button to a more visible place, upper
User prompt
Place button on right and left bottom when needed (should be 1 on the screen always)
User prompt
Make action stick button visible
User prompt
Not playable
User prompt
Touch screen doesn't work
User prompt
Not playable
User prompt
Enable screen touch playing
User prompt
increase reality of city map with more details
User prompt
increase pace and change cars icons with real car photos, police cars & bugatti for player ca
User prompt
enable desktop joystick button to use with mouse
User prompt
enable desktop play mode
User prompt
i need player to move all directions
User prompt
show console button
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var CityBackground = Container.expand(function () {
var self = Container.call(this);
var backgroundElements = [];
self.tileHeight = 400;
self.tilesPerRow = 10;
self.rows = 10;
// Create initial background tiles
for (var row = 0; row < self.rows; row++) {
for (var col = 0; col < self.tilesPerRow; col++) {
var element;
var elementType = Math.floor(Math.random() * 3);
if (elementType === 0) {
// Road
element = LK.getAsset('road', {
anchorX: 0,
anchorY: 0
});
element.width = 200;
element.height = 100;
} else if (elementType === 1) {
// Building
element = LK.getAsset('building', {
anchorX: 0,
anchorY: 0
});
element.width = 150;
element.height = 200;
} else {
// City block
element = LK.getAsset('cityBlock', {
anchorX: 0,
anchorY: 0
});
element.width = 200;
element.height = 200;
}
element.x = col * 200;
element.y = (row - 2) * self.tileHeight; // Start some tiles above screen
element.alpha = 0.7;
self.addChild(element);
backgroundElements.push(element);
}
}
self.update = function () {
// Move all background elements with map speed
for (var i = backgroundElements.length - 1; i >= 0; i--) {
var element = backgroundElements[i];
element.y += mapSpeed;
// Remove elements that went off screen bottom
if (element.y > 2732 + 400) {
element.destroy();
backgroundElements.splice(i, 1);
}
}
// Add new row of tiles at the top when needed
if (backgroundElements.length < self.tilesPerRow * 8) {
var topY = -800;
for (var col = 0; col < self.tilesPerRow; col++) {
var element;
var elementType = Math.floor(Math.random() * 3);
if (elementType === 0) {
element = LK.getAsset('road', {
anchorX: 0,
anchorY: 0
});
element.width = 200;
element.height = 100;
} else if (elementType === 1) {
element = LK.getAsset('building', {
anchorX: 0,
anchorY: 0
});
element.width = 150;
element.height = 200;
} else {
element = LK.getAsset('cityBlock', {
anchorX: 0,
anchorY: 0
});
element.width = 200;
element.height = 200;
}
element.x = col * 200;
element.y = topY;
element.alpha = 0.7;
self.addChild(element);
backgroundElements.push(element);
}
}
};
return self;
});
var Diamond = Container.expand(function () {
var self = Container.call(this);
var diamondGraphics = self.attachAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.rotationSpeed = 0.05;
self.update = function () {
diamondGraphics.rotation += self.rotationSpeed;
// Move with map scrolling
self.y += mapSpeed;
// Remove diamonds that go off screen
if (self.y > 2732 + 100) {
self.destroy();
}
};
return self;
});
var Explosion = Container.expand(function () {
var self = Container.call(this);
var explosionGraphics = self.attachAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5
});
self.lifetime = 30;
self.age = 0;
self.update = function () {
self.age++;
explosionGraphics.alpha = 1 - self.age / self.lifetime;
explosionGraphics.scaleX = 1 + self.age / self.lifetime;
explosionGraphics.scaleY = 1 + self.age / self.lifetime;
// Move with map scrolling
self.y += mapSpeed;
if (self.age >= self.lifetime) {
self.destroy();
}
};
return self;
});
var GetawayCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('getawayCar', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.maxSpeed = 12;
self.velocityX = 0;
self.velocityY = 0;
self.acceleration = 0.5;
self.friction = 0.85;
self.update = function () {
// Apply joystick input if available
if (joystick && joystick.isActive) {
self.velocityX += joystick.currentX * self.acceleration;
self.velocityY += joystick.currentY * self.acceleration;
// Rotate car to face movement direction
if (joystick.currentX !== 0 || joystick.currentY !== 0) {
var angle = Math.atan2(joystick.currentY, joystick.currentX);
carGraphics.rotation = angle + Math.PI / 2;
}
}
// Apply friction
self.velocityX *= self.friction;
self.velocityY *= self.friction;
// Limit velocity
var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY);
if (speed > self.maxSpeed) {
self.velocityX = self.velocityX / speed * self.maxSpeed;
self.velocityY = self.velocityY / speed * self.maxSpeed;
}
// Move player
self.x += self.velocityX;
self.y += self.velocityY;
// Keep player within bounds with more generous boundaries
self.x = Math.max(40, Math.min(2008, self.x));
self.y = Math.max(40, Math.min(2692, self.y));
};
return self;
});
var JoystickControl = Container.expand(function () {
var self = Container.call(this);
var joystickBase = self.attachAsset('joystickBase', {
anchorX: 0.5,
anchorY: 0.5
});
var joystickKnob = self.attachAsset('joystickKnob', {
anchorX: 0.5,
anchorY: 0.5
});
joystickBase.alpha = 0.8;
joystickKnob.alpha = 1.0;
self.isActive = false;
self.currentX = 0;
self.currentY = 0;
self.maxDistance = 100;
self.down = function (x, y, obj) {
self.isActive = true;
self.updateKnob(x, y);
};
self.move = function (x, y, obj) {
if (self.isActive) {
self.updateKnob(x, y);
}
};
self.up = function (x, y, obj) {
self.isActive = false;
joystickKnob.x = 0;
joystickKnob.y = 0;
self.currentX = 0;
self.currentY = 0;
};
self.updateKnob = function (x, y) {
var deltaX = x;
var deltaY = y;
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
if (distance > self.maxDistance) {
deltaX = deltaX / distance * self.maxDistance;
deltaY = deltaY / distance * self.maxDistance;
}
joystickKnob.x = deltaX;
joystickKnob.y = deltaY;
self.currentX = deltaX / self.maxDistance;
self.currentY = deltaY / self.maxDistance;
};
return self;
});
var PoliceCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('policeCar', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.targetCar = null;
self.lastCollisionCheck = false;
self.velocityX = 0;
self.velocityY = 0;
self.acceleration = 0.2;
self.friction = 0.95;
self.update = function () {
if (self.targetCar) {
var deltaX = self.targetCar.x - self.x;
var deltaY = self.targetCar.y - self.y;
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
if (distance > 5) {
// Apply acceleration towards target
self.velocityX += deltaX / distance * self.acceleration;
self.velocityY += deltaY / distance * self.acceleration;
// Rotate car to face movement direction
var angle = Math.atan2(deltaY, deltaX);
carGraphics.rotation = angle + Math.PI / 2;
}
}
// Apply friction
self.velocityX *= self.friction;
self.velocityY *= self.friction;
// Limit velocity
var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY);
if (speed > self.speed) {
self.velocityX = self.velocityX / speed * self.speed;
self.velocityY = self.velocityY / speed * self.speed;
}
// Move police car
self.x += self.velocityX;
self.y += self.velocityY;
// Move with map scrolling
self.y += mapSpeed;
// Remove police cars that go off screen
if (self.y > 2732 + 100) {
self.destroy();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
// Game variables
var player;
var policeCars = [];
var diamonds = [];
var explosions = [];
var gameSpeed = 1;
var milestone = 0;
var diamondsCollected = 0;
var policeKills = 0;
var mapSpeed = 6;
var mapOffsetY = 0;
var baseMapSpeed = 6;
// Background colors for different milestones
var backgroundColors = [0x2c3e50, 0x34495e, 0x1abc9c, 0x16a085, 0x27ae60, 0x2980b9];
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var diamondsTxt = new Text2('Diamonds: 0', {
size: 50,
fill: 0xF1C40F
});
diamondsTxt.anchor.set(0, 0);
diamondsTxt.x = 120;
diamondsTxt.y = 100;
LK.gui.topLeft.addChild(diamondsTxt);
var killsTxt = new Text2('Police Crashes: 0', {
size: 50,
fill: 0xE74C3C
});
killsTxt.anchor.set(1, 0);
killsTxt.x = -20;
killsTxt.y = 100;
LK.gui.topRight.addChild(killsTxt);
// Initialize city background
var cityBackground = game.addChild(new CityBackground());
// Initialize joystick control
var joystick = new JoystickControl();
joystick.x = 200;
joystick.y = 2532;
LK.gui.bottomLeft.addChild(joystick);
// Initialize player
player = game.addChild(new GetawayCar());
player.x = 1024; // Center horizontally
player.y = 1366; // Center vertically
// Spawn initial police cars
function spawnPoliceCar() {
var police = new PoliceCar();
// Spawn from random edge, favoring top and sides for moving map
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top (ahead of player)
police.x = Math.random() * 2048;
police.y = -60;
break;
case 1:
// Right
police.x = 2048 + 60;
police.y = Math.random() * 1000; // Spawn closer to top
break;
case 2:
// Bottom (behind player, will move forward)
police.x = Math.random() * 2048;
police.y = 2732 + 60;
break;
case 3:
// Left
police.x = -60;
police.y = Math.random() * 1000; // Spawn closer to top
break;
}
police.targetCar = player;
police.speed = 2 + milestone * 0.5;
policeCars.push(police);
game.addChild(police);
}
// Spawn initial diamonds
function spawnDiamond() {
var diamond = new Diamond();
diamond.x = 100 + Math.random() * 1848;
diamond.y = -100 - Math.random() * 500; // Spawn ahead of player
diamonds.push(diamond);
game.addChild(diamond);
}
// Initialize game objects
for (var i = 0; i < 3; i++) {
spawnPoliceCar();
}
for (var i = 0; i < 1; i++) {
spawnDiamond();
}
// Joystick controls are now handled by the JoystickControl class
// Update score display
function updateScore() {
var totalScore = diamondsCollected * 100 + policeKills * 500;
LK.setScore(totalScore);
scoreTxt.setText('Score: ' + totalScore);
diamondsTxt.setText('Diamonds: ' + diamondsCollected);
killsTxt.setText('Police Crashes: ' + policeKills);
}
// Check milestone progression
function checkMilestone() {
var newMilestone = Math.floor(LK.getScore() / 1000);
if (newMilestone > milestone) {
milestone = newMilestone;
// Change background color
if (milestone < backgroundColors.length) {
tween(game, {
backgroundColor: backgroundColors[milestone]
}, {
duration: 2000
});
}
// Spawn additional police car
spawnPoliceCar();
}
}
// Create explosion effect
function createExplosion(x, y) {
var explosion = new Explosion();
explosion.x = x;
explosion.y = y;
explosions.push(explosion);
game.addChild(explosion);
}
// Main game loop
game.update = function () {
// Check diamond collection
for (var i = diamonds.length - 1; i >= 0; i--) {
var diamond = diamonds[i];
if (!diamond.collected && player.intersects(diamond)) {
diamond.collected = true;
diamondsCollected++;
LK.getSound('collectDiamond').play();
diamond.destroy();
diamonds.splice(i, 1);
// Spawn new diamond
spawnDiamond();
}
}
// Check police car collisions with player
for (var i = 0; i < policeCars.length; i++) {
var police = policeCars[i];
if (player.intersects(police)) {
LK.getSound('gameOver').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// Check police car collisions with each other
for (var i = policeCars.length - 1; i >= 0; i--) {
var police1 = policeCars[i];
var collided = false;
for (var j = i + 1; j < policeCars.length; j++) {
var police2 = policeCars[j];
if (police1.intersects(police2)) {
// Create explosion
var explosionX = (police1.x + police2.x) / 2;
var explosionY = (police1.y + police2.y) / 2;
createExplosion(explosionX, explosionY);
policeKills++;
LK.getSound('policeExplode').play();
// Increase map speed by 1%
mapSpeed = mapSpeed * 1.01;
// Remove both police cars
police1.destroy();
police2.destroy();
policeCars.splice(j, 1);
policeCars.splice(i, 1);
collided = true;
break;
}
}
if (collided) break;
}
// Clean up police cars that went off screen
for (var i = policeCars.length - 1; i >= 0; i--) {
var police = policeCars[i];
if (police.y > 2732 + 100) {
police.destroy();
policeCars.splice(i, 1);
}
}
// Clean up diamonds that went off screen
for (var i = diamonds.length - 1; i >= 0; i--) {
var diamond = diamonds[i];
if (diamond.y > 2732 + 100) {
diamond.destroy();
diamonds.splice(i, 1);
// Spawn new diamond
spawnDiamond();
}
}
// Clean up explosions
for (var i = explosions.length - 1; i >= 0; i--) {
var explosion = explosions[i];
if (explosion.age >= explosion.lifetime) {
explosions.splice(i, 1);
}
}
// Spawn new police cars periodically
if (LK.ticks % (300 - milestone * 30) === 0) {
spawnPoliceCar();
}
// Spawn new diamonds periodically
if (LK.ticks % 500 === 0) {
spawnDiamond();
}
// Update score and check milestones
updateScore();
checkMilestone();
// Win condition
if (LK.getScore() >= 10000) {
LK.showYouWin();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -144,13 +144,13 @@
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
- self.maxSpeed = 8;
+ self.maxSpeed = 12;
self.velocityX = 0;
self.velocityY = 0;
- self.acceleration = 0.3;
- self.friction = 0.9;
+ self.acceleration = 0.5;
+ self.friction = 0.85;
self.update = function () {
// Apply joystick input if available
if (joystick && joystick.isActive) {
self.velocityX += joystick.currentX * self.acceleration;
@@ -172,11 +172,11 @@
}
// Move player
self.x += self.velocityX;
self.y += self.velocityY;
- // Keep player within bounds
- self.x = Math.max(100, Math.min(1948, self.x));
- self.y = Math.max(100, Math.min(2632, self.y));
+ // Keep player within bounds with more generous boundaries
+ self.x = Math.max(40, Math.min(2008, self.x));
+ self.y = Math.max(40, Math.min(2692, self.y));
};
return self;
});
var JoystickControl = Container.expand(function () {
@@ -193,9 +193,9 @@
joystickKnob.alpha = 1.0;
self.isActive = false;
self.currentX = 0;
self.currentY = 0;
- self.maxDistance = 80;
+ self.maxDistance = 100;
self.down = function (x, y, obj) {
self.isActive = true;
self.updateKnob(x, y);
};