User prompt
Alev efectini büyült ve polis arabasına yapışık kalsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Alev efecti sabit kalsın hareket etmeddn kaybolsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Polis araçları vurulmadan kayboluyor
User prompt
Polis aracı vuruldugunda alev alsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Polis aracşarının ısıkları yanlarda ve üsttede yansın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Araç farını biraz daha öne al
User prompt
Polis araçlaeının kırmızı ve mavi ısıkları gündüzde olsun dakat gece daha belirgin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Araç farları yanlış yerde
User prompt
Polis ışıkları gündüzde yansın fakat gece daha belirgin olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Gece oldugun polis ışıkları ve oyuncu araç lambaladı yansın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyuna gündüz gece döngüsü ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Egzos parçacıkları yönü yanlış
User prompt
Oyuncu aracına egzoz efekti ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Altinları biraz çogalt
User prompt
Arac kayma sesi biriz azalt
User prompt
Aracı saga sola hareket ettirirken ses ekle
User prompt
Altinlar bazen engellerin üzerinde beliriyor
User prompt
Altin toplama sesini biraz yükselt
User prompt
Polis arabaları vurulma sesi ekle
User prompt
Her altın sadece 1 puan ve mtre göstergesini kaldır
User prompt
Scor tablosu sadece alınan altınları saysın
User prompt
Polis arabaları vurulup ortadan kaybolmasına ragmen ordaymış gibi oyuncunun canını yiyor
User prompt
Polis siren sesi sürekli tekrar etsin
User prompt
Olmadı
User prompt
Polis siren sesi ve bg müzik aynı anda çalsın
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -25;
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 = 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;
// Add police lights to the obstacle (police car)
var leftLight = self.attachAsset('policeLight', {
anchorX: 0.5,
anchorY: 0.5
});
leftLight.x = -30;
leftLight.y = -60;
var rightLight = self.attachAsset('policeLight', {
anchorX: 0.5,
anchorY: 0.5
});
rightLight.x = 30;
rightLight.y = -60;
rightLight.tint = 0x0000ff; // Make right light blue
self.lightTimer = 0;
self.isRedActive = true;
self.update = function () {
self.y += self.speed;
// Animate police lights
self.lightTimer++;
if (self.lightTimer >= 15) {
// Change every 15 frames (0.25 seconds at 60fps)
self.lightTimer = 0;
self.isRedActive = !self.isRedActive;
if (self.isRedActive) {
leftLight.alpha = 1;
rightLight.alpha = 0.3;
} else {
leftLight.alpha = 0.3;
rightLight.alpha = 1;
}
}
};
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.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.moveLeft = function () {
if (self.currentLane > 0) {
self.currentLane--;
self.targetX = self.lanes[self.currentLane];
// Play car movement sound
try {
LK.getSound('carMove').play();
} catch (e) {
console.log('Car move sound error:', e);
}
}
};
self.moveRight = function () {
if (self.currentLane < 2) {
self.currentLane++;
self.targetX = self.lanes[self.currentLane];
// Play car movement sound
try {
LK.getSound('carMove').play();
} catch (e) {
console.log('Car move sound error:', e);
}
}
};
self.update = function () {
// 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;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupGraphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = gameSpeed;
self.collected = false;
self.lifetime = 420; // 7 seconds at 60fps
self.update = function () {
self.y += self.speed;
self.rotation += 0.15;
// Decrease lifetime
self.lifetime--;
// Flash when about to disappear (last 3 seconds)
if (self.lifetime <= 180 && self.lifetime > 0) {
self.alpha = (Math.sin(self.lifetime * 0.3) + 1) * 0.5;
}
};
return self;
});
var Tree = Container.expand(function () {
var self = Container.call(this);
var treeGraphics = self.attachAsset('tree', {
anchorX: 0.5,
anchorY: 1.0
});
self.speed = gameSpeed;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var player;
var obstacles = [];
var coins = [];
var powerups = [];
var bullets = [];
var hasWeapon = false;
var weaponTimer = 0;
var weaponDuration = 1200; // 20 seconds at 60fps
var laneLines = [];
var trees = [];
var gameSpeed = 8;
var maxSpeed = 20;
var speedIncrement = 0.005;
var distance = 0;
var obstacleSpawnTimer = 0;
var coinSpawnTimer = 0;
var powerupSpawnTimer = 0;
var laneLineSpawnTimer = 0;
var treeSpawnTimer = 0;
var lastSwipeX = 0;
var lastSwipeY = 0;
var swipeStarted = false;
var policeMusicPlaying = false;
var policeOnScreen = false;
var lives = 3;
var maxLives = 3;
// 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 green forest backgrounds on sides
var leftForest = game.addChild(LK.getAsset('forestBackground', {
anchorX: 0.5,
anchorY: 0.5
}));
leftForest.x = 238; // Center of left side area
leftForest.y = 1366;
var rightForest = game.addChild(LK.getAsset('forestBackground', {
anchorX: 0.5,
anchorY: 0.5
}));
rightForest.x = 1810; // Center of right side area
rightForest.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());
player.scaleX = 1.3;
player.scaleY = 1.3;
// Create score display
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Distance display removed - only counting coins for score
// Create lives display as hearts in top right
var healthBars = [];
for (var h = 0; h < maxLives; h++) {
var heart = LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heart.x = -50 - h * 50;
heart.y = 80;
LK.gui.topRight.addChild(heart);
healthBars.push(heart);
}
// 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();
}
}
}
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.9;
obstacle.scaleY = 0.9;
tween(obstacle, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 400,
easing: tween.easeOut
});
obstacles.push(obstacle);
game.addChild(obstacle);
}
function spawnCoin() {
var coin = new Coin();
var laneIndex = Math.floor(Math.random() * 3);
var targetX = player.lanes[laneIndex];
var canSpawn = true;
// Check if there's an obstacle in this lane that would conflict
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
// Check if obstacle is in the same lane and close to spawn area
if (Math.abs(obstacle.x - targetX) < 50 && obstacle.y >= -300 && obstacle.y <= 200) {
canSpawn = false;
break;
}
}
// If we can't spawn in the selected lane, try other lanes
if (!canSpawn) {
var availableLanes = [];
for (var lane = 0; lane < 3; lane++) {
var laneX = player.lanes[lane];
var laneAvailable = true;
for (var j = 0; j < obstacles.length; j++) {
var obs = obstacles[j];
if (Math.abs(obs.x - laneX) < 50 && obs.y >= -300 && obs.y <= 200) {
laneAvailable = false;
break;
}
}
if (laneAvailable) {
availableLanes.push(lane);
}
}
// If no lanes are available, don't spawn coin this time
if (availableLanes.length === 0) {
return;
}
// Pick a random available lane
laneIndex = availableLanes[Math.floor(Math.random() * availableLanes.length)];
targetX = player.lanes[laneIndex];
}
coin.x = targetX;
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 spawnPowerUp() {
var powerup = new PowerUp();
var laneIndex = Math.floor(Math.random() * 3);
powerup.x = player.lanes[laneIndex];
powerup.y = -50;
powerup.speed = gameSpeed;
powerup.scaleX = 0.3;
powerup.scaleY = 0.3;
tween(powerup, {
scaleX: 1,
scaleY: 1
}, {
duration: 600,
easing: tween.easeOut
});
powerups.push(powerup);
game.addChild(powerup);
}
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 = -20;
laneLine.speed = gameSpeed;
laneLines.push(laneLine);
game.addChild(laneLine);
}
}
function spawnTrees() {
// Spawn trees on left side of road
var leftPositions = [100, 200, 300, 400];
for (var i = 0; i < leftPositions.length; i++) {
if (Math.random() < 0.3) {
var leftTree = new Tree();
leftTree.x = leftPositions[i];
leftTree.y = -80;
leftTree.speed = gameSpeed;
// Add some variation in scale
leftTree.scaleX = 0.8 + Math.random() * 0.4;
leftTree.scaleY = 0.8 + Math.random() * 0.4;
// Add slight tint variation for natural look
var tintVariation = 0.9 + Math.random() * 0.2;
leftTree.tint = tintVariation * 0x90EE90 | 0;
trees.push(leftTree);
game.addChild(leftTree);
}
}
// Spawn trees on right side of road
var rightPositions = [1648, 1748, 1848, 1948];
for (var j = 0; j < rightPositions.length; j++) {
if (Math.random() < 0.3) {
var rightTree = new Tree();
rightTree.x = rightPositions[j];
rightTree.y = -80;
rightTree.speed = gameSpeed;
// Add some variation in scale
rightTree.scaleX = 0.8 + Math.random() * 0.4;
rightTree.scaleY = 0.8 + Math.random() * 0.4;
// Add slight tint variation for natural look
var tintVariation = 0.9 + Math.random() * 0.2;
rightTree.tint = tintVariation * 0x90EE90 | 0;
trees.push(rightTree);
game.addChild(rightTree);
}
}
}
// Main game loop
game.update = function () {
// Increase game speed gradually
if (gameSpeed < maxSpeed) {
gameSpeed += speedIncrement;
}
// Distance tracking removed - only counting coins for score
// Spawn obstacles
obstacleSpawnTimer++;
if (obstacleSpawnTimer > 60 + Math.random() * 60) {
spawnObstacle();
obstacleSpawnTimer = 0;
}
// Spawn coins - dynamically adjust spawn rate based on game speed
coinSpawnTimer++;
var coinSpawnRate = Math.max(30, 120 - (gameSpeed - 8) * 5); // Faster spawning as speed increases
if (coinSpawnTimer > coinSpawnRate + Math.random() * 30) {
spawnCoin();
coinSpawnTimer = 0;
}
// Spawn powerups (rare spawn - every 1 minute)
powerupSpawnTimer++;
if (powerupSpawnTimer > 3600) {
// 1 minute (60 seconds * 60 fps)
spawnPowerUp();
powerupSpawnTimer = 0;
}
// Spawn lane lines
laneLineSpawnTimer++;
if (laneLineSpawnTimer > 30) {
spawnLaneLine();
laneLineSpawnTimer = 0;
}
// Spawn trees
treeSpawnTimer++;
if (treeSpawnTimer > 45) {
spawnTrees();
treeSpawnTimer = 0;
}
// Update obstacles
var currentPoliceOnScreen = false;
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
obstacle.speed = gameSpeed;
// Check if police car is on screen
if (obstacle.y >= -200 && obstacle.y <= 2900) {
currentPoliceOnScreen = true;
}
// 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)) {
// Play crash sound
try {
LK.getSound('crash').play();
} catch (e) {
console.log('Crash sound error:', e);
}
// Reduce lives
lives--;
// Hide the health bar corresponding to lost life
if (lives >= 0 && lives < healthBars.length) {
healthBars[healthBars.length - 1 - lives].visible = false;
}
// Flash screen and remove obstacle
LK.effects.flashScreen(0xff0000, 500);
obstacle.destroy();
obstacles.splice(i, 1);
// Check if game over
if (lives <= 0) {
// Add delay to allow crash sound to play before game over
LK.setTimeout(function () {
LK.showGameOver();
}, 800); // Wait 800ms for crash sound to play
return;
}
// Make player temporarily invulnerable
player.alpha = 0.5;
LK.setTimeout(function () {
player.alpha = 1.0;
}, 1500); // 1.5 seconds of invulnerability
continue;
}
}
// Handle police music based on police presence
if (currentPoliceOnScreen && !policeMusicPlaying) {
// Start police siren as a sound effect that loops instead of music
// This allows it to play alongside the background music
try {
var policeSiren = LK.getSound('policemusic');
if (policeSiren) {
policeSiren.loop = true;
policeSiren.play();
}
} catch (e) {
console.log('Police siren play error:', e);
}
policeMusicPlaying = true;
policeOnScreen = true;
} else if (!currentPoliceOnScreen && policeMusicPlaying) {
// Stop police siren sound
try {
var policeSiren = LK.getSound('policemusic');
if (policeSiren) {
policeSiren.stop();
}
} catch (e) {
console.log('Police siren stop error:', e);
}
policeMusicPlaying = false;
policeOnScreen = false;
} else if (currentPoliceOnScreen && policeMusicPlaying) {
// Ensure police siren continues playing if it stopped
try {
var policeSiren = LK.getSound('policemusic');
if (policeSiren && !policeSiren.playing) {
policeSiren.loop = true;
policeSiren.play();
}
} catch (e) {
console.log('Police siren restart error:', e);
}
}
// 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() + 1); // Each coin is worth exactly 1 point
scoreText.setText('Score: ' + LK.getScore());
LK.getSound('collect').play();
// Enhanced visual effect with faster animation for higher speeds
var animationDuration = Math.max(200, 400 - (gameSpeed - 8) * 10);
tween(coin, {
alpha: 0,
scaleX: 2.5,
scaleY: 2.5,
y: coin.y - 50
}, {
duration: animationDuration,
easing: tween.easeOut,
onFinish: function onFinish() {
coin.destroy();
}
});
coins.splice(j, 1);
}
}
// Update powerups
for (var p = powerups.length - 1; p >= 0; p--) {
var powerup = powerups[p];
powerup.speed = gameSpeed;
// Remove powerups that are off screen or expired
if (powerup.y > 2800 || powerup.lifetime <= 0) {
powerup.destroy();
powerups.splice(p, 1);
continue;
}
// Check collection
if (!powerup.collected && player.intersects(powerup)) {
powerup.collected = true;
hasWeapon = true;
weaponTimer = weaponDuration; // 20 seconds
LK.getSound('collect').play();
// Visual effect
tween(powerup, {
alpha: 0,
scaleX: 3,
scaleY: 3
}, {
duration: 400,
onFinish: function onFinish() {
powerup.destroy();
}
});
powerups.splice(p, 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);
}
}
// Update trees
for (var t = trees.length - 1; t >= 0; t--) {
var tree = trees[t];
tree.speed = gameSpeed;
// Remove trees that are off screen
if (tree.y > 2800) {
tree.destroy();
trees.splice(t, 1);
}
}
// Handle weapon system
if (hasWeapon) {
weaponTimer--;
if (weaponTimer <= 0) {
hasWeapon = false;
}
// Shoot bullets every 20 frames (3 times per second)
if (LK.ticks % 20 === 0) {
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y - 100;
bullets.push(bullet);
game.addChild(bullet);
// Play gun sound
LK.getSound('gunshot').play();
}
}
// Update bullets
for (var b = bullets.length - 1; b >= 0; b--) {
var bullet = bullets[b];
// Remove bullets that are off screen
if (bullet.y < -50) {
bullet.destroy();
bullets.splice(b, 1);
continue;
}
// Check bullet collision with obstacles
for (var o = obstacles.length - 1; o >= 0; o--) {
var obstacle = obstacles[o];
if (bullet.intersects(obstacle)) {
// Play police hit sound
try {
LK.getSound('policeHit').play();
} catch (e) {
console.log('Police hit sound error:', e);
}
// Destroy bullet immediately
bullet.destroy();
bullets.splice(b, 1);
// Remove obstacle from array immediately to prevent further collisions
obstacles.splice(o, 1);
// Create red burning effect before destroying obstacle
tween(obstacle, {
tint: 0xff0000,
alpha: 0
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
obstacle.destroy();
}
});
break;
}
}
}
// Road color no longer changes automatically
};
// Road color change function (kept for potential future use)
function changeRoadColor(newColor) {
roadBackground.tint = newColor;
}
// Spawn initial powerup at game start
spawnPowerUp();
// Start background music - this will be the base music layer
LK.playMusic('bgmusic');
; ===================================================================
--- original.js
+++ change.js
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