User prompt
If you tap playercar1 10 times at the entrance, it will start from 2000 directly.
User prompt
Let's crush and kill bomberperson
User prompt
make your own bomb throwers image
User prompt
change the image of the bomb throwers
User prompt
Add people who throw bombs on the road and let them come from time to time
User prompt
playercar3 open at 2000 score
User prompt
playercar3 change your image
User prompt
add a new car
User prompt
put car selection at the bottom
User prompt
Don't close the texts in the place where you can choose a car
User prompt
1. Let the car make a quick turn 2. The car should turn slowly and its speed should be very fast ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Uncaught ReferenceError: updateCarSelection is not defined' in or related to this line: 'updateCarSelection();' Line Number: 689
User prompt
Let's choose between car 1 and car 2 in the menu
User prompt
Add a new car
User prompt
Let there be a cup on the road, when we take the heart, we have the right to hit it once
User prompt
remove language option
User prompt
When you press Turkish, everything including the menu will be in Turkish. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
türkçeye basınca oyun türkçe olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Have Turkish and English language options in the start menu ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Write the best score next to the score ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
The game gets harder as it progresses
User prompt
When the car hits the enemies it will explode and have a pixek art explosion effect ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When the car hits the enemies it will explode and have a pixek art explosion effect ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add small and beautiful details ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var saved = storage.get('bestDistance');' Line Number: 140 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Cup = Container.expand(function () {
var self = Container.call(this);
var cupGraphics = self.attachAsset('cup', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.rotationSpeed = 0.15;
self.pulseScale = 1;
self.pulseDirection = 1;
self.update = function () {
self.speed = 8 * gameSpeed;
self.y += self.speed;
cupGraphics.rotation += self.rotationSpeed;
// Pulsing effect
self.pulseScale += self.pulseDirection * 0.03;
if (self.pulseScale > 1.4) {
self.pulseDirection = -1;
} else if (self.pulseScale < 0.9) {
self.pulseDirection = 1;
}
cupGraphics.scaleX = self.pulseScale;
cupGraphics.scaleY = self.pulseScale;
// Golden tint for visual appeal
cupGraphics.tint = 0xFFD700;
};
return self;
});
var EnemyCar = Container.expand(function (carType) {
var self = Container.call(this);
var assetId = carType || 'enemyCar1';
var carGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.lane = 0;
self.update = function () {
// Progressive speed increase with difficulty
var difficultyMultiplier = 1 + distanceTraveled / 8000; // Enemies get faster over time
self.speed = 8 * gameSpeed * difficultyMultiplier;
self.y += self.speed;
// Add subtle bobbing motion for visual interest
carGraphics.rotation = Math.sin(LK.ticks * 0.05) * 0.02;
};
return self;
});
var Explosion = Container.expand(function () {
var self = Container.call(this);
self.particles = [];
self.lifeTime = 0;
self.maxLifeTime = 60; // 1 second at 60fps
// Create explosion particles
for (var i = 0; i < 12; i++) {
var particle = self.addChild(LK.getAsset('roadLine', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
}));
particle.tint = [0xFF4500, 0xFF6600, 0xFF8800, 0xFFAA00, 0xFFCC00][Math.floor(Math.random() * 5)];
particle.vx = (Math.random() - 0.5) * 20;
particle.vy = (Math.random() - 0.5) * 20;
particle.gravity = 0.5;
particle.friction = 0.95;
self.particles.push(particle);
}
self.update = function () {
self.lifeTime++;
// Update particles
for (var i = 0; i < self.particles.length; i++) {
var particle = self.particles[i];
particle.x += particle.vx;
particle.y += particle.vy;
particle.vy += particle.gravity;
particle.vx *= particle.friction;
particle.vy *= particle.friction;
// Fade out over time
particle.alpha = 1 - self.lifeTime / self.maxLifeTime;
}
// Destroy explosion when done
if (self.lifeTime >= self.maxLifeTime) {
self.destroy();
}
};
return self;
});
var Nitro = Container.expand(function () {
var self = Container.call(this);
var nitroGraphics = self.attachAsset('nitro', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.rotationSpeed = 0.2;
self.pulseScale = 1;
self.pulseDirection = 1;
self.update = function () {
self.y += self.speed;
nitroGraphics.rotation += self.rotationSpeed;
// Pulsing effect
self.pulseScale += self.pulseDirection * 0.02;
if (self.pulseScale > 1.3) {
self.pulseDirection = -1;
} else if (self.pulseScale < 0.8) {
self.pulseDirection = 1;
}
nitroGraphics.scaleX = self.pulseScale;
nitroGraphics.scaleY = self.pulseScale;
};
return self;
});
var PlayerCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('playerCar', {
anchorX: 0.5,
anchorY: 0.5
});
self.targetLane = 1;
self.currentLane = 1;
self.laneWidth = 400;
self.moveSpeed = 0.35;
self.update = function () {
var targetX = self.getLaneX(self.targetLane);
var diff = targetX - self.x;
var adjustedMoveSpeed = self.moveSpeed * (1 + (gameSpeed - 1) * 0.5);
if (Math.abs(diff) > 5) {
self.x += diff * adjustedMoveSpeed;
} else {
self.x = targetX;
self.currentLane = self.targetLane;
}
};
self.getLaneX = function (lane) {
return 424 + lane * self.laneWidth;
};
self.switchLane = function (direction) {
var newLane = self.targetLane + direction;
if (newLane >= 0 && newLane <= 3) {
self.targetLane = newLane;
// Add slow dramatic turn effect when switching lanes
tween(carGraphics, {
rotation: direction * 0.4
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(carGraphics, {
rotation: 0
}, {
duration: 600,
easing: tween.easeIn
});
}
});
}
};
return self;
});
var PlayerCar2 = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('playerCar2', {
anchorX: 0.5,
anchorY: 0.5
});
self.targetLane = 1;
self.currentLane = 1;
self.laneWidth = 400;
self.moveSpeed = 0.42; // Much faster lane switching speed
self.update = function () {
var targetX = self.getLaneX(self.targetLane);
var diff = targetX - self.x;
var adjustedMoveSpeed = self.moveSpeed * (1 + (gameSpeed - 1) * 0.5);
if (Math.abs(diff) > 5) {
self.x += diff * adjustedMoveSpeed;
} else {
self.x = targetX;
self.currentLane = self.targetLane;
}
};
self.getLaneX = function (lane) {
return 424 + lane * self.laneWidth;
};
self.switchLane = function (direction) {
var newLane = self.targetLane + direction;
if (newLane >= 0 && newLane <= 3) {
self.targetLane = newLane;
// Add slow dramatic turn effect when switching lanes with different rotation
tween(carGraphics, {
rotation: direction * 0.5
}, {
duration: 900,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(carGraphics, {
rotation: 0
}, {
duration: 700,
easing: tween.easeIn
});
}
});
}
};
return self;
});
var PlayerCar3 = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('enemyCar1', {
anchorX: 0.5,
anchorY: 0.5
});
// Make it visually distinct with tint
carGraphics.tint = 0x9932CC; // Purple color
self.targetLane = 1;
self.currentLane = 1;
self.laneWidth = 400;
self.moveSpeed = 0.38; // Faster lane switching speed
self.update = function () {
var targetX = self.getLaneX(self.targetLane);
var diff = targetX - self.x;
var adjustedMoveSpeed = self.moveSpeed * (1 + (gameSpeed - 1) * 0.5);
if (Math.abs(diff) > 5) {
self.x += diff * adjustedMoveSpeed;
} else {
self.x = targetX;
self.currentLane = self.targetLane;
}
};
self.getLaneX = function (lane) {
return 424 + lane * self.laneWidth;
};
self.switchLane = function (direction) {
var newLane = self.targetLane + direction;
if (newLane >= 0 && newLane <= 3) {
self.targetLane = newLane;
// Add slow dramatic turn effect when switching lanes
tween(carGraphics, {
rotation: direction * 0.3
}, {
duration: 750,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(carGraphics, {
rotation: 0
}, {
duration: 550,
easing: tween.easeIn
});
}
});
}
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.rotationSpeed = 0.1;
self.update = function () {
self.speed = 8 * gameSpeed;
self.y += self.speed;
powerUpGraphics.rotation += self.rotationSpeed;
};
return self;
});
var RoadLine = Container.expand(function () {
var self = Container.call(this);
var lineGraphics = self.attachAsset('roadLine', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.speed = 8 * gameSpeed;
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
// Game state management
var gameState = 'menu'; // 'menu', 'playing', 'gameOver'
var menuElements = [];
var bestDistance = 0;
// Load best score from storage
function loadBestScore() {
var saved = storage.bestDistance;
if (saved !== undefined) {
bestDistance = saved;
}
}
// Save best score to storage
function saveBestScore() {
storage.bestDistance = bestDistance;
}
// Start menu creation
function createStartMenu() {
// Create road background for menu
for (var i = 0; i < 15; i++) {
for (var lane = 0; lane < 4; lane++) {
var menuLine = LK.getAsset('roadLine', {
anchorX: 0.5,
anchorY: 0.5,
x: 624 + lane * 400,
y: i * 180 + 200
});
menuLine.alpha = 0.3;
game.addChild(menuLine);
menuElements.push(menuLine);
}
}
// Add some background cars for visual appeal
for (var c = 0; c < 3; c++) {
var bgCar = LK.getAsset('enemyCar1', {
anchorX: 0.5,
anchorY: 0.5,
x: 424 + Math.floor(Math.random() * 4) * 400,
y: 300 + c * 800,
scaleX: 0.8,
scaleY: 0.8
});
bgCar.alpha = 0.4;
bgCar.tint = 0x666666;
game.addChild(bgCar);
menuElements.push(bgCar);
}
// Dark overlay for better text readability
var overlay = LK.getAsset('enemyCar3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 25,
scaleY: 40,
x: 1024,
y: 1366
});
overlay.alpha = 0.7;
overlay.tint = 0x000000;
game.addChild(overlay);
menuElements.push(overlay);
// Title with glow effect
var titleShadow = new Text2('HIGHWAY RUSH', {
size: 124,
fill: '#FF6B00'
});
titleShadow.anchor.set(0.5, 0.5);
titleShadow.x = 1028;
titleShadow.y = 804;
titleShadow.alpha = 0.8;
game.addChild(titleShadow);
menuElements.push(titleShadow);
var titleText = new Text2('HIGHWAY RUSH', {
size: 120,
fill: '#FFD700'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 800;
game.addChild(titleText);
menuElements.push(titleText);
// Subtitle with improved styling
var subtitleText = new Text2('Endless Car Racing Adventure', {
size: 65,
fill: '#FFFFFF'
});
subtitleText.anchor.set(0.5, 0.5);
subtitleText.x = 1024;
subtitleText.y = 950;
game.addChild(subtitleText);
menuElements.push(subtitleText);
// Game features list
var featuresText = new Text2('• Swipe or tap to change lanes\n• Avoid traffic and collect power-ups\n• Get nitro boosts for extra speed\n• Survive as long as possible!', {
size: 48,
fill: '#CCCCCC'
});
featuresText.anchor.set(0.5, 0.5);
featuresText.x = 1024;
featuresText.y = 1180;
game.addChild(featuresText);
menuElements.push(featuresText);
// Play button with enhanced design
var playButtonShadow = LK.getAsset('enemyCar3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3.1,
scaleY: 1.1,
x: 1028,
y: 1354
});
playButtonShadow.tint = 0x000000;
playButtonShadow.alpha = 0.5;
game.addChild(playButtonShadow);
menuElements.push(playButtonShadow);
var playButtonBg = LK.getAsset('enemyCar3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1,
x: 1024,
y: 1350
});
playButtonBg.tint = 0x4CAF50;
game.addChild(playButtonBg);
menuElements.push(playButtonBg);
// Play button text with glow
var playButtonTextShadow = new Text2('TAP TO START', {
size: 84,
fill: '#228B22'
});
playButtonTextShadow.anchor.set(0.5, 0.5);
playButtonTextShadow.x = 1028;
playButtonTextShadow.y = 1354;
playButtonTextShadow.alpha = 0.8;
game.addChild(playButtonTextShadow);
menuElements.push(playButtonTextShadow);
var playButtonText = new Text2('TAP TO START', {
size: 80,
fill: '#FFFFFF'
});
playButtonText.anchor.set(0.5, 0.5);
playButtonText.x = 1024;
playButtonText.y = 1350;
game.addChild(playButtonText);
menuElements.push(playButtonText);
// Best score display
var bestScoreText = new Text2('Best Distance: ' + bestDistance, {
size: 55,
fill: '#FFD700'
});
bestScoreText.anchor.set(0.5, 0.5);
bestScoreText.x = 1024;
bestScoreText.y = 1450;
game.addChild(bestScoreText);
menuElements.push(bestScoreText);
// Add gentle floating animation to best score
tween(bestScoreText, {
y: 1470
}, {
duration: 2500,
yoyo: true,
repeat: -1,
easing: tween.easeInOut
});
// Animate title with pulsing effect
tween(titleText, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1500,
yoyo: true,
repeat: -1
});
// Add twinkling effect to title
tween(titleText, {
alpha: 0.8
}, {
duration: 800,
yoyo: true,
repeat: -1,
easing: tween.easeInOut
});
// Car selection instruction text (permanent)
var carSelectionText = new Text2('Choose your car:', {
size: 52,
fill: '#FFFFFF'
});
carSelectionText.anchor.set(0.5, 0.5);
carSelectionText.x = 1024;
carSelectionText.y = 1550;
game.addChild(carSelectionText);
menuElements.push(carSelectionText);
// Car selection buttons at bottom
var car1Button = LK.getAsset('playerCar', {
anchorX: 0.5,
anchorY: 0.5,
x: 624,
y: 1650,
scaleX: 0.8,
scaleY: 0.8
});
game.addChild(car1Button);
menuElements.push(car1Button);
var car2Button = LK.getAsset('playerCar2', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1650,
scaleX: 0.8,
scaleY: 0.8
});
game.addChild(car2Button);
menuElements.push(car2Button);
var car3Button = LK.getAsset('enemyCar1', {
anchorX: 0.5,
anchorY: 0.5,
x: 1424,
y: 1650,
scaleX: 0.8,
scaleY: 0.8
});
car3Button.tint = 0x9932CC; // Purple color to match PlayerCar3
game.addChild(car3Button);
menuElements.push(car3Button);
// Car selection labels
var car1Label = new Text2('CAR 1', {
size: 48,
fill: '#FFFFFF'
});
car1Label.anchor.set(0.5, 0.5);
car1Label.x = 624;
car1Label.y = 1600;
game.addChild(car1Label);
menuElements.push(car1Label);
var car2Label = new Text2('CAR 2', {
size: 48,
fill: '#FFFFFF'
});
car2Label.anchor.set(0.5, 0.5);
car2Label.x = 1024;
car2Label.y = 1600;
game.addChild(car2Label);
menuElements.push(car2Label);
var car3Label = new Text2('CAR 3', {
size: 48,
fill: '#FFFFFF'
});
car3Label.anchor.set(0.5, 0.5);
car3Label.x = 1424;
car3Label.y = 1600;
game.addChild(car3Label);
menuElements.push(car3Label);
// Selection indicator
selectionIndicator = LK.getAsset('roadLine', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 0.5,
x: selectedCarType === 0 ? 624 : selectedCarType === 1 ? 1024 : 1424,
y: 1720
});
selectionIndicator.tint = 0xFFD700;
game.addChild(selectionIndicator);
menuElements.push(selectionIndicator);
// Initialize selection visual state
updateCarSelection();
// Add floating animation to car buttons
tween(car1Button, {
y: 1670
}, {
duration: 2000,
yoyo: true,
repeat: -1
});
tween(car2Button, {
y: 1670
}, {
duration: 2200,
yoyo: true,
repeat: -1
});
tween(car3Button, {
y: 1670
}, {
duration: 2400,
yoyo: true,
repeat: -1
});
// Animate title shadow
tween(titleShadow, {
scaleX: 1.15,
scaleY: 1.15
}, {
duration: 1500,
yoyo: true,
repeat: -1
});
// Animate play button
tween(playButtonBg, {
scaleX: 3.2,
scaleY: 1.1
}, {
duration: 1000,
yoyo: true,
repeat: -1
});
// Add breathing animation to play button text
tween(playButtonText, {
scaleX: 1.05,
scaleY: 1.05
}, {
duration: 1200,
yoyo: true,
repeat: -1,
easing: tween.easeInOut
});
// Animate subtitle
tween(subtitleText, {
alpha: 0.7
}, {
duration: 2000,
yoyo: true,
repeat: -1
});
// Floating animation for features text
tween(featuresText, {
y: 1270
}, {
duration: 3000,
yoyo: true,
repeat: -1
});
}
function removeStartMenu() {
for (var i = 0; i < menuElements.length; i++) {
menuElements[i].destroy();
}
menuElements = [];
}
function startGame() {
gameState = 'playing';
removeStartMenu();
loadBestScore();
initializeGameplay();
}
function initializeGameplay() {
// Initialize all game variables
gameSpeed = 1;
spawnTimer = 0;
spawnRate = 120;
lineSpawnTimer = 0;
powerUpSpawnTimer = 0;
nitroSpawnTimer = 0;
cupSpawnTimer = 0;
distanceTraveled = 0;
nitroEffect = false;
nitroEndTime = 0;
hasShield = false;
// Reset score
LK.setScore(0);
// Update UI texts with English
scoreTxt.setText('Distance: 0');
bestScoreTxt.setText('Best: ' + bestDistance);
speedTxt.setText('Speed: 1x');
// Reinitialize player car to ensure it's properly set up
initializePlayerCar();
}
// Initialize best score system
loadBestScore();
// Create start menu on game load
createStartMenu();
// Car selection variable
var selectedCarType = 0; // 0 for PlayerCar, 1 for PlayerCar2, 2 for PlayerCar3
var playerCar;
var selectionIndicator;
// Update car selection visual state
function updateCarSelection() {
if (selectionIndicator) {
selectionIndicator.x = selectedCarType === 0 ? 624 : selectedCarType === 1 ? 1024 : 1424;
}
// Update car button tints if they exist
if (menuElements.length > 0) {
for (var i = 0; i < menuElements.length; i++) {
var element = menuElements[i];
if (element.x === 624 && element.y === 1650) {
element.tint = selectedCarType === 0 ? 0xFFD700 : 0xFFFFFF;
} else if (element.x === 1024 && element.y === 1650) {
element.tint = selectedCarType === 1 ? 0xFFD700 : 0xFFFFFF;
} else if (element.x === 1424 && element.y === 1650) {
element.tint = selectedCarType === 2 ? 0xFFD700 : element.tint === 0x9932CC ? 0x9932CC : 0xFFFFFF;
}
}
}
}
// Initialize player car based on selection
function initializePlayerCar() {
if (playerCar) {
playerCar.destroy();
}
if (selectedCarType === 0) {
playerCar = game.addChild(new PlayerCar());
} else if (selectedCarType === 1) {
playerCar = game.addChild(new PlayerCar2());
} else {
playerCar = game.addChild(new PlayerCar3());
}
playerCar.x = 424 + 400; // Lane 1
playerCar.y = 2200;
}
// Initialize the first car
initializePlayerCar();
var enemyCars = [];
var powerUps = [];
var roadLines = [];
var nitros = [];
var cups = [];
var gameSpeed = 1;
var spawnTimer = 0;
var spawnRate = 120;
var lineSpawnTimer = 0;
var powerUpSpawnTimer = 0;
var nitroSpawnTimer = 0;
var cupSpawnTimer = 0;
var distanceTraveled = 0;
var nitroEffect = false;
var nitroEndTime = 0;
var hasShield = false;
// Create initial road lines
for (var i = 0; i < 20; i++) {
for (var lane = 0; lane < 4; lane++) {
var line = game.addChild(new RoadLine());
line.x = 624 + lane * 400; // Between lanes
line.y = i * 150 - 200;
roadLines.push(line);
}
}
// UI Elements
var scoreTxt = new Text2('Distance: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var bestScoreTxt = new Text2('Best: ' + bestDistance, {
size: 60,
fill: 0xFFD700
});
bestScoreTxt.anchor.set(0.5, 0);
bestScoreTxt.y = 90;
LK.gui.top.addChild(bestScoreTxt);
var speedTxt = new Text2('Speed: 1x', {
size: 60,
fill: 0xFFFFFF
});
speedTxt.anchor.set(1, 0);
speedTxt.x = -20;
speedTxt.y = 100;
LK.gui.topRight.addChild(speedTxt);
// Touch controls
var touchStartX = 0;
var touchStartTime = 0;
game.down = function (x, y, obj) {
if (gameState === 'menu') {
// Check car selection buttons
if (y >= 1550 && y <= 1750) {
if (x >= 524 && x <= 724) {
// Car 1 selected
selectedCarType = 0;
updateCarSelection();
initializePlayerCar();
return;
} else if (x >= 924 && x <= 1124) {
// Car 2 selected
selectedCarType = 1;
updateCarSelection();
initializePlayerCar();
return;
} else if (x >= 1324 && x <= 1524) {
// Car 3 selected
selectedCarType = 2;
updateCarSelection();
initializePlayerCar();
return;
}
}
// Any other touch on menu starts the game
startGame();
return;
}
touchStartX = x;
touchStartTime = LK.ticks;
};
game.up = function (x, y, obj) {
if (gameState !== 'playing') return;
var touchEndX = x;
var swipeDistance = touchEndX - touchStartX;
var touchDuration = LK.ticks - touchStartTime;
// Detect swipe or tap
if (Math.abs(swipeDistance) > 100 && touchDuration < 30) {
// Swipe detected
if (swipeDistance > 0) {
playerCar.switchLane(1); // Swipe right
} else {
playerCar.switchLane(-1); // Swipe left
}
} else if (touchDuration < 15) {
// Quick tap - determine direction based on screen side
if (x > 1024) {
playerCar.switchLane(1); // Right side tap
} else {
playerCar.switchLane(-1); // Left side tap
}
}
};
function spawnEnemyCar() {
var lane = Math.floor(Math.random() * 4);
var carTypes = ['enemyCar1', 'enemyCar2', 'enemyCar3'];
var carType = carTypes[Math.floor(Math.random() * carTypes.length)];
var enemy = game.addChild(new EnemyCar(carType));
enemy.x = 424 + lane * 400;
enemy.y = -100;
enemy.lane = lane;
enemy.speed = 8 * gameSpeed;
enemyCars.push(enemy);
}
function spawnPowerUp() {
// Reduce spawn chance as difficulty increases
var spawnChance = Math.max(0.1, 0.3 - distanceTraveled / 25000); // Decreases from 30% to 10%
if (Math.random() < spawnChance) {
var lane = Math.floor(Math.random() * 4);
var powerUp = game.addChild(new PowerUp());
powerUp.x = 424 + lane * 400;
powerUp.y = -100;
powerUp.speed = 8 * gameSpeed;
powerUps.push(powerUp);
}
}
function spawnNitro() {
// Significantly reduce spawn chance as difficulty increases
var spawnChance = Math.max(0.05, 0.2 - distanceTraveled / 20000); // Decreases from 20% to 5%
if (Math.random() < spawnChance) {
var lane = Math.floor(Math.random() * 4);
var nitro = game.addChild(new Nitro());
nitro.x = 424 + lane * 400;
nitro.y = -100;
nitro.speed = 8 * gameSpeed;
nitros.push(nitro);
}
}
function spawnCup() {
// Rare spawn chance for cups
var spawnChance = Math.max(0.03, 0.15 - distanceTraveled / 30000); // Decreases from 15% to 3%
if (Math.random() < spawnChance) {
var lane = Math.floor(Math.random() * 4);
var cup = game.addChild(new Cup());
cup.x = 424 + lane * 400;
cup.y = -100;
cup.speed = 8 * gameSpeed;
cups.push(cup);
}
}
game.update = function () {
// Only update game logic when playing
if (gameState !== 'playing') return;
// Update distance and speed with accelerated progression
distanceTraveled += gameSpeed;
var lastGameSpeed = gameSpeed;
// More aggressive speed scaling for increased difficulty
gameSpeed = 1 + distanceTraveled / 7000 + Math.pow(distanceTraveled / 15000, 1.5);
gameSpeed = Math.min(gameSpeed, 4); // Cap maximum speed to keep game playable
scoreTxt.setText('Distance: ' + Math.floor(distanceTraveled));
bestScoreTxt.setText('Best: ' + bestDistance);
speedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x');
// Add pulsing effect when speed increases
if (gameSpeed > lastGameSpeed + 0.1) {
tween(speedTxt, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(speedTxt, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
}
});
}
// Spawn enemies with progressive difficulty
spawnTimer++;
var adjustedSpawnRate = Math.max(30, spawnRate - Math.floor(distanceTraveled / 500)); // More aggressive spawn rate reduction
if (spawnTimer >= adjustedSpawnRate / gameSpeed) {
spawnEnemyCar();
spawnTimer = 0;
// Multiple enemy spawning at higher difficulty
if (distanceTraveled > 5000 && Math.random() < 0.3) {
spawnEnemyCar(); // 30% chance for double spawn after 5000 distance
}
if (distanceTraveled > 10000 && Math.random() < 0.2) {
spawnEnemyCar(); // Additional spawn chance after 10000 distance
}
}
// Spawn power-ups with reduced frequency at higher difficulty
powerUpSpawnTimer++;
var powerUpInterval = Math.max(200, 300 + Math.floor(distanceTraveled / 200)); // Longer intervals as distance increases
if (powerUpSpawnTimer >= powerUpInterval / gameSpeed) {
spawnPowerUp();
powerUpSpawnTimer = 0;
}
// Spawn nitro with increased rarity at higher difficulty
nitroSpawnTimer++;
var nitroInterval = Math.max(400, 600 + Math.floor(distanceTraveled / 150)); // Much longer intervals as distance increases
if (nitroSpawnTimer >= nitroInterval / gameSpeed) {
spawnNitro();
nitroSpawnTimer = 0;
}
// Spawn cups with very rare frequency
cupSpawnTimer++;
var cupInterval = Math.max(800, 1200 + Math.floor(distanceTraveled / 100)); // Very long intervals
if (cupSpawnTimer >= cupInterval / gameSpeed) {
spawnCup();
cupSpawnTimer = 0;
}
// Check nitro effect end
if (nitroEffect && LK.ticks >= nitroEndTime) {
nitroEffect = false;
tween(playerCar, {
scaleX: 1,
scaleY: 1
}, {
duration: 300
});
}
// Spawn road lines
lineSpawnTimer++;
if (lineSpawnTimer >= 25) {
for (var lane = 0; lane < 4; lane++) {
var line = game.addChild(new RoadLine());
line.x = 624 + lane * 400;
line.y = -100;
line.speed = 8 * gameSpeed;
roadLines.push(line);
}
lineSpawnTimer = 0;
}
// Update and check enemy cars
for (var i = enemyCars.length - 1; i >= 0; i--) {
var enemy = enemyCars[i];
if (enemy.lastY === undefined) enemy.lastY = enemy.y;
// Remove off-screen enemies
if (enemy.lastY < 2800 && enemy.y >= 2800) {
enemy.destroy();
enemyCars.splice(i, 1);
continue;
}
// Check collision with player
if (enemy.intersects(playerCar)) {
if (hasShield) {
// Player has shield from cup - destroy enemy instead
hasShield = false;
LK.setScore(LK.getScore() + 200);
LK.getSound('collect').play();
LK.effects.flashScreen(0x00ff00, 300);
// Create explosion at enemy position
var explosion = game.addChild(new Explosion());
explosion.x = enemy.x;
explosion.y = enemy.y;
// Destroy the enemy
enemy.destroy();
enemyCars.splice(i, 1);
continue;
} else {
// Normal collision - game over
// Create explosion at collision point
var explosion = game.addChild(new Explosion());
explosion.x = playerCar.x;
explosion.y = playerCar.y;
// Make player car explode with tween effect
tween(playerCar, {
scaleX: 0,
scaleY: 0,
rotation: Math.PI * 2,
alpha: 0
}, {
duration: 500,
easing: tween.easeOut
});
// Update best score if needed
if (distanceTraveled > bestDistance) {
bestDistance = Math.floor(distanceTraveled);
bestScoreTxt.setText('Best: ' + bestDistance);
saveBestScore();
}
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// Check for near miss (score bonus)
var distanceFromPlayer = Math.abs(enemy.x - playerCar.x);
if (enemy.y > playerCar.y - 150 && enemy.y < playerCar.y + 150 && distanceFromPlayer < 200 && distanceFromPlayer > 150) {
if (!enemy.nearMissScored) {
LK.setScore(LK.getScore() + 10);
LK.getSound('dodge').play();
enemy.nearMissScored = true;
}
}
enemy.lastY = enemy.y;
}
// Update and check power-ups
for (var j = powerUps.length - 1; j >= 0; j--) {
var powerUp = powerUps[j];
// Remove off-screen power-ups
if (powerUp.y > 2800) {
powerUp.destroy();
powerUps.splice(j, 1);
continue;
}
// Check collection
if (powerUp.intersects(playerCar)) {
LK.setScore(LK.getScore() + 50);
LK.getSound('collect').play();
LK.effects.flashObject(powerUp, 0xffffff, 200);
// Add smooth scale-out effect before destroying
tween(powerUp, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
powerUp.destroy();
}
});
powerUps.splice(j, 1);
}
}
// Update and check nitros
for (var n = nitros.length - 1; n >= 0; n--) {
var nitro = nitros[n];
// Remove off-screen nitros
if (nitro.y > 2800) {
nitro.destroy();
nitros.splice(n, 1);
continue;
}
// Check collection
if (nitro.intersects(playerCar)) {
LK.setScore(LK.getScore() + 100);
LK.getSound('collect').play();
// Activate nitro effect
nitroEffect = true;
nitroEndTime = LK.ticks + 300; // 5 seconds at 60fps
tween(playerCar, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 300
});
LK.effects.flashScreen(0x00ff00, 500);
// Add smooth scale-out effect for nitro
tween(nitro, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 400,
easing: tween.elasticOut,
onFinish: function onFinish() {
nitro.destroy();
}
});
nitros.splice(n, 1);
}
}
// Update and check cups
for (var c = cups.length - 1; c >= 0; c--) {
var cup = cups[c];
// Remove off-screen cups
if (cup.y > 2800) {
cup.destroy();
cups.splice(c, 1);
continue;
}
// Check collection
if (cup.intersects(playerCar)) {
hasShield = true;
LK.setScore(LK.getScore() + 150);
LK.getSound('collect').play();
LK.effects.flashScreen(0xFFD700, 400);
// Visual feedback for shield activation
tween(playerCar, {
tint: 0xFFD700
}, {
duration: 200,
onFinish: function onFinish() {
tween(playerCar, {
tint: 0xFFFFFF
}, {
duration: 200
});
}
});
// Add smooth scale-out effect for cup
tween(cup, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 300,
easing: tween.elasticOut,
onFinish: function onFinish() {
cup.destroy();
}
});
cups.splice(c, 1);
}
}
// Update road lines
for (var k = roadLines.length - 1; k >= 0; k--) {
var line = roadLines[k];
// Remove off-screen lines
if (line.y > 2800) {
line.destroy();
roadLines.splice(k, 1);
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -212,8 +212,57 @@
}
};
return self;
});
+var PlayerCar3 = Container.expand(function () {
+ var self = Container.call(this);
+ var carGraphics = self.attachAsset('enemyCar1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Make it visually distinct with tint
+ carGraphics.tint = 0x9932CC; // Purple color
+ self.targetLane = 1;
+ self.currentLane = 1;
+ self.laneWidth = 400;
+ self.moveSpeed = 0.38; // Faster lane switching speed
+ self.update = function () {
+ var targetX = self.getLaneX(self.targetLane);
+ var diff = targetX - self.x;
+ var adjustedMoveSpeed = self.moveSpeed * (1 + (gameSpeed - 1) * 0.5);
+ if (Math.abs(diff) > 5) {
+ self.x += diff * adjustedMoveSpeed;
+ } else {
+ self.x = targetX;
+ self.currentLane = self.targetLane;
+ }
+ };
+ self.getLaneX = function (lane) {
+ return 424 + lane * self.laneWidth;
+ };
+ self.switchLane = function (direction) {
+ var newLane = self.targetLane + direction;
+ if (newLane >= 0 && newLane <= 3) {
+ self.targetLane = newLane;
+ // Add slow dramatic turn effect when switching lanes
+ tween(carGraphics, {
+ rotation: direction * 0.3
+ }, {
+ duration: 750,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(carGraphics, {
+ rotation: 0
+ }, {
+ duration: 550,
+ easing: tween.easeIn
+ });
+ }
+ });
+ }
+ };
+ return self;
+});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
@@ -445,9 +494,9 @@
// Car selection buttons at bottom
var car1Button = LK.getAsset('playerCar', {
anchorX: 0.5,
anchorY: 0.5,
- x: 824,
+ x: 624,
y: 1650,
scaleX: 0.8,
scaleY: 0.8
});
@@ -455,41 +504,61 @@
menuElements.push(car1Button);
var car2Button = LK.getAsset('playerCar2', {
anchorX: 0.5,
anchorY: 0.5,
- x: 1224,
+ x: 1024,
y: 1650,
scaleX: 0.8,
scaleY: 0.8
});
game.addChild(car2Button);
menuElements.push(car2Button);
+ var car3Button = LK.getAsset('enemyCar1', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1424,
+ y: 1650,
+ scaleX: 0.8,
+ scaleY: 0.8
+ });
+ car3Button.tint = 0x9932CC; // Purple color to match PlayerCar3
+ game.addChild(car3Button);
+ menuElements.push(car3Button);
// Car selection labels
var car1Label = new Text2('CAR 1', {
size: 48,
fill: '#FFFFFF'
});
car1Label.anchor.set(0.5, 0.5);
- car1Label.x = 824;
+ car1Label.x = 624;
car1Label.y = 1600;
game.addChild(car1Label);
menuElements.push(car1Label);
var car2Label = new Text2('CAR 2', {
size: 48,
fill: '#FFFFFF'
});
car2Label.anchor.set(0.5, 0.5);
- car2Label.x = 1224;
+ car2Label.x = 1024;
car2Label.y = 1600;
game.addChild(car2Label);
menuElements.push(car2Label);
+ var car3Label = new Text2('CAR 3', {
+ size: 48,
+ fill: '#FFFFFF'
+ });
+ car3Label.anchor.set(0.5, 0.5);
+ car3Label.x = 1424;
+ car3Label.y = 1600;
+ game.addChild(car3Label);
+ menuElements.push(car3Label);
// Selection indicator
selectionIndicator = LK.getAsset('roadLine', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 0.5,
- x: selectedCarType === 0 ? 824 : 1224,
+ x: selectedCarType === 0 ? 624 : selectedCarType === 1 ? 1024 : 1424,
y: 1720
});
selectionIndicator.tint = 0xFFD700;
game.addChild(selectionIndicator);
@@ -510,8 +579,15 @@
duration: 2200,
yoyo: true,
repeat: -1
});
+ tween(car3Button, {
+ y: 1670
+ }, {
+ duration: 2400,
+ yoyo: true,
+ repeat: -1
+ });
// Animate title shadow
tween(titleShadow, {
scaleX: 1.15,
scaleY: 1.15
@@ -594,24 +670,26 @@
loadBestScore();
// Create start menu on game load
createStartMenu();
// Car selection variable
-var selectedCarType = 0; // 0 for PlayerCar, 1 for PlayerCar2
+var selectedCarType = 0; // 0 for PlayerCar, 1 for PlayerCar2, 2 for PlayerCar3
var playerCar;
var selectionIndicator;
// Update car selection visual state
function updateCarSelection() {
if (selectionIndicator) {
- selectionIndicator.x = selectedCarType === 0 ? 824 : 1224;
+ selectionIndicator.x = selectedCarType === 0 ? 624 : selectedCarType === 1 ? 1024 : 1424;
}
// Update car button tints if they exist
if (menuElements.length > 0) {
for (var i = 0; i < menuElements.length; i++) {
var element = menuElements[i];
- if (element.x === 824 && element.y === 1650) {
+ if (element.x === 624 && element.y === 1650) {
element.tint = selectedCarType === 0 ? 0xFFD700 : 0xFFFFFF;
- } else if (element.x === 1224 && element.y === 1650) {
+ } else if (element.x === 1024 && element.y === 1650) {
element.tint = selectedCarType === 1 ? 0xFFD700 : 0xFFFFFF;
+ } else if (element.x === 1424 && element.y === 1650) {
+ element.tint = selectedCarType === 2 ? 0xFFD700 : element.tint === 0x9932CC ? 0x9932CC : 0xFFFFFF;
}
}
}
}
@@ -621,10 +699,12 @@
playerCar.destroy();
}
if (selectedCarType === 0) {
playerCar = game.addChild(new PlayerCar());
- } else {
+ } else if (selectedCarType === 1) {
playerCar = game.addChild(new PlayerCar2());
+ } else {
+ playerCar = game.addChild(new PlayerCar3());
}
playerCar.x = 424 + 400; // Lane 1
playerCar.y = 2200;
}
@@ -683,20 +763,26 @@
game.down = function (x, y, obj) {
if (gameState === 'menu') {
// Check car selection buttons
if (y >= 1550 && y <= 1750) {
- if (x >= 724 && x <= 924) {
+ if (x >= 524 && x <= 724) {
// Car 1 selected
selectedCarType = 0;
updateCarSelection();
initializePlayerCar();
return;
- } else if (x >= 1124 && x <= 1324) {
+ } else if (x >= 924 && x <= 1124) {
// Car 2 selected
selectedCarType = 1;
updateCarSelection();
initializePlayerCar();
return;
+ } else if (x >= 1324 && x <= 1524) {
+ // Car 3 selected
+ selectedCarType = 2;
+ updateCarSelection();
+ initializePlayerCar();
+ return;
}
}
// Any other touch on menu starts the game
startGame();
pixel art ferrari bird's eye view. In-Game asset. 2d. High contrast. No shadows
pixel art tofaş bird's eye view. In-Game asset. 2d. High contrast. No shadows
pixel art Togg bird's eye view. In-Game asset. 2d. High contrast. No shadows
pixel art gas pedal bird's eye view. In-Game asset. 2d. High contrast. No shadows
pixel art nitro. In-Game asset. 2d. High contrast. No shadows
pixel art fantasy car bird's eye view. In-Game asset. 2d. High contrast. No shadows
pixel art straight line,. In-Game asset. 2d. High contrast. No shadows
Gold and Glory pixel art cup. In-Game asset. 2d. High contrast. No shadows
bugatti bolide pixel art bird's eye view. In-Game asset. 2d. High contrast. No shadows
BMW X6 pixel art bird's eye view. In-Game asset. 2d. High contrast. No shadows
pixel art joker. In-Game asset. 2d. High contrast. No shadows
düz sarı çizgi. In-Game asset. 2d. High contrast. No shadows
pixel art peter parker. In-Game asset. 2d. High contrast. No shadows
bird's eye pixel art motorcycle suzuki. In-Game asset. 2d. High contrast. No shadows