User prompt
Coinlerin çıkma oranını 20% arttır
User prompt
Barı fix le ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bar aşağıda olsun ve 40% oranında büyüt ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
İksirlerin etki süresini hösteren bir bar ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yavaşlatıcı iksir ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
İksirin çıkma oranını 20% arttır
User prompt
İksirin çıkma oranını 10% arttır
User prompt
İksirin çıkma oranını 30% düşür
User prompt
Araba hızını arttıran enerji iksiri ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Engel sayını 40% oranında arrdır
User prompt
Oyun sonu skorunu 10k ya yükselt
User prompt
Skor tablosundakı rakamla oyun bitince gelen şablondakı rakam aynı olsun
User prompt
Kalpları 70% oranında büyüt
User prompt
Can sistemine rakam yerinr kalp ekle
User prompt
Can şablonu sağ üstde olsun
User prompt
Can sistemi ekle 3 hakkın olsun
User prompt
Her corin topladıkda skor +50 artsın
User prompt
Biraz daha yukarı
User prompt
Birazcık daha yukarı
User prompt
Player arabası biraz daha yukarıda olsun
User prompt
Oyun sonu skorunu 5000 e yükselt
User prompt
Oyun sonu skorunu 1000 indir
User prompt
Arka planı orman olarak değiştir
User prompt
Bir engele çarptıkda patlama ses effekti ekle
User prompt
Oyun sonu skorununu 10000 e yükselt
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var CenterLine = Container.expand(function () {
var self = Container.call(this);
var centerGraphics = self.attachAsset('centerLine', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.y += self.speed;
// Add slight rotation for visual effect
coinGraphics.rotation += 0.1;
};
return self;
});
var ExplosionEffect = Container.expand(function () {
var self = Container.call(this);
var explosionParts = [];
// Create main explosion circle
var mainExplosion = self.attachAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5
});
explosionParts.push(mainExplosion);
// Create spark particles around the explosion
for (var i = 0; i < 8; i++) {
var spark = self.attachAsset('explosionSpark', {
anchorX: 0.5,
anchorY: 0.5
});
var angle = i / 8 * Math.PI * 2;
spark.x = Math.cos(angle) * 30;
spark.y = Math.sin(angle) * 30;
explosionParts.push(spark);
}
self.startExplosion = function () {
// Animate main explosion - scale up and fade out
tween(mainExplosion, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut
});
// Animate sparks - fly outward and fade
for (var i = 1; i < explosionParts.length; i++) {
var spark = explosionParts[i];
var angle = (i - 1) / 8 * Math.PI * 2;
var targetX = Math.cos(angle) * 120;
var targetY = Math.sin(angle) * 120;
tween(spark, {
x: targetX,
y: targetY,
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 600,
easing: tween.easeOut
});
}
// Remove explosion after animation
LK.setTimeout(function () {
self.destroy();
}, 900);
};
return self;
});
var ObstacleCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('obstacleCar', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.y += self.speed;
};
return self;
});
var PlayerCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('playerCar', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Keep car within road bounds
if (self.x < 100) {
self.x = 100;
}
if (self.x > 1948) {
self.x = 1948;
}
};
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.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228b22
});
/****
* Game Code
****/
// Game variables
var playerCar;
var obstacles = [];
var coins = [];
var roadLines = [];
var laneDividers = [];
var centerLines = [];
var explosions = [];
var gameSpeed = 20;
var spawnTimer = 0;
var coinSpawnTimer = 0;
var roadLineSpawnTimer = 0;
var laneDividerSpawnTimer = 0;
var centerLineSpawnTimer = 0;
var distanceScore = 0;
var coinScore = 0;
var coinCount = 0;
var dragNode = null;
var gameStarted = false;
var lives = 3;
// Create forest background with multiple tiles for seamless scrolling
var forestBackgrounds = [];
for (var i = 0; i < 4; i++) {
var forestBg = game.addChild(LK.getAsset('forest', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: i * 400 - 200
}));
forestBackgrounds.push(forestBg);
}
// Add trees on the sides for forest atmosphere
var trees = [];
for (var i = 0; i < 8; i++) {
// Left side trees
var leftTree = game.addChild(LK.getAsset('tree', {
anchorX: 0.5,
anchorY: 1,
x: 200,
y: i * 350 - 100
}));
var leftTreeTop = game.addChild(LK.getAsset('treeTop', {
anchorX: 0.5,
anchorY: 1,
x: 200,
y: i * 350 - 140
}));
trees.push(leftTree);
trees.push(leftTreeTop);
// Right side trees
var rightTree = game.addChild(LK.getAsset('tree', {
anchorX: 0.5,
anchorY: 1,
x: 1848,
y: i * 350 - 100
}));
var rightTreeTop = game.addChild(LK.getAsset('treeTop', {
anchorX: 0.5,
anchorY: 1,
x: 1848,
y: i * 350 - 140
}));
trees.push(rightTree);
trees.push(rightTreeTop);
}
// Create player car
playerCar = game.addChild(new PlayerCar());
playerCar.x = 1024;
playerCar.y = 2000;
// Create UI elements
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var coinCountText = new Text2('Coins: 0', {
size: 40,
fill: 0xFFD700
});
coinCountText.anchor.set(0, 0);
coinCountText.x = 150;
coinCountText.y = 100;
LK.gui.topLeft.addChild(coinCountText);
var remainingText = new Text2('Remaining: 5000m', {
size: 40,
fill: 0x00FF00
});
remainingText.anchor.set(0, 0);
remainingText.x = 150;
remainingText.y = 150;
LK.gui.topLeft.addChild(remainingText);
var livesText = new Text2('Lives: 3', {
size: 40,
fill: 0xFF0000
});
livesText.anchor.set(0, 0);
livesText.x = 150;
livesText.y = 200;
LK.gui.topLeft.addChild(livesText);
// Touch controls
function handleMove(x, y, obj) {
if (dragNode && gameStarted) {
// Constrain car to road bounds (between 324 and 1724)
var roadLeftBound = 324;
var roadRightBound = 1724;
if (x < roadLeftBound) {
playerCar.x = roadLeftBound;
} else if (x > roadRightBound) {
playerCar.x = roadRightBound;
} else {
playerCar.x = x;
}
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
LK.stopMusic();
LK.playMusic('bgMusic');
}
dragNode = playerCar;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Spawn functions
function spawnObstacle() {
var obstacle = new ObstacleCar();
obstacle.x = Math.random() * 1400 + 324; // Random X position within safe road bounds (324 to 1724)
obstacle.y = -100;
obstacle.speed = gameSpeed;
obstacles.push(obstacle);
game.addChild(obstacle);
}
function spawnCoin() {
var coin = new Coin();
var attempts = 0;
var maxAttempts = 10;
var validPosition = false;
var minDistance = 200; // Minimum distance between coins and obstacles
var coinX,
coinY = -100;
// Try to find a valid position away from obstacles
while (!validPosition && attempts < maxAttempts) {
coinX = Math.random() * 1400 + 324; // Random X position within safe road bounds (324 to 1724)
validPosition = true;
// Check distance from all existing obstacles
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
// Only check obstacles that are close vertically (within spawn range)
if (obstacle.y > -500 && obstacle.y < 500) {
var distance = Math.sqrt(Math.pow(coinX - obstacle.x, 2) + Math.pow(coinY - obstacle.y, 2));
if (distance < minDistance) {
validPosition = false;
break;
}
}
}
attempts++;
}
coin.x = coinX;
coin.y = coinY;
coin.speed = gameSpeed;
coins.push(coin);
game.addChild(coin);
}
function spawnRoadLine() {
var roadLine = new RoadLine();
roadLine.x = 1024;
roadLine.y = -100;
roadLine.speed = gameSpeed;
roadLines.push(roadLine);
game.addChild(roadLine);
}
function spawnLaneDivider() {
// Create lane dividers for left and right lanes
var leftDivider = game.addChild(LK.getAsset('laneDivider', {
anchorX: 0.5,
anchorY: 0.5,
x: 700,
y: -100
}));
leftDivider.speed = gameSpeed;
laneDividers.push(leftDivider);
var rightDivider = game.addChild(LK.getAsset('laneDivider', {
anchorX: 0.5,
anchorY: 0.5,
x: 1348,
y: -100
}));
rightDivider.speed = gameSpeed;
laneDividers.push(rightDivider);
}
function spawnCenterLine() {
var centerLine = new CenterLine();
centerLine.x = 1024;
centerLine.y = -100;
centerLine.speed = gameSpeed;
centerLines.push(centerLine);
game.addChild(centerLine);
}
// Main game loop
game.update = function () {
if (!gameStarted) {
return;
}
// Update distance score at a slower rate
distanceScore += gameSpeed / 60;
// Increase game speed gradually with acceleration
if (LK.ticks % 300 === 0) {
// Accelerate faster as time goes on
var acceleration = 0.5 + distanceScore / 1000 * 0.2;
gameSpeed += acceleration;
}
// Spawn obstacles more frequently as speed increases
spawnTimer++;
var obstacleSpawnRate = Math.max(26, 78 - gameSpeed * 3.9);
if (spawnTimer > obstacleSpawnRate) {
spawnObstacle();
spawnTimer = 0;
}
// Spawn coins
coinSpawnTimer++;
if (coinSpawnTimer > 120) {
spawnCoin();
coinSpawnTimer = 0;
}
// Spawn road lines
roadLineSpawnTimer++;
if (roadLineSpawnTimer > 40) {
spawnRoadLine();
roadLineSpawnTimer = 0;
}
// Spawn lane dividers more frequently as speed increases
laneDividerSpawnTimer++;
var laneDividerSpawnRate = Math.max(15, 30 - gameSpeed * 1.5);
if (laneDividerSpawnTimer > laneDividerSpawnRate) {
spawnLaneDivider();
laneDividerSpawnTimer = 0;
}
// Spawn center lines more frequently as speed increases
centerLineSpawnTimer++;
var centerLineSpawnRate = Math.max(12, 25 - gameSpeed * 1.2);
if (centerLineSpawnTimer > centerLineSpawnRate) {
spawnCenterLine();
centerLineSpawnTimer = 0;
}
// Update and check obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
if (obstacle.lastY === undefined) {
obstacle.lastY = obstacle.y;
}
// Remove off-screen obstacles
if (obstacle.lastY < 2800 && obstacle.y >= 2800) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Check collision with player
if (obstacle.intersects(playerCar)) {
// Create explosion effect at collision point
var explosion = new ExplosionEffect();
explosion.x = playerCar.x;
explosion.y = playerCar.y;
explosions.push(explosion);
game.addChild(explosion);
explosion.startExplosion();
LK.getSound('crash').play();
LK.effects.flashScreen(0xff0000, 1000);
// Decrease lives
lives--;
livesText.setText('Lives: ' + lives);
// Remove the obstacle that caused collision
obstacle.destroy();
obstacles.splice(i, 1);
// Check if game over
if (lives <= 0) {
LK.showGameOver();
return;
}
continue;
}
obstacle.lastY = obstacle.y;
}
// Update and check coins
for (var j = coins.length - 1; j >= 0; j--) {
var coin = coins[j];
if (coin.lastY === undefined) {
coin.lastY = coin.y;
}
if (coin.lastCollected === undefined) {
coin.lastCollected = false;
}
// Remove off-screen coins
if (coin.lastY < 2800 && coin.y >= 2800) {
coin.destroy();
coins.splice(j, 1);
continue;
}
// Check collection
var currentCollected = coin.intersects(playerCar);
if (!coin.lastCollected && currentCollected) {
LK.getSound('collectCoin').play();
coinCount += 1;
coinScore += 50;
LK.setScore(Math.floor(distanceScore) + coinScore);
coin.destroy();
coins.splice(j, 1);
continue;
}
coin.lastY = coin.y;
coin.lastCollected = currentCollected;
}
// Update and remove road lines
for (var k = roadLines.length - 1; k >= 0; k--) {
var roadLine = roadLines[k];
if (roadLine.lastY === undefined) {
roadLine.lastY = roadLine.y;
}
if (roadLine.lastY < 2800 && roadLine.y >= 2800) {
roadLine.destroy();
roadLines.splice(k, 1);
continue;
}
roadLine.lastY = roadLine.y;
}
// Update and remove lane dividers
for (var d = laneDividers.length - 1; d >= 0; d--) {
var divider = laneDividers[d];
if (divider.lastY === undefined) {
divider.lastY = divider.y;
}
divider.y += divider.speed;
if (divider.lastY < 2800 && divider.y >= 2800) {
divider.destroy();
laneDividers.splice(d, 1);
continue;
}
divider.lastY = divider.y;
}
// Update and remove center lines
for (var c = centerLines.length - 1; c >= 0; c--) {
var centerLine = centerLines[c];
if (centerLine.lastY === undefined) {
centerLine.lastY = centerLine.y;
}
if (centerLine.lastY < 2800 && centerLine.y >= 2800) {
centerLine.destroy();
centerLines.splice(c, 1);
continue;
}
centerLine.lastY = centerLine.y;
}
// Check win condition
var totalScore = Math.floor(distanceScore) + coinScore;
if (totalScore >= 5000) {
LK.showYouWin();
return;
}
// Update UI
scoreText.setText('Score: ' + totalScore);
var remainingDistance = Math.max(0, 5000 - totalScore);
remainingText.setText('Remaining: ' + remainingDistance + 'm');
coinCountText.setText('Coins: ' + coinCount);
// Scroll forest backgrounds for realistic movement
for (var bg = 0; bg < forestBackgrounds.length; bg++) {
forestBackgrounds[bg].y += gameSpeed;
// Reset position when tile moves off screen
if (forestBackgrounds[bg].y > 2932) {
forestBackgrounds[bg].y = forestBackgrounds[bg].y - 4 * 400;
}
}
// Scroll trees for realistic movement
for (var t = 0; t < trees.length; t++) {
trees[t].y += gameSpeed;
// Reset position when tree moves off screen
if (trees[t].y > 2932) {
trees[t].y = trees[t].y - 8 * 350;
}
}
// Update speeds for all moving objects
for (var l = 0; l < obstacles.length; l++) {
obstacles[l].speed = gameSpeed;
}
for (var m = 0; m < coins.length; m++) {
coins[m].speed = gameSpeed;
}
for (var n = 0; n < roadLines.length; n++) {
roadLines[n].speed = gameSpeed;
}
for (var d = 0; d < laneDividers.length; d++) {
laneDividers[d].speed = gameSpeed;
}
for (var cl = 0; cl < centerLines.length; cl++) {
centerLines[cl].speed = gameSpeed;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -156,8 +156,9 @@
var coinScore = 0;
var coinCount = 0;
var dragNode = null;
var gameStarted = false;
+var lives = 3;
// Create forest background with multiple tiles for seamless scrolling
var forestBackgrounds = [];
for (var i = 0; i < 4; i++) {
var forestBg = game.addChild(LK.getAsset('forest', {
@@ -228,8 +229,16 @@
remainingText.anchor.set(0, 0);
remainingText.x = 150;
remainingText.y = 150;
LK.gui.topLeft.addChild(remainingText);
+var livesText = new Text2('Lives: 3', {
+ size: 40,
+ fill: 0xFF0000
+});
+livesText.anchor.set(0, 0);
+livesText.x = 150;
+livesText.y = 200;
+LK.gui.topLeft.addChild(livesText);
// Touch controls
function handleMove(x, y, obj) {
if (dragNode && gameStarted) {
// Constrain car to road bounds (between 324 and 1724)
@@ -401,10 +410,20 @@
game.addChild(explosion);
explosion.startExplosion();
LK.getSound('crash').play();
LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- return;
+ // Decrease lives
+ lives--;
+ livesText.setText('Lives: ' + lives);
+ // Remove the obstacle that caused collision
+ obstacle.destroy();
+ obstacles.splice(i, 1);
+ // Check if game over
+ if (lives <= 0) {
+ LK.showGameOver();
+ return;
+ }
+ continue;
}
obstacle.lastY = obstacle.y;
}
// Update and check coins
Ford mustang. High contrast. No shadows
Gold coins. In-Game asset. 2d. High contrast. No shadows
Minecraf hardcore heart. In-Game asset. 2d. High contrast. No shadows
Arkadan fotoğraflı araba. In-Game asset. 2d. High contrast. No shadows
İksir. In-Game asset. 2d. High contrast. No shadows
Atom bomb. In-Game asset. 2d. High contrast. No shadows