User prompt
Hala çalışmıyor
User prompt
Kaza sesi çalışmıyor
User prompt
Çarpma sesi için varlık ekle
User prompt
Polis arabaları için bir oyun müzigi ekle
User prompt
Oyundaki polis arabalarına kırmızı ve mavi ışıklar ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Coin toplama sesi 7
User prompt
Yan kısımları yeşil renkli yap ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyunun yan taraflarında kalan yere ormanlık ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yol rengi degişmesin
User prompt
Yol rengini degiştirebilmem için varlık ekle
User prompt
3 şeritli bir yol ekle
User prompt
Zemin çizgisini sil
User prompt
Oyun varlıklarını büyült ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Endless Runner
Initial prompt
Sonsuz koşu
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = gameSpeed;
self.collected = false;
self.update = function () {
self.y += self.speed;
self.rotation += 0.1;
};
return self;
});
var LaneLine = Container.expand(function () {
var self = Container.call(this);
var lineGraphics = self.attachAsset('laneLine', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = gameSpeed;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0
});
self.speed = gameSpeed;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1.0
});
self.groundY = 2300;
self.jumpSpeed = 0;
self.isJumping = false;
self.gravity = 1.2;
self.jumpPower = -22;
self.lanes = [650, 1024, 1398]; // Three lanes
self.currentLane = 1; // Middle lane
self.targetX = self.lanes[self.currentLane];
self.x = self.targetX;
self.y = self.groundY;
self.jump = function () {
if (!self.isJumping) {
self.jumpSpeed = self.jumpPower;
self.isJumping = true;
LK.getSound('jump').play();
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
}
});
}
};
self.moveLeft = function () {
if (self.currentLane > 0) {
self.currentLane--;
self.targetX = self.lanes[self.currentLane];
}
};
self.moveRight = function () {
if (self.currentLane < 2) {
self.currentLane++;
self.targetX = self.lanes[self.currentLane];
}
};
self.update = function () {
// Handle jumping
if (self.isJumping) {
self.jumpSpeed += self.gravity;
self.y += self.jumpSpeed;
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpSpeed = 0;
}
}
// Handle lane switching
var dx = self.targetX - self.x;
if (Math.abs(dx) > 2) {
self.x += dx * 0.15;
} else {
self.x = self.targetX;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var player;
var obstacles = [];
var coins = [];
var laneLines = [];
var gameSpeed = 8;
var maxSpeed = 20;
var speedIncrement = 0.005;
var distance = 0;
var obstacleSpawnTimer = 0;
var coinSpawnTimer = 0;
var laneLineSpawnTimer = 0;
var lastSwipeX = 0;
var lastSwipeY = 0;
var swipeStarted = false;
// Create road background
var roadBackground = game.addChild(LK.getAsset('roadBackground', {
anchorX: 0.5,
anchorY: 0.5
}));
roadBackground.x = 1024; // Center of screen
roadBackground.y = 1366;
// Create road borders
var leftBorder = game.addChild(LK.getAsset('roadBorder', {
anchorX: 0.5,
anchorY: 0.5
}));
leftBorder.x = 476; // Left of leftmost lane
leftBorder.y = 1366;
var rightBorder = game.addChild(LK.getAsset('roadBorder', {
anchorX: 0.5,
anchorY: 0.5
}));
rightBorder.x = 1572; // Right of rightmost lane
rightBorder.y = 1366;
// Create player
player = game.addChild(new Player());
// Create score display
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Create distance display
var distanceText = new Text2('Distance: 0m', {
size: 50,
fill: 0xFFFFFF
});
distanceText.anchor.set(0, 0);
distanceText.x = 50;
distanceText.y = 120;
LK.gui.topLeft.addChild(distanceText);
// Touch controls
game.down = function (x, y, obj) {
lastSwipeX = x;
lastSwipeY = y;
swipeStarted = true;
};
game.up = function (x, y, obj) {
if (swipeStarted) {
var deltaX = x - lastSwipeX;
var deltaY = y - lastSwipeY;
var swipeThreshold = 100;
if (Math.abs(deltaX) > Math.abs(deltaY)) {
// Horizontal swipe
if (deltaX > swipeThreshold) {
player.moveRight();
} else if (deltaX < -swipeThreshold) {
player.moveLeft();
}
} else {
// Vertical swipe or tap
if (deltaY < -swipeThreshold || Math.abs(deltaX) < 50 && Math.abs(deltaY) < 50) {
player.jump();
}
}
}
swipeStarted = false;
};
function spawnObstacle() {
var obstacle = new Obstacle();
var laneIndex = Math.floor(Math.random() * 3);
obstacle.x = player.lanes[laneIndex];
obstacle.y = -100;
obstacle.speed = gameSpeed;
obstacle.scaleX = 0.7;
obstacle.scaleY = 0.7;
tween(obstacle, {
scaleX: 1,
scaleY: 1
}, {
duration: 400,
easing: tween.easeOut
});
obstacles.push(obstacle);
game.addChild(obstacle);
}
function spawnCoin() {
var coin = new Coin();
var laneIndex = Math.floor(Math.random() * 3);
coin.x = player.lanes[laneIndex];
coin.y = -50;
coin.speed = gameSpeed;
coin.scaleX = 0.5;
coin.scaleY = 0.5;
tween(coin, {
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.easeOut
});
coins.push(coin);
game.addChild(coin);
}
function spawnLaneLine() {
// Lane dividers between lanes
var positions = [837, 1211]; // Between lanes 0-1 and 1-2
for (var i = 0; i < positions.length; i++) {
var laneLine = new LaneLine();
laneLine.x = positions[i];
laneLine.y = -60;
laneLine.speed = gameSpeed;
laneLines.push(laneLine);
game.addChild(laneLine);
}
}
// Main game loop
game.update = function () {
// Increase game speed gradually
if (gameSpeed < maxSpeed) {
gameSpeed += speedIncrement;
}
// Update distance
distance += gameSpeed * 0.1;
distanceText.setText('Distance: ' + Math.floor(distance) + 'm');
// Spawn obstacles
obstacleSpawnTimer++;
if (obstacleSpawnTimer > 60 + Math.random() * 60) {
spawnObstacle();
obstacleSpawnTimer = 0;
}
// Spawn coins
coinSpawnTimer++;
if (coinSpawnTimer > 90 + Math.random() * 90) {
spawnCoin();
coinSpawnTimer = 0;
}
// Spawn lane lines
laneLineSpawnTimer++;
if (laneLineSpawnTimer > 30) {
spawnLaneLine();
laneLineSpawnTimer = 0;
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
obstacle.speed = gameSpeed;
// Remove obstacles that are off screen
if (obstacle.y > 2800) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Check collision with player
if (player.intersects(obstacle)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// Update coins
for (var j = coins.length - 1; j >= 0; j--) {
var coin = coins[j];
coin.speed = gameSpeed;
// Remove coins that are off screen
if (coin.y > 2800) {
coin.destroy();
coins.splice(j, 1);
continue;
}
// Check collection
if (!coin.collected && player.intersects(coin)) {
coin.collected = true;
LK.setScore(LK.getScore() + 10);
scoreText.setText('Score: ' + LK.getScore());
LK.getSound('collect').play();
// Visual effect
tween(coin, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
coin.destroy();
}
});
coins.splice(j, 1);
}
}
// Update lane lines
for (var k = laneLines.length - 1; k >= 0; k--) {
var laneLine = laneLines[k];
laneLine.speed = gameSpeed;
// Remove lane lines that are off screen
if (laneLine.y > 2800) {
laneLine.destroy();
laneLines.splice(k, 1);
}
}
// Add distance bonus to score
if (LK.ticks % 60 === 0) {
LK.setScore(LK.getScore() + 1);
scoreText.setText('Score: ' + LK.getScore());
}
// Change road color periodically
colorChangeTimer++;
if (colorChangeTimer > 600) {
// Every 10 seconds at 60fps
currentColorIndex = (currentColorIndex + 1) % roadColors.length;
changeRoadColor(roadColors[currentColorIndex]);
colorChangeTimer = 0;
}
};
// Road color change function
function changeRoadColor(newColor) {
roadBackground.tint = newColor;
}
// Example usage - change road color every 10 seconds
var colorChangeTimer = 0;
var roadColors = [0x404040, 0x8B4513, 0x2F4F4F, 0x483D8B, 0x556B2F];
var currentColorIndex = 0;
// Start background music
LK.playMusic('bgmusic');
; ===================================================================
--- original.js
+++ change.js
@@ -140,8 +140,15 @@
var laneLineSpawnTimer = 0;
var lastSwipeX = 0;
var lastSwipeY = 0;
var swipeStarted = false;
+// Create road background
+var roadBackground = game.addChild(LK.getAsset('roadBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+roadBackground.x = 1024; // Center of screen
+roadBackground.y = 1366;
// Create road borders
var leftBorder = game.addChild(LK.getAsset('roadBorder', {
anchorX: 0.5,
anchorY: 0.5
@@ -335,7 +342,24 @@
if (LK.ticks % 60 === 0) {
LK.setScore(LK.getScore() + 1);
scoreText.setText('Score: ' + LK.getScore());
}
+ // Change road color periodically
+ colorChangeTimer++;
+ if (colorChangeTimer > 600) {
+ // Every 10 seconds at 60fps
+ currentColorIndex = (currentColorIndex + 1) % roadColors.length;
+ changeRoadColor(roadColors[currentColorIndex]);
+ colorChangeTimer = 0;
+ }
};
+// Road color change function
+function changeRoadColor(newColor) {
+ roadBackground.tint = newColor;
+}
+// Example usage - change road color every 10 seconds
+var colorChangeTimer = 0;
+var roadColors = [0x404040, 0x8B4513, 0x2F4F4F, 0x483D8B, 0x556B2F];
+var currentColorIndex = 0;
// Start background music
-LK.playMusic('bgmusic');
\ No newline at end of file
+LK.playMusic('bgmusic');
+;
\ No newline at end of file
Polis arabası kuş bakışı. In-Game asset. 2d. High contrast. No shadows
Düz gri renk. In-Game asset. 2d. High contrast. No shadows
Kuş bakışı agaç. In-Game asset. 2d. High contrast. No shadows
Kalp 3d. In-Game asset. 2d. High contrast. No shadows
Kırmızı ve sarı gradient renk. In-Game asset. 2d. High contrast. No shadows
Çiçek kuş bakışı. In-Game asset. 2d. High contrast. No shadows
Kuş bakışı polis aracı. In-Game asset. 2d. High contrast. No shadows