User prompt
ParmagÌım ekrana devamlı dokunuyorken bile karakterim parmagÌımı takip etsin
User prompt
Karakter dokunma konumumu takip etsin
User prompt
Karakter parmak konumunu sadece x ekseninde takip etsin
Code edit (1 edits merged)
Please save this source code
User prompt
Swipe Runner
Initial prompt
Mobil oyun olmasını istiyorum
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Bomb collectible class var BombCollectible = Container.expand(function () { var self = Container.call(this); var bombAsset = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.update = function () { if (typeof lives === 'undefined' || lives > 0) { self.y += self.speed; } }; return self; }); // Heart collectible class var HeartCollectible = Container.expand(function () { var self = Container.call(this); var heartAsset = self.attachAsset('Heart', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.update = function () { if (typeof lives === 'undefined' || lives > 0) { self.y += self.speed; } }; return self; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obsAsset = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); // Speed will be set on creation self.speed = 0; self.update = function () { if (typeof lives === 'undefined' || lives > 0) { self.y += self.speed; } }; return self; }); // Point collectible class var PointCollectible = Container.expand(function () { var self = Container.call(this); var pointAsset = self.attachAsset('point', { anchorX: 0.5, anchorY: 0.5 }); // Speed will be set on creation self.speed = 0; self.update = function () { if (typeof lives === 'undefined' || lives > 0) { self.y += self.speed; } }; return self; }); // Runner class var Runner = Container.expand(function () { var self = Container.call(this); var runnerAsset = self.attachAsset('runner', { anchorX: 0.5, anchorY: 0.5 }); // For swipe movement self.targetX = self.x; self.targetY = self.y; // For collision flash self.flash = function () { tween(self, { alpha: 0.3 }, { duration: 80, onFinish: function onFinish() { tween(self, { alpha: 1 }, { duration: 120 }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x888888 }); /**** * Game Code ****/ // Game area dimensions // Runner character: a colorful box // Obstacle: a red ellipse // Point collectible: a yellow box // Play 'Troll' music in a loop as background music var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; // Play Troll music continuously in the background LK.playMusic('Troll'); // Runner start position var runnerStartX = GAME_WIDTH / 2; var runnerStartY = GAME_HEIGHT - 400; // Create runner var runner = new Runner(); runner.x = runnerStartX; runner.y = runnerStartY; runner.targetX = runner.x; runner.targetY = runner.y; game.addChild(runner); // Score var score = 0; var money = 0; // Ensure money is 0 at game start var scoreTxt = new Text2('0', { size: 120, fill: 0x222222 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Lives and Money var lives = 3; var livesMoneyTxt = new Text2('â„ ' + lives + ' $' + money, { size: 100, fill: 0xff3b30 }); livesMoneyTxt.anchor.set(0, 0); livesMoneyTxt.x = 120; livesMoneyTxt.y = 40; LK.gui.top.addChild(livesMoneyTxt); // Arrays for obstacles and points var obstacles = []; var points = []; var hearts = []; var bombs = []; // Difficulty progression var baseSpeed = 14; var speedIncrease = 0.012; // per tick var spawnInterval = 60; // ticks between spawns var minSpawnInterval = 24; var tickCount = 0; // Swipe handling var swipeStartX = null; var swipeStartY = null; var isSwiping = false; // Helper: clamp value function clamp(val, min, max) { return Math.max(min, Math.min(max, val)); } // Touch/drag events for swipe game.down = function (x, y, obj) { // Only start swipe if touch is not in top left 100x100 if (x < 100 && y < 100) return; swipeStartX = x; swipeStartY = y; runnerStartX = runner.x; // Save runner's current X as the base for delta isSwiping = true; }; game.move = function (x, y, obj) { // Only move runner if swipe is active if (isSwiping && swipeStartX !== null) { // Move runner by the same delta as finger movement var deltaX = x - swipeStartX; var newX = clamp(runnerStartX + deltaX, 100 + runner.width / 2, GAME_WIDTH - runner.width / 2 - 100); runner.x = newX; runner.y = runnerStartY; } }; game.up = function (x, y, obj) { isSwiping = false; swipeStartX = null; swipeStartY = null; // Optionally, snap runner back to base Y tween(runner, { y: runnerStartY }, { duration: 180, easing: tween.cubicOut }); }; // Main game update loop game.update = function () { tickCount++; // Increase speed over time var currentSpeed = baseSpeed + speedIncrease * tickCount; // Spawn obstacles, points, hearts, and bombs if (tickCount % spawnInterval === 0) { // Helper to get random speed in range [min, max] var getRandomSpeed = function getRandomSpeed(min, max) { return min + Math.random() * (max - min); }; // Randomly decide: obstacle, point, heart, or bomb // 60% obstacle, 25% point, 8% heart, 7% bomb var rand = Math.random(); var spawnType = 'obstacle'; if (rand < 0.6) spawnType = 'obstacle';else if (rand < 0.85) spawnType = 'point';else if (rand < 0.93) spawnType = 'heart';else spawnType = 'bomb'; var laneCount = 5; var laneWidth = (GAME_WIDTH - 400) / laneCount; var lane = Math.floor(Math.random() * laneCount); var spawnX = 200 + laneWidth / 2 + lane * laneWidth; var spawnY = -120; // Set max speed for each type var maxObstacleSpeed = 28; var maxCollectibleSpeed = 18; if (spawnType === 'obstacle') { var obs = new Obstacle(); obs.x = spawnX; obs.y = spawnY; // Randomize speed, but cap at maxObstacleSpeed var minObsSpeed = Math.max(currentSpeed * 0.7, 8); var maxObsSpeed = Math.min(currentSpeed * 1.1, maxObstacleSpeed); obs.speed = getRandomSpeed(minObsSpeed, maxObsSpeed); obstacles.push(obs); game.addChild(obs); } else if (spawnType === 'point') { var pt = new PointCollectible(); pt.x = spawnX; pt.y = spawnY; // Randomize speed, but cap at maxCollectibleSpeed var minPtSpeed = Math.max(currentSpeed * 0.35, 5); var maxPtSpeed = Math.min(currentSpeed * 0.65, maxCollectibleSpeed); pt.speed = getRandomSpeed(minPtSpeed, maxPtSpeed); points.push(pt); game.addChild(pt); } else if (spawnType === 'heart') { var heart = new HeartCollectible(); heart.x = spawnX; heart.y = spawnY; // Randomize speed, but cap at maxCollectibleSpeed var minHeartSpeed = Math.max(currentSpeed * 0.35, 5); var maxHeartSpeed = Math.min(currentSpeed * 0.65, maxCollectibleSpeed); heart.speed = getRandomSpeed(minHeartSpeed, maxHeartSpeed); hearts.push(heart); game.addChild(heart); } else if (spawnType === 'bomb') { var bomb = new BombCollectible(); bomb.x = spawnX; bomb.y = spawnY; // Randomize speed, but cap at maxCollectibleSpeed var minBombSpeed = Math.max(currentSpeed * 0.35, 5); var maxBombSpeed = Math.min(currentSpeed * 0.65, maxCollectibleSpeed); bomb.speed = getRandomSpeed(minBombSpeed, maxBombSpeed); bombs.push(bomb); game.addChild(bomb); } // Gradually decrease spawn interval to increase difficulty if (spawnInterval > minSpawnInterval && tickCount % 600 === 0) { spawnInterval -= 4; if (spawnInterval < minSpawnInterval) spawnInterval = minSpawnInterval; } } // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { var obs = obstacles[i]; obs.update(); // Remove if off screen if (obs.y - obs.height / 2 > GAME_HEIGHT + 100) { obs.destroy(); obstacles.splice(i, 1); continue; } // Collision with runner if (obs.intersects(runner)) { // Play explosion sound LK.getSound('Explosion').play(); // Flash runner runner.flash(); // Flash screen LK.effects.flashScreen(0xff3b30, 600); // Decrease lives lives -= 1; if (lives < 0) lives = 0; livesMoneyTxt.setText('â„ ' + lives + ' $' + money); // Remove obstacle so it doesn't hit again obs.destroy(); obstacles.splice(i, 1); // Game over if no lives left if (lives <= 0) { // Pause the game loop game.paused = true; // Play 'TrollGameOver' sound LK.getSound('TrollGameOver').play(); // Fade out the screen over 1.2 seconds, then show game over var fadeOverlay = new Container(); var fadeRect = LK.getAsset('GameOver', { // Use GameOver image as overlay width: GAME_WIDTH, height: GAME_HEIGHT, anchorX: 0, anchorY: 0, x: 0, y: 0 }); fadeRect.alpha = 0; fadeOverlay.addChild(fadeRect); game.addChild(fadeOverlay); tween(fadeRect, { alpha: 1 }, { duration: 3000, onFinish: function onFinish() { LK.showGameOver(); } }); return; } continue; } } // Update points for (var j = points.length - 1; j >= 0; j--) { var pt = points[j]; pt.update(); // Remove if off screen if (pt.y - pt.height / 2 > GAME_HEIGHT + 100) { pt.destroy(); points.splice(j, 1); continue; } // Collectible collision if (pt.intersects(runner)) { // Play coin collect sound LK.getSound('Meterial').play(); // Add score and money score += 1; money += 1; LK.setScore(score); scoreTxt.setText(score); livesMoneyTxt.setText('â„ ' + lives + ' $' + money); // Flash screen yellow, similar to bomb's effect (darker, longer, more solid) LK.effects.flashScreen(0xffc800, 600); pt.destroy(); points.splice(j, 1); continue; } } // Update hearts for (var h = hearts.length - 1; h >= 0; h--) { var heart = hearts[h]; heart.update(); // Remove if off screen if (heart.y - heart.height / 2 > GAME_HEIGHT + 100) { heart.destroy(); hearts.splice(h, 1); continue; } // Collectible collision if (heart.intersects(runner)) { // Play 'ohh' sound LK.getSound('ohh').play(); // Add life lives += 1; livesMoneyTxt.setText('â„ ' + lives + ' $' + money); // Flash screen green, similar to bomb's effect but green LK.effects.flashScreen(0x00ff00, 600); // No runner tint flash on heart collect; runner always stays default color heart.destroy(); hearts.splice(h, 1); continue; } } // Update bombs for (var b = bombs.length - 1; b >= 0; b--) { var bomb = bombs[b]; bomb.update(); // Remove if off screen if (bomb.y - bomb.height / 2 > GAME_HEIGHT + 100) { bomb.destroy(); bombs.splice(b, 1); continue; } // Bomb collision if (bomb.intersects(runner)) { // Lose a life lives -= 1; if (lives < 0) lives = 0; livesMoneyTxt.setText('â„ ' + lives + ' $' + money); // No runner tint flash on bomb collect; runner always stays default color LK.effects.flashScreen(0x222222, 600); bomb.destroy(); bombs.splice(b, 1); // Game over if no lives left if (lives <= 0) { // Pause the game loop game.paused = true; // Play 'TrollGameOver' sound LK.getSound('TrollGameOver').play(); // Fade out the screen over 1.2 seconds, then show game over var fadeOverlay = new Container(); var fadeRect = LK.getAsset('GameOver', { // Use GameOver image as overlay width: GAME_WIDTH, height: GAME_HEIGHT, anchorX: 0, anchorY: 0, x: 0, y: 0 }); fadeRect.alpha = 0; fadeOverlay.addChild(fadeRect); game.addChild(fadeOverlay); tween(fadeRect, { alpha: 1 }, { duration: 3000, onFinish: function onFinish() { LK.showGameOver(); } }); return; } continue; } } }; // Center score text at top, avoid top left 100x100 scoreTxt.x = 1024; scoreTxt.y = 40; // Add Instagram handle text to bottom right corner var instaTxt = new Text2('insta: oguzhandgzl', { size: 50, fill: 0x222222 }); instaTxt.anchor.set(1, 1); // Anchor at bottom right instaTxt.x = GAME_WIDTH - 40; instaTxt.y = GAME_HEIGHT - 40; LK.gui.bottomRight.addChild(instaTxt); // Add instagram handle text that follows the character var heleText = new Text2('insta: oguzhandgzl', { size: 50, fill: 0x222222 }); heleText.anchor.set(0.5, 0); // Anchor at top center game.addChild(heleText); // Add update to game.update function to make helehele follow the runner var originalUpdate = game.update; game.update = function () { // Call the original update function originalUpdate.call(this); // Update heleText position to follow the runner heleText.x = runner.x; heleText.y = runner.y + 150; // Position below the runner };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Bomb collectible class
var BombCollectible = Container.expand(function () {
var self = Container.call(this);
var bombAsset = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0;
self.update = function () {
if (typeof lives === 'undefined' || lives > 0) {
self.y += self.speed;
}
};
return self;
});
// Heart collectible class
var HeartCollectible = Container.expand(function () {
var self = Container.call(this);
var heartAsset = self.attachAsset('Heart', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0;
self.update = function () {
if (typeof lives === 'undefined' || lives > 0) {
self.y += self.speed;
}
};
return self;
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obsAsset = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
// Speed will be set on creation
self.speed = 0;
self.update = function () {
if (typeof lives === 'undefined' || lives > 0) {
self.y += self.speed;
}
};
return self;
});
// Point collectible class
var PointCollectible = Container.expand(function () {
var self = Container.call(this);
var pointAsset = self.attachAsset('point', {
anchorX: 0.5,
anchorY: 0.5
});
// Speed will be set on creation
self.speed = 0;
self.update = function () {
if (typeof lives === 'undefined' || lives > 0) {
self.y += self.speed;
}
};
return self;
});
// Runner class
var Runner = Container.expand(function () {
var self = Container.call(this);
var runnerAsset = self.attachAsset('runner', {
anchorX: 0.5,
anchorY: 0.5
});
// For swipe movement
self.targetX = self.x;
self.targetY = self.y;
// For collision flash
self.flash = function () {
tween(self, {
alpha: 0.3
}, {
duration: 80,
onFinish: function onFinish() {
tween(self, {
alpha: 1
}, {
duration: 120
});
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x888888
});
/****
* Game Code
****/
// Game area dimensions
// Runner character: a colorful box
// Obstacle: a red ellipse
// Point collectible: a yellow box
// Play 'Troll' music in a loop as background music
var GAME_WIDTH = 2048;
var GAME_HEIGHT = 2732;
// Play Troll music continuously in the background
LK.playMusic('Troll');
// Runner start position
var runnerStartX = GAME_WIDTH / 2;
var runnerStartY = GAME_HEIGHT - 400;
// Create runner
var runner = new Runner();
runner.x = runnerStartX;
runner.y = runnerStartY;
runner.targetX = runner.x;
runner.targetY = runner.y;
game.addChild(runner);
// Score
var score = 0;
var money = 0; // Ensure money is 0 at game start
var scoreTxt = new Text2('0', {
size: 120,
fill: 0x222222
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Lives and Money
var lives = 3;
var livesMoneyTxt = new Text2('â„ ' + lives + ' $' + money, {
size: 100,
fill: 0xff3b30
});
livesMoneyTxt.anchor.set(0, 0);
livesMoneyTxt.x = 120;
livesMoneyTxt.y = 40;
LK.gui.top.addChild(livesMoneyTxt);
// Arrays for obstacles and points
var obstacles = [];
var points = [];
var hearts = [];
var bombs = [];
// Difficulty progression
var baseSpeed = 14;
var speedIncrease = 0.012; // per tick
var spawnInterval = 60; // ticks between spawns
var minSpawnInterval = 24;
var tickCount = 0;
// Swipe handling
var swipeStartX = null;
var swipeStartY = null;
var isSwiping = false;
// Helper: clamp value
function clamp(val, min, max) {
return Math.max(min, Math.min(max, val));
}
// Touch/drag events for swipe
game.down = function (x, y, obj) {
// Only start swipe if touch is not in top left 100x100
if (x < 100 && y < 100) return;
swipeStartX = x;
swipeStartY = y;
runnerStartX = runner.x; // Save runner's current X as the base for delta
isSwiping = true;
};
game.move = function (x, y, obj) {
// Only move runner if swipe is active
if (isSwiping && swipeStartX !== null) {
// Move runner by the same delta as finger movement
var deltaX = x - swipeStartX;
var newX = clamp(runnerStartX + deltaX, 100 + runner.width / 2, GAME_WIDTH - runner.width / 2 - 100);
runner.x = newX;
runner.y = runnerStartY;
}
};
game.up = function (x, y, obj) {
isSwiping = false;
swipeStartX = null;
swipeStartY = null;
// Optionally, snap runner back to base Y
tween(runner, {
y: runnerStartY
}, {
duration: 180,
easing: tween.cubicOut
});
};
// Main game update loop
game.update = function () {
tickCount++;
// Increase speed over time
var currentSpeed = baseSpeed + speedIncrease * tickCount;
// Spawn obstacles, points, hearts, and bombs
if (tickCount % spawnInterval === 0) {
// Helper to get random speed in range [min, max]
var getRandomSpeed = function getRandomSpeed(min, max) {
return min + Math.random() * (max - min);
};
// Randomly decide: obstacle, point, heart, or bomb
// 60% obstacle, 25% point, 8% heart, 7% bomb
var rand = Math.random();
var spawnType = 'obstacle';
if (rand < 0.6) spawnType = 'obstacle';else if (rand < 0.85) spawnType = 'point';else if (rand < 0.93) spawnType = 'heart';else spawnType = 'bomb';
var laneCount = 5;
var laneWidth = (GAME_WIDTH - 400) / laneCount;
var lane = Math.floor(Math.random() * laneCount);
var spawnX = 200 + laneWidth / 2 + lane * laneWidth;
var spawnY = -120;
// Set max speed for each type
var maxObstacleSpeed = 28;
var maxCollectibleSpeed = 18;
if (spawnType === 'obstacle') {
var obs = new Obstacle();
obs.x = spawnX;
obs.y = spawnY;
// Randomize speed, but cap at maxObstacleSpeed
var minObsSpeed = Math.max(currentSpeed * 0.7, 8);
var maxObsSpeed = Math.min(currentSpeed * 1.1, maxObstacleSpeed);
obs.speed = getRandomSpeed(minObsSpeed, maxObsSpeed);
obstacles.push(obs);
game.addChild(obs);
} else if (spawnType === 'point') {
var pt = new PointCollectible();
pt.x = spawnX;
pt.y = spawnY;
// Randomize speed, but cap at maxCollectibleSpeed
var minPtSpeed = Math.max(currentSpeed * 0.35, 5);
var maxPtSpeed = Math.min(currentSpeed * 0.65, maxCollectibleSpeed);
pt.speed = getRandomSpeed(minPtSpeed, maxPtSpeed);
points.push(pt);
game.addChild(pt);
} else if (spawnType === 'heart') {
var heart = new HeartCollectible();
heart.x = spawnX;
heart.y = spawnY;
// Randomize speed, but cap at maxCollectibleSpeed
var minHeartSpeed = Math.max(currentSpeed * 0.35, 5);
var maxHeartSpeed = Math.min(currentSpeed * 0.65, maxCollectibleSpeed);
heart.speed = getRandomSpeed(minHeartSpeed, maxHeartSpeed);
hearts.push(heart);
game.addChild(heart);
} else if (spawnType === 'bomb') {
var bomb = new BombCollectible();
bomb.x = spawnX;
bomb.y = spawnY;
// Randomize speed, but cap at maxCollectibleSpeed
var minBombSpeed = Math.max(currentSpeed * 0.35, 5);
var maxBombSpeed = Math.min(currentSpeed * 0.65, maxCollectibleSpeed);
bomb.speed = getRandomSpeed(minBombSpeed, maxBombSpeed);
bombs.push(bomb);
game.addChild(bomb);
}
// Gradually decrease spawn interval to increase difficulty
if (spawnInterval > minSpawnInterval && tickCount % 600 === 0) {
spawnInterval -= 4;
if (spawnInterval < minSpawnInterval) spawnInterval = minSpawnInterval;
}
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obs = obstacles[i];
obs.update();
// Remove if off screen
if (obs.y - obs.height / 2 > GAME_HEIGHT + 100) {
obs.destroy();
obstacles.splice(i, 1);
continue;
}
// Collision with runner
if (obs.intersects(runner)) {
// Play explosion sound
LK.getSound('Explosion').play();
// Flash runner
runner.flash();
// Flash screen
LK.effects.flashScreen(0xff3b30, 600);
// Decrease lives
lives -= 1;
if (lives < 0) lives = 0;
livesMoneyTxt.setText('â„ ' + lives + ' $' + money);
// Remove obstacle so it doesn't hit again
obs.destroy();
obstacles.splice(i, 1);
// Game over if no lives left
if (lives <= 0) {
// Pause the game loop
game.paused = true;
// Play 'TrollGameOver' sound
LK.getSound('TrollGameOver').play();
// Fade out the screen over 1.2 seconds, then show game over
var fadeOverlay = new Container();
var fadeRect = LK.getAsset('GameOver', {
// Use GameOver image as overlay
width: GAME_WIDTH,
height: GAME_HEIGHT,
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
fadeRect.alpha = 0;
fadeOverlay.addChild(fadeRect);
game.addChild(fadeOverlay);
tween(fadeRect, {
alpha: 1
}, {
duration: 3000,
onFinish: function onFinish() {
LK.showGameOver();
}
});
return;
}
continue;
}
}
// Update points
for (var j = points.length - 1; j >= 0; j--) {
var pt = points[j];
pt.update();
// Remove if off screen
if (pt.y - pt.height / 2 > GAME_HEIGHT + 100) {
pt.destroy();
points.splice(j, 1);
continue;
}
// Collectible collision
if (pt.intersects(runner)) {
// Play coin collect sound
LK.getSound('Meterial').play();
// Add score and money
score += 1;
money += 1;
LK.setScore(score);
scoreTxt.setText(score);
livesMoneyTxt.setText('â„ ' + lives + ' $' + money);
// Flash screen yellow, similar to bomb's effect (darker, longer, more solid)
LK.effects.flashScreen(0xffc800, 600);
pt.destroy();
points.splice(j, 1);
continue;
}
}
// Update hearts
for (var h = hearts.length - 1; h >= 0; h--) {
var heart = hearts[h];
heart.update();
// Remove if off screen
if (heart.y - heart.height / 2 > GAME_HEIGHT + 100) {
heart.destroy();
hearts.splice(h, 1);
continue;
}
// Collectible collision
if (heart.intersects(runner)) {
// Play 'ohh' sound
LK.getSound('ohh').play();
// Add life
lives += 1;
livesMoneyTxt.setText('â„ ' + lives + ' $' + money);
// Flash screen green, similar to bomb's effect but green
LK.effects.flashScreen(0x00ff00, 600);
// No runner tint flash on heart collect; runner always stays default color
heart.destroy();
hearts.splice(h, 1);
continue;
}
}
// Update bombs
for (var b = bombs.length - 1; b >= 0; b--) {
var bomb = bombs[b];
bomb.update();
// Remove if off screen
if (bomb.y - bomb.height / 2 > GAME_HEIGHT + 100) {
bomb.destroy();
bombs.splice(b, 1);
continue;
}
// Bomb collision
if (bomb.intersects(runner)) {
// Lose a life
lives -= 1;
if (lives < 0) lives = 0;
livesMoneyTxt.setText('â„ ' + lives + ' $' + money);
// No runner tint flash on bomb collect; runner always stays default color
LK.effects.flashScreen(0x222222, 600);
bomb.destroy();
bombs.splice(b, 1);
// Game over if no lives left
if (lives <= 0) {
// Pause the game loop
game.paused = true;
// Play 'TrollGameOver' sound
LK.getSound('TrollGameOver').play();
// Fade out the screen over 1.2 seconds, then show game over
var fadeOverlay = new Container();
var fadeRect = LK.getAsset('GameOver', {
// Use GameOver image as overlay
width: GAME_WIDTH,
height: GAME_HEIGHT,
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
fadeRect.alpha = 0;
fadeOverlay.addChild(fadeRect);
game.addChild(fadeOverlay);
tween(fadeRect, {
alpha: 1
}, {
duration: 3000,
onFinish: function onFinish() {
LK.showGameOver();
}
});
return;
}
continue;
}
}
};
// Center score text at top, avoid top left 100x100
scoreTxt.x = 1024;
scoreTxt.y = 40;
// Add Instagram handle text to bottom right corner
var instaTxt = new Text2('insta: oguzhandgzl', {
size: 50,
fill: 0x222222
});
instaTxt.anchor.set(1, 1); // Anchor at bottom right
instaTxt.x = GAME_WIDTH - 40;
instaTxt.y = GAME_HEIGHT - 40;
LK.gui.bottomRight.addChild(instaTxt);
// Add instagram handle text that follows the character
var heleText = new Text2('insta: oguzhandgzl', {
size: 50,
fill: 0x222222
});
heleText.anchor.set(0.5, 0); // Anchor at top center
game.addChild(heleText);
// Add update to game.update function to make helehele follow the runner
var originalUpdate = game.update;
game.update = function () {
// Call the original update function
originalUpdate.call(this);
// Update heleText position to follow the runner
heleText.x = runner.x;
heleText.y = runner.y + 150; // Position below the runner
};