User prompt
Start button should not appear when the game starts
Code edit (2 edits merged)
Please save this source code
User prompt
The adventures of Burhan and Nadir
Code edit (1 edits merged)
Please save this source code
User prompt
Occasionally have scrolling text on the screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The score should end with "TEBRİKLER" on 10 and write " kafanızı s1kem " underneath.
User prompt
If Bird2 falls, it will return to its original state of bird.
User prompt
Go with only bird until 5 points, then turn into bird2
User prompt
A new bird comes in score 5
User prompt
Pull back
User prompt
A new bird comes in Level 5
User prompt
Pull back
User prompt
Try again if you want to make it easier for yourself
User prompt
Pull back
User prompt
Increase the distance between the pipes a little more
User prompt
Increase it a bit more and the spaces will be random
User prompt
Increase the distance between pipes
User prompt
The start button should be invisible when t Don't be seen
User prompt
The start button should be deleted or made transparent when the game starts.
User prompt
Sounds can be adjusted from the settings menu and The settings button can be clicked
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var settingsPos = LK.gui.center.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 400
User prompt
The flap sound should be low and there should be an adjustment area in the game.There should be a start and settings button in the menu
User prompt
When the game starts Keep the score screen and it will come back when you die
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); var birdSprite = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.velocityY = 0; self.gravity = 0.8; self.flapStrength = -12; self.isDead = false; self.lastY = 0; self.flap = function () { if (!self.isDead && gameStarted && !flapSoundPlaying) { self.velocityY = self.flapStrength; flapSoundPlaying = true; var flapSound = LK.getSound('flap'); flapSound.play(); // Reset flap sound state when sound ends (approximate duration) LK.setTimeout(function () { flapSoundPlaying = false; }, 200); } }; self.update = function () { if (!self.isDead) { self.lastY = self.y; self.velocityY += self.gravity; self.y += self.velocityY; // Rotate bird based on velocity birdSprite.rotation = Math.max(-0.5, Math.min(0.5, self.velocityY * 0.1)); // Check ground collision if (self.y > groundY - 40) { self.y = groundY - 40; self.die(); } // Check ceiling collision if (self.y < 40) { self.y = 40; self.velocityY = 0; } } }; self.die = function () { if (!self.isDead) { self.isDead = true; if (!hitSoundPlaying) { hitSoundPlaying = true; var hitSound = LK.getSound('hit'); hitSound.play(); } gameState = 'gameover'; // Update best score var currentScore = LK.getScore(); if (currentScore > bestScore) { bestScore = currentScore; storage.bestScore = bestScore; bestScoreTxt.setText('Best: ' + bestScore); } LK.setTimeout(function () { // Reset game state to menu gameState = 'menu'; gameStarted = false; self.isDead = false; self.velocityY = 0; self.y = 1366; // Smooth fade out only score display tween(scoreTxt, { alpha: 0 }, { duration: 500 }); // Smooth fade in menu elements with scale animation tween(titleTxt, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 800 }); tween(startBtn, { alpha: 1, y: 0 }, { duration: 800 }); tween(bestScoreTxt, { alpha: 1, y: 120 }, { duration: 800 }); tween(instructionTxt, { alpha: 1 }, { duration: 800 }); hitSoundPlaying = false; flapSoundPlaying = false; // Clear all pipes for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].destroy(); pipes.splice(i, 1); } pipeSpawnTimer = 0; // Restart menu animations LK.setTimeout(function () { titlePulse(); startBtnGlow(); floatAnimation(); }, 800); }, 2000); } }; return self; }); var Pipe = Container.expand(function (pipeX, gapY) { var self = Container.call(this); var topPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0.0, y: 0, height: gapY - 200 }); var bottomPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0.0, y: gapY + 200, height: 2732 - (gapY + 200) }); self.x = pipeX; self.speed = -4; self.scored = false; self.lastX = pipeX; self.update = function () { self.lastX = self.x; self.x += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1e3c72 }); /**** * Game Code ****/ // Game variables var bird; var pipes = []; var groundY = 2632; var pipeSpawnTimer = 0; var pipeSpawnInterval = 180; var gameStarted = false; var gameState = 'menu'; // 'menu', 'playing', 'gameover' var hitSoundPlaying = false; var flapSoundPlaying = false; // Create ground var ground = game.addChild(LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: groundY + 50 })); // Create bird bird = new Bird(); bird.x = 300; bird.y = 1366; game.addChild(bird); // Create score display var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); scoreTxt.y = 100; LK.gui.top.addChild(scoreTxt); // Create instructions var instructionTxt = new Text2('Tap to flap!', { size: 60, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0); instructionTxt.y = 300; LK.gui.top.addChild(instructionTxt); // Create menu elements var titleTxt = new Text2('Burhan Nadirin peşinde', { size: 80, fill: 0xFFD700 }); titleTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(titleTxt); titleTxt.y = -250; // Add title pulsing animation var titlePulse = function titlePulse() { tween(titleTxt, { scaleX: 1.1, scaleY: 1.1 }, { duration: 1000 }); }; titlePulse(); var startBtn = new Text2('TAP TO START', { size: 70, fill: 0x00FF7F }); startBtn.anchor.set(0.5, 0.5); LK.gui.center.addChild(startBtn); // Add start button glow effect var startBtnGlow = function startBtnGlow() { tween(startBtn, { alpha: 0.7 }, { duration: 800 }); }; startBtnGlow(); // Initialize best score var bestScore = storage.bestScore || 0; var bestScoreTxt = new Text2('Best: ' + bestScore, { size: 55, fill: 0xFFA500 }); bestScoreTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(bestScoreTxt); bestScoreTxt.y = 120; // Hide game elements initially scoreTxt.alpha = 0; instructionTxt.alpha = 0; // Add floating animations to menu elements var floatAnimation = function floatAnimation() { tween(bestScoreTxt, { y: 130 }, { duration: 2000 }); tween(startBtn, { y: 10 }, { duration: 1500 }); }; floatAnimation(); function spawnPipe() { var gapY = 800 + Math.random() * 1200; var pipe = new Pipe(2200, gapY); pipes.push(pipe); game.addChild(pipe); } ; function checkCollisions() { if (bird.isDead) return; for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; // Check if bird passes through pipe gap for scoring if (!pipe.scored && pipe.lastX > bird.x && pipe.x <= bird.x) { pipe.scored = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore().toString()); var scoreSound = LK.getSound('score'); scoreSound.play(); } // Check collision with pipes var birdBounds = { left: bird.x - 116, right: bird.x + 116, top: bird.y - 87, bottom: bird.y + 87 }; var pipeBounds = { left: pipe.x - 125, right: pipe.x + 125, top: 0, bottom: 2732 }; // Check if bird overlaps with pipe horizontally if (birdBounds.right > pipeBounds.left && birdBounds.left < pipeBounds.right) { // Check if bird is in the gap area var gapTop = pipe.children[0].height; var gapBottom = pipe.children[1].y; // If bird is not in the gap, it's a collision if (birdBounds.top < gapTop || birdBounds.bottom > gapBottom) { bird.die(); return; } } } } function cleanupPipes() { for (var i = pipes.length - 1; i >= 0; i--) { if (pipes[i].x < -200) { pipes[i].destroy(); pipes.splice(i, 1); } } } game.down = function (x, y, obj) { if (gameState === 'menu') { // Start game gameState = 'playing'; gameStarted = true; // Smooth fade out menu elements tween(titleTxt, { alpha: 0, scaleX: 0.5, scaleY: 0.5 }, { duration: 500 }); tween(startBtn, { alpha: 0, y: startBtn.y - 50 }, { duration: 500 }); tween(bestScoreTxt, { alpha: 0, y: bestScoreTxt.y + 50 }, { duration: 500 }); // Smooth fade in only score display and hide instructions tween(scoreTxt, { alpha: 1 }, { duration: 800 }); tween(instructionTxt, { alpha: 0 }, { duration: 500 }); // Reset game LK.setScore(0); scoreTxt.setText('0'); } else if (gameState === 'playing' && gameStarted) { bird.flap(); } }; game.update = function () { if (gameState !== 'playing') return; // Spawn pipes pipeSpawnTimer++; if (pipeSpawnTimer >= pipeSpawnInterval) { spawnPipe(); pipeSpawnTimer = 0; } // Check collisions and scoring checkCollisions(); // Clean up off-screen pipes cleanupPipes(); };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdSprite = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 0;
self.gravity = 0.8;
self.flapStrength = -12;
self.isDead = false;
self.lastY = 0;
self.flap = function () {
if (!self.isDead && gameStarted && !flapSoundPlaying) {
self.velocityY = self.flapStrength;
flapSoundPlaying = true;
var flapSound = LK.getSound('flap');
flapSound.play();
// Reset flap sound state when sound ends (approximate duration)
LK.setTimeout(function () {
flapSoundPlaying = false;
}, 200);
}
};
self.update = function () {
if (!self.isDead) {
self.lastY = self.y;
self.velocityY += self.gravity;
self.y += self.velocityY;
// Rotate bird based on velocity
birdSprite.rotation = Math.max(-0.5, Math.min(0.5, self.velocityY * 0.1));
// Check ground collision
if (self.y > groundY - 40) {
self.y = groundY - 40;
self.die();
}
// Check ceiling collision
if (self.y < 40) {
self.y = 40;
self.velocityY = 0;
}
}
};
self.die = function () {
if (!self.isDead) {
self.isDead = true;
if (!hitSoundPlaying) {
hitSoundPlaying = true;
var hitSound = LK.getSound('hit');
hitSound.play();
}
gameState = 'gameover';
// Update best score
var currentScore = LK.getScore();
if (currentScore > bestScore) {
bestScore = currentScore;
storage.bestScore = bestScore;
bestScoreTxt.setText('Best: ' + bestScore);
}
LK.setTimeout(function () {
// Reset game state to menu
gameState = 'menu';
gameStarted = false;
self.isDead = false;
self.velocityY = 0;
self.y = 1366;
// Smooth fade out only score display
tween(scoreTxt, {
alpha: 0
}, {
duration: 500
});
// Smooth fade in menu elements with scale animation
tween(titleTxt, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 800
});
tween(startBtn, {
alpha: 1,
y: 0
}, {
duration: 800
});
tween(bestScoreTxt, {
alpha: 1,
y: 120
}, {
duration: 800
});
tween(instructionTxt, {
alpha: 1
}, {
duration: 800
});
hitSoundPlaying = false;
flapSoundPlaying = false;
// Clear all pipes
for (var i = pipes.length - 1; i >= 0; i--) {
pipes[i].destroy();
pipes.splice(i, 1);
}
pipeSpawnTimer = 0;
// Restart menu animations
LK.setTimeout(function () {
titlePulse();
startBtnGlow();
floatAnimation();
}, 800);
}, 2000);
}
};
return self;
});
var Pipe = Container.expand(function (pipeX, gapY) {
var self = Container.call(this);
var topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0.0,
y: 0,
height: gapY - 200
});
var bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0.0,
y: gapY + 200,
height: 2732 - (gapY + 200)
});
self.x = pipeX;
self.speed = -4;
self.scored = false;
self.lastX = pipeX;
self.update = function () {
self.lastX = self.x;
self.x += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1e3c72
});
/****
* Game Code
****/
// Game variables
var bird;
var pipes = [];
var groundY = 2632;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 180;
var gameStarted = false;
var gameState = 'menu'; // 'menu', 'playing', 'gameover'
var hitSoundPlaying = false;
var flapSoundPlaying = false;
// Create ground
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: groundY + 50
}));
// Create bird
bird = new Bird();
bird.x = 300;
bird.y = 1366;
game.addChild(bird);
// Create score display
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.y = 100;
LK.gui.top.addChild(scoreTxt);
// Create instructions
var instructionTxt = new Text2('Tap to flap!', {
size: 60,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0);
instructionTxt.y = 300;
LK.gui.top.addChild(instructionTxt);
// Create menu elements
var titleTxt = new Text2('Burhan Nadirin peşinde', {
size: 80,
fill: 0xFFD700
});
titleTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(titleTxt);
titleTxt.y = -250;
// Add title pulsing animation
var titlePulse = function titlePulse() {
tween(titleTxt, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1000
});
};
titlePulse();
var startBtn = new Text2('TAP TO START', {
size: 70,
fill: 0x00FF7F
});
startBtn.anchor.set(0.5, 0.5);
LK.gui.center.addChild(startBtn);
// Add start button glow effect
var startBtnGlow = function startBtnGlow() {
tween(startBtn, {
alpha: 0.7
}, {
duration: 800
});
};
startBtnGlow();
// Initialize best score
var bestScore = storage.bestScore || 0;
var bestScoreTxt = new Text2('Best: ' + bestScore, {
size: 55,
fill: 0xFFA500
});
bestScoreTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(bestScoreTxt);
bestScoreTxt.y = 120;
// Hide game elements initially
scoreTxt.alpha = 0;
instructionTxt.alpha = 0;
// Add floating animations to menu elements
var floatAnimation = function floatAnimation() {
tween(bestScoreTxt, {
y: 130
}, {
duration: 2000
});
tween(startBtn, {
y: 10
}, {
duration: 1500
});
};
floatAnimation();
function spawnPipe() {
var gapY = 800 + Math.random() * 1200;
var pipe = new Pipe(2200, gapY);
pipes.push(pipe);
game.addChild(pipe);
}
;
function checkCollisions() {
if (bird.isDead) return;
for (var i = 0; i < pipes.length; i++) {
var pipe = pipes[i];
// Check if bird passes through pipe gap for scoring
if (!pipe.scored && pipe.lastX > bird.x && pipe.x <= bird.x) {
pipe.scored = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore().toString());
var scoreSound = LK.getSound('score');
scoreSound.play();
}
// Check collision with pipes
var birdBounds = {
left: bird.x - 116,
right: bird.x + 116,
top: bird.y - 87,
bottom: bird.y + 87
};
var pipeBounds = {
left: pipe.x - 125,
right: pipe.x + 125,
top: 0,
bottom: 2732
};
// Check if bird overlaps with pipe horizontally
if (birdBounds.right > pipeBounds.left && birdBounds.left < pipeBounds.right) {
// Check if bird is in the gap area
var gapTop = pipe.children[0].height;
var gapBottom = pipe.children[1].y;
// If bird is not in the gap, it's a collision
if (birdBounds.top < gapTop || birdBounds.bottom > gapBottom) {
bird.die();
return;
}
}
}
}
function cleanupPipes() {
for (var i = pipes.length - 1; i >= 0; i--) {
if (pipes[i].x < -200) {
pipes[i].destroy();
pipes.splice(i, 1);
}
}
}
game.down = function (x, y, obj) {
if (gameState === 'menu') {
// Start game
gameState = 'playing';
gameStarted = true;
// Smooth fade out menu elements
tween(titleTxt, {
alpha: 0,
scaleX: 0.5,
scaleY: 0.5
}, {
duration: 500
});
tween(startBtn, {
alpha: 0,
y: startBtn.y - 50
}, {
duration: 500
});
tween(bestScoreTxt, {
alpha: 0,
y: bestScoreTxt.y + 50
}, {
duration: 500
});
// Smooth fade in only score display and hide instructions
tween(scoreTxt, {
alpha: 1
}, {
duration: 800
});
tween(instructionTxt, {
alpha: 0
}, {
duration: 500
});
// Reset game
LK.setScore(0);
scoreTxt.setText('0');
} else if (gameState === 'playing' && gameStarted) {
bird.flap();
}
};
game.update = function () {
if (gameState !== 'playing') return;
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Check collisions and scoring
checkCollisions();
// Clean up off-screen pipes
cleanupPipes();
};