User prompt
powerup assests leri poweruplara entegre et
User prompt
add powerups assests
User prompt
2 adet powerup ekle
User prompt
enemy car 5 kaldır
User prompt
araç çeşitliliğini arttır
User prompt
sen beni yanlış anlamıssın bütün araçlar hızlanıcaz
User prompt
her 50 puanda çok daha hızlansın
User prompt
her hız arttığında gaz sesi gelsin
User prompt
her 50 puanda aracın hızını biraz arttır
User prompt
tam tersi yap
User prompt
orta şeritte gidebilmeyi orta şeride tıklayarak değil sağa yada sola giderken arada durmak şeklinde yap
User prompt
yeni bir araç oluşum şeması yap
User prompt
Create a top-down car dodging game for mobile. The road has two lanes visually, but cars can spawn in three positions: left, center, and right. In each spawn cycle, randomly spawn 1 or 2 cars in different lanes, but always leave at least one lane empty so the player can pass through. Cars move downward at a constant speed. The player controls a car that can switch between the three lanes by swiping left or right. If the player hits a car, the game is over
User prompt
oyuncunun orta şeritte gitmesine izin ver
User prompt
orta şeritte sürebilme ekle
User prompt
oyuncunun geçebileceği yerler olsun
User prompt
orta şeritte sürebilme ekle
User prompt
araçların oluşum şemasını geliştir farklı oluşumlar ekle
Code edit (1 edits merged)
Please save this source code
User prompt
arkada kalan yol hemen kaybolmasın
User prompt
yol bağlantılı olsun
User prompt
bağlantılı olsun
User prompt
yol hareket etsin
Code edit (4 edits merged)
Please save this source code
User prompt
remove unnecessary codes
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { level: 1, bestTime: 0 }); /**** * Classes ****/ var Car = Container.expand(function () { var self = Container.call(this); var carGraphics = self.attachAsset('playerCar', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.update = function () { // Player car does not move forward automatically anymore // Only horizontal movement is allowed, so no change to self.y here if (self.x < 0) { self.x = 2048; } else if (self.x > 2048) { self.x = 0; } }; return self; }); var EnemyCar = Container.expand(function () { var self = Container.call(this); var enemyCarGraphics = self.attachAsset('enemyCar', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.update = function () { // Enemy cars move down the screen (already correct) self.y += self.speed; if (self.x < 0) { self.x = 2048; } else if (self.x > 2048) { self.x = 0; } }; return self; }); var Smoke = Container.expand(function () { var self = Container.call(this); var smokeGraphics = self.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); // Initialize with random properties for varied effect self.speedX = (Math.random() - 0.5) * 2; // Random horizontal drift self.speedY = 1 + Math.random() * 2; // Move backward speed self.initialDistance = 0; // Track distance traveled self.maxAlpha = 0.8 + Math.random() * 0.2; // Maximum density at start self.alpha = self.maxAlpha; // Start with maximum opacity self.fadingDistance = 40 + Math.random() * 40; // Distance at which smoke starts to fade self.growSpeed = 0.03 + Math.random() * 0.03; // Expansion rate // Update smoke particle behavior self.update = function () { self.x += self.speedX; self.y += self.speedY; // Move downward (backward from car perspective) // Update distance traveled self.initialDistance += self.speedY; // Start dense and become less dense as it moves backward self.alpha = Math.max(0, self.maxAlpha * (1 - self.initialDistance / (self.fadingDistance * 2))); self.scale.x += self.growSpeed; self.scale.y += self.growSpeed; // Remove smoke when it becomes too transparent if (self.alpha <= 0) { self.destroy(); return true; // Signal that this smoke has been destroyed } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Create score text var score = 0; var scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); // Add smoke effects var smokeParticles = []; function createSmoke(x, y, amount) { for (var i = 0; i < amount; i++) { var smoke = new Smoke(); // Alternate between left and right sides of the car var side = i % 2 === 0 ? -1 : 1; // Position smoke on the left or right side of the car smoke.x = x + side * 100 + (Math.random() - 0.5) * 20; // Offset from car sides smoke.y = y + 200; // Position behind car (below car in screen coordinates) smokeParticles.push(smoke); game.addChild(smoke); } } scoreTxt.anchor.set(0.5, 0); scoreTxt.alpha = 0; LK.gui.top.addChild(scoreTxt); tween(scoreTxt, { alpha: 1 }, 800, { easing: "easeOutCubic" }); var road = LK.getAsset('road', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); road.alpha = 0; road.scale.set(1.05, 1.05); game.addChild(road); // Create a second road image for seamless looping var road2 = LK.getAsset('road', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 - 2732 // Place directly above the first road }); road2.alpha = 0; road2.scale.set(1.05, 1.05); game.addChild(road2); tween(road, { alpha: 1 }, 1000, { easing: "easeOutCubic" }); tween(road2, { alpha: 1 }, 1000, { easing: "easeOutCubic" }); tween(road.scale, { x: 1, y: 1 }, 900, { easing: "easeOutCubic" }); tween(road2.scale, { x: 1, y: 1 }, 900, { easing: "easeOutCubic" }); // Add road movement variables var roadScrollSpeed = 16; var roadInitialY = 2366; var roadImageHeight = 2732; // Play background music with fade in LK.playMusic('bgmusic', { fade: { start: 0, end: 0.8, duration: 1000 } }); // Display high score var highScore = storage.highScore || 0; var highScoreTxt = new Text2('High Score: ' + highScore, { size: 80, fill: 0x00a000, // Lighter green color fontWeight: 'bold' // Make the text bold }); highScoreTxt.anchor.set(0.5, 0); highScoreTxt.y = 120; highScoreTxt.alpha = 0; LK.gui.top.addChild(highScoreTxt); tween(highScoreTxt, { alpha: 1 }, 1000, { easing: "easeOutCubic" }); var playerCar = game.addChild(new Car()); // Place player in left, center, or right lane randomly var laneXs = [512, 1024, 1536]; // 512 = left, 1024 = center, 1536 = right playerCar.x = laneXs[Math.floor(Math.random() * laneXs.length)]; playerCar.y = 2300; // Start near the bottom, adjusted for bigger car // Fade in the player car for a polished entrance playerCar.alpha = 0; playerCar.scale.set(1.2, 1.2); tween(playerCar, { alpha: 1 }, 600, { easing: "easeOutCubic" }); tween(playerCar.scale, { x: 1, y: 1 }, 400, { easing: "easeOutBack" }); var enemyCars = []; function spawnEnemyCar() { // Allow enemy cars to spawn in left, center, or right lane var laneXs = [512, 1024, 1536]; // Car height for vertical gap - increased multiplier for more space var carHeight = 660; var verticalGapMultiplier = 3.5; // Find the highest Y of any existing enemy car, or use -330 if none var topY = -330; for (var i = 0; i < enemyCars.length; i++) { if (enemyCars[i].y < topY) { topY = enemyCars[i].y; } } // Patterns: single, double, triple, and zigzag formations for more variety (including center lane) var patterns = [ // Only left lane [{ x: laneXs[0] }], // Only center lane [{ x: laneXs[1] }], // Only right lane [{ x: laneXs[2] }], // Double: left and center [{ x: laneXs[0] }, { x: laneXs[1], yOffset: 330 }], // Double: center and right [{ x: laneXs[1] }, { x: laneXs[2], yOffset: 330 }], // Double: left and right [{ x: laneXs[0] }, { x: laneXs[2], yOffset: 330 }], // Triple: left, center, right (with vertical gaps) [{ x: laneXs[0] }, { x: laneXs[1], yOffset: 330 }, { x: laneXs[2], yOffset: 660 }], // Zigzag: left, center, right (with vertical gaps) [{ x: laneXs[0] }, { x: laneXs[1], yOffset: 330 }, { x: laneXs[2], yOffset: 660 }], // Zigzag: right, center, left (with vertical gaps) [{ x: laneXs[2] }, { x: laneXs[1], yOffset: 330 }, { x: laneXs[0], yOffset: 660 }]]; // Keep track of which pattern to use next if (typeof spawnEnemyCar.patternIndex === "undefined") { spawnEnemyCar.patternIndex = 0; } // Shuffle patterns order every cycle for variety if (typeof spawnEnemyCar.patternOrder === "undefined" || spawnEnemyCar.patternOrder.length === 0) { var order = []; for (var i = 0; i < patterns.length; i++) { order.push(i); } // Fisher-Yates shuffle for (var i = order.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = order[i]; order[i] = order[j]; order[j] = temp; } spawnEnemyCar.patternOrder = order; spawnEnemyCar.patternIndex = 0; } var patternIdx = spawnEnemyCar.patternOrder[spawnEnemyCar.patternIndex]; var pattern = patterns[patternIdx]; spawnEnemyCar.patternIndex++; if (spawnEnemyCar.patternIndex >= spawnEnemyCar.patternOrder.length) { spawnEnemyCar.patternOrder = []; } // Place new pattern below the last one, with the specified gap and support yOffset for formations var spawnY = topY; for (var i = 0; i < pattern.length; i++) { var carDef = pattern[i]; var enemyCar = new EnemyCar(); enemyCar.x = carDef.x; // If yOffset is defined, add it to spawnY for this car enemyCar.y = spawnY - (carDef.yOffset || 0); enemyCars.push(enemyCar); game.addChild(enemyCar); } // Always space the next pattern below the last car in the pattern spawnY -= carHeight * verticalGapMultiplier; } game.update = function () { // Move both road images downward to simulate motion road.y += roadScrollSpeed; road2.y += roadScrollSpeed; // If a road image moves off the bottom, move it above the other for seamless looping if (road.y > roadInitialY + roadImageHeight / 2) { road.y = road2.y - roadImageHeight; } if (road2.y > roadInitialY + roadImageHeight / 2) { road2.y = road.y - roadImageHeight; } // No gradual movement needed; handled instantly in game.down // Only update playerCar for horizontal movement, not forward movement playerCar.update(); // Create smoke particles behind player car if (LK.ticks % 5 == 0) { createSmoke(playerCar.x, playerCar.y, 2); } // Update and manage smoke particles for (var i = smokeParticles.length - 1; i >= 0; i--) { var isDestroyed = smokeParticles[i].update(); if (isDestroyed) { smokeParticles.splice(i, 1); } } var _loop = function _loop() { enemyCar = enemyCars[i]; // Track previous position for scoring if (enemyCar.lastY === undefined) { enemyCar.lastY = enemyCar.y; enemyCar.scored = false; } enemyCar.update(); // No smoke for enemy cars // Score when car passes the player if (!enemyCar.scored && enemyCar.lastY < playerCar.y && enemyCar.y >= playerCar.y) { score += 10; scoreTxt.setText('Score: ' + score); // Subtle pop animation for score text scoreTxt.scale.set(1.2, 1.2); tween(scoreTxt.scale, { x: 1, y: 1 }, 200, { easing: "easeOutBack" }); enemyCar.scored = true; } // Update last position enemyCar.lastY = enemyCar.y; if (enemyCar.y > 2832) { // If the enemy car goes off the screen enemyCar.destroy(); enemyCars.splice(i, 1); } if (playerCar.intersects(enemyCar)) { var _doShake = function doShake() { if (shakeIndex < shakeTimes) { playerCar.x = originalX + (shakeIndex % 2 === 0 ? shakeMagnitude : -shakeMagnitude); LK.setTimeout(function () { playerCar.x = originalX; shakeIndex++; _doShake(); }, shakeStep); } else { playerCar.x = originalX; // Update high score if needed if (score > highScore) { highScore = score; storage.highScore = highScore; highScoreTxt.setText('High Score: ' + highScore); // Subtle fade-in and pop effect for new high score highScoreTxt.alpha = 0.2; highScoreTxt.scale.set(1.3, 1.3); tween(highScoreTxt, { alpha: 1 }, 400, { easing: "easeOutCubic" }); tween(highScoreTxt.scale, { x: 1, y: 1 }, 300, { easing: "easeOutBack" }); } // Set the final score before game over LK.setScore(score); LK.showGameOver(); } }; // Subtle shake effect for player car originalX = playerCar.x; shakeTimes = 6; shakeMagnitude = 30; shakeDuration = 180; shakeStep = shakeDuration / shakeTimes; shakeIndex = 0; _doShake(); return { v: void 0 }; // Prevent double game over } }, enemyCar, originalX, shakeTimes, shakeMagnitude, shakeDuration, shakeStep, shakeIndex, _ret; for (var i = enemyCars.length - 1; i >= 0; i--) { _ret = _loop(); if (_ret) { return _ret.v; } } if (LK.ticks % 120 == 0) { // Spawn new enemy cars every 2 seconds to keep more space between them spawnEnemyCar(); } }; game.down = function (x, y, obj) { // Divide screen into three vertical regions for left, center, right if (x < 682) { playerCar.x = 512; // Left lane } else if (x < 1365) { playerCar.x = 1024; // Center lane } else { playerCar.x = 1536; // Right lane } }; game.up = function (x, y, obj) { // No action needed };
===================================================================
--- original.js
+++ change.js
@@ -190,10 +190,11 @@
}, 1000, {
easing: "easeOutCubic"
});
var playerCar = game.addChild(new Car());
-// Place player in left or right lane randomly, not center
-playerCar.x = Math.random() > 0.5 ? 512 : 1536; // 512 = left lane, 1536 = right lane
+// Place player in left, center, or right lane randomly
+var laneXs = [512, 1024, 1536]; // 512 = left, 1024 = center, 1536 = right
+playerCar.x = laneXs[Math.floor(Math.random() * laneXs.length)];
playerCar.y = 2300; // Start near the bottom, adjusted for bigger car
// Fade in the player car for a polished entrance
playerCar.alpha = 0;
playerCar.scale.set(1.2, 1.2);
@@ -209,11 +210,10 @@
easing: "easeOutBack"
});
var enemyCars = [];
function spawnEnemyCar() {
- // Only allow enemy cars to spawn in the same vertical lines as the player (left or right lane)
- // Lane Xs: left, right
- var laneXs = [512, 1536];
+ // Allow enemy cars to spawn in left, center, or right lane
+ var laneXs = [512, 1024, 1536];
// Car height for vertical gap - increased multiplier for more space
var carHeight = 660;
var verticalGapMultiplier = 3.5;
// Find the highest Y of any existing enemy car, or use -330 if none
@@ -222,50 +222,71 @@
if (enemyCars[i].y < topY) {
topY = enemyCars[i].y;
}
}
- // Patterns: single, double, and zigzag formations for more variety
+ // Patterns: single, double, triple, and zigzag formations for more variety (including center lane)
var patterns = [
// Only left lane
[{
x: laneXs[0]
}],
- // Only right lane
+ // Only center lane
[{
x: laneXs[1]
}],
- // Double: left then right (with vertical gap)
+ // Only right lane
[{
+ x: laneXs[2]
+ }],
+ // Double: left and center
+ [{
x: laneXs[0]
}, {
x: laneXs[1],
yOffset: 330
}],
- // Double: right then left (with vertical gap)
+ // Double: center and right
[{
x: laneXs[1]
}, {
- x: laneXs[0],
+ x: laneXs[2],
yOffset: 330
}],
- // Zigzag: left, right, left (with vertical gaps)
+ // Double: left and right
[{
x: laneXs[0]
}, {
+ x: laneXs[2],
+ yOffset: 330
+ }],
+ // Triple: left, center, right (with vertical gaps)
+ [{
+ x: laneXs[0]
+ }, {
x: laneXs[1],
yOffset: 330
}, {
- x: laneXs[0],
+ x: laneXs[2],
yOffset: 660
}],
- // Zigzag: right, left, right (with vertical gaps)
+ // Zigzag: left, center, right (with vertical gaps)
[{
- x: laneXs[1]
+ x: laneXs[0]
}, {
- x: laneXs[0],
+ x: laneXs[1],
yOffset: 330
}, {
+ x: laneXs[2],
+ yOffset: 660
+ }],
+ // Zigzag: right, center, left (with vertical gaps)
+ [{
+ x: laneXs[2]
+ }, {
x: laneXs[1],
+ yOffset: 330
+ }, {
+ x: laneXs[0],
yOffset: 660
}]];
// Keep track of which pattern to use next
if (typeof spawnEnemyCar.patternIndex === "undefined") {
@@ -429,12 +450,15 @@
spawnEnemyCar();
}
};
game.down = function (x, y, obj) {
- if (x < 1024) {
- playerCar.x = 512; // Instantly move to left lane
+ // Divide screen into three vertical regions for left, center, right
+ if (x < 682) {
+ playerCar.x = 512; // Left lane
+ } else if (x < 1365) {
+ playerCar.x = 1024; // Center lane
} else {
- playerCar.x = 1536; // Instantly move to right lane
+ playerCar.x = 1536; // Right lane
}
};
game.up = function (x, y, obj) {
// No action needed