User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'alpha')' in or related to this line: 'scoreTxt.alpha = 0;' Line Number: 132
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'bestScoreTxt.setText('Best: ' + bestScore);' Line Number: 128
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var bestScore = storage.get('bestScore') || 0;' Line Number: 126 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Bir başlangıç ve bitiş menüsü yap
User prompt
Birazdaha boruları uzat tam tavana gelsin
User prompt
Boruların boyunu uzat tam tavana ve zemine denk gelsin
User prompt
Borular arasındaki mesafeyi biraz daha artır ve kalınlaşma uygula
User prompt
Borular arasındaki mesafeyi artır
User prompt
Kuş arasından geçmiyor onu düzelt
User prompt
Stünlar arasındaki boşluğu artır ve tam olsun
User prompt
Bir Flappy bird oyunu yap
Code edit (1 edits merged)
Please save this source code
User prompt
Perfect Ring Drop
Initial prompt
İşaret parmağını bir delikten geçir o delikte vajina olsun
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Bird = Container.expand(function (birdType) { var self = Container.call(this); var assetName = birdType || 'bird'; self.birdType = assetName; // Track which bird type this is var birdSprite = self.attachAsset(assetName, { 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.volume = 0.01 * soundVolume; 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.volume = 0.3 * soundVolume; 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; // Replace Bird2 with original bird when it dies if (self.birdType === 'Bird2') { var oldX = self.x; var oldY = self.y; var oldVelocityY = self.velocityY; var oldIsDead = self.isDead; // Remove current bird self.destroy(); // Create new original bird bird = new Bird('bird'); bird.birdType = 'bird'; bird.x = oldX; bird.y = oldY; bird.velocityY = oldVelocityY; bird.isDead = oldIsDead; game.addChild(bird); } // Reset to original bird type when Bird2 dies self.birdType = 'bird'; // Smooth fade out only score display tween(scoreTxt, { alpha: 0 }, { duration: 500 }); tween(levelTxt, { 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 }); tween(settingsBtn, { alpha: 1, y: 200 }, { 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; // Clean up scrolling text if (currentScrollingText) { currentScrollingText.destroy(); currentScrollingText = null; } scrollingTextTimer = 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 - 350 }); var bottomPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0.0, y: gapY + 350, height: 2732 - (gapY + 350) }); 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; var currentLevel = 1; var scoresPerLevel = 10; // Points needed to advance to next level // Scrolling text variables var scrollingMessages = [" ne bakiyon oyun iste amcik !", "sikiş başliyor hazir mısın?", "Nadir:arda cok seksi?", "taytyirtan5643!", "Dostluk her yatalakı sokar!", "Burhan ve Nadir ve haykocepkin!", "apo kürtmü?", "İkiniz de birsik olmazsınız!"]; var scrollingTextTimer = 0; var scrollingTextInterval = 600; // Show every 10 seconds during gameplay var currentScrollingText = null; // 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.birdType = 'bird'; // Track that we start with the original 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 level display var levelTxt = new Text2('Level 1', { size: 60, fill: 0xFFD700 }); levelTxt.anchor.set(0.5, 0); levelTxt.y = 200; levelTxt.alpha = 0; LK.gui.top.addChild(levelTxt); // Create instructions var instructionTxt = new Text2('Burhanı Nadire götür!', { 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 & Nadir Macerası', { 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); startBtn.alpha = 0; 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; // Create settings button var settingsBtn = new Text2('SETTINGS', { size: 60, fill: 0xFFFFFF }); settingsBtn.anchor.set(0.5, 0.5); LK.gui.center.addChild(settingsBtn); settingsBtn.y = 200; // Game settings variables var showingSettings = false; var soundVolume = storage.soundVolume || 1.0; // Settings panel elements var settingsPanel = new Container(); LK.gui.center.addChild(settingsPanel); settingsPanel.alpha = 0; var settingsTitle = new Text2('SETTINGS', { size: 70, fill: 0xFFD700 }); settingsTitle.anchor.set(0.5, 0.5); settingsPanel.addChild(settingsTitle); settingsTitle.y = -150; var volumeText = new Text2('Volume: ' + Math.round(soundVolume * 100) + '%', { size: 50, fill: 0xFFFFFF }); volumeText.anchor.set(0.5, 0.5); settingsPanel.addChild(volumeText); volumeText.y = -50; var volumeDownBtn = new Text2('[-]', { size: 60, fill: 0x00FF7F }); volumeDownBtn.anchor.set(0.5, 0.5); settingsPanel.addChild(volumeDownBtn); volumeDownBtn.x = -150; volumeDownBtn.y = 20; var volumeUpBtn = new Text2('[+]', { size: 60, fill: 0x00FF7F }); volumeUpBtn.anchor.set(0.5, 0.5); settingsPanel.addChild(volumeUpBtn); volumeUpBtn.x = 150; volumeUpBtn.y = 20; var backBtn = new Text2('BACK', { size: 50, fill: 0xFFA500 }); backBtn.anchor.set(0.5, 0.5); settingsPanel.addChild(backBtn); backBtn.y = 100; // 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 }); tween(settingsBtn, { y: 210 }, { duration: 1800 }); }; floatAnimation(); // Function to create scrolling text function createScrollingText() { if (currentScrollingText) { return; } // Don't create if one is already active var randomMessage = scrollingMessages[Math.floor(Math.random() * scrollingMessages.length)]; currentScrollingText = new Text2(randomMessage, { size: 70, fill: 0xFFD700 }); currentScrollingText.anchor.set(0.5, 0.5); currentScrollingText.x = 2200; // Start from right edge currentScrollingText.y = 400 + Math.random() * 800; // Random height currentScrollingText.alpha = 0.8; game.addChild(currentScrollingText); // Animate scrolling from right to left tween(currentScrollingText, { x: -400 // Move to left edge }, { duration: 4000, // 4 seconds to cross screen onFinish: function onFinish() { if (currentScrollingText) { currentScrollingText.destroy(); currentScrollingText = null; } } }); } // Settings button glow effect var settingsBtnGlow = function settingsBtnGlow() { tween(settingsBtn, { alpha: 0.7 }, { duration: 900 }); }; settingsBtnGlow(); function spawnPipe() { var gapY = 600 + Math.random() * 1200; // Increased gap range to make game easier 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()); // Switch to new bird when score reaches 5 (only if still using original bird) if (LK.getScore() === 5 && bird.birdType !== 'Bird2') { var oldX = bird.x; var oldY = bird.y; var oldVelocityY = bird.velocityY; var oldIsDead = bird.isDead; // Remove old bird bird.destroy(); // Create new bird with Bird2 sprite bird = new Bird('Bird2'); bird.birdType = 'Bird2'; // Track which bird type we're using bird.x = oldX; bird.y = oldY; bird.velocityY = oldVelocityY; bird.isDead = oldIsDead; game.addChild(bird); // Flash effect for bird change and show transformation message LK.effects.flashScreen(0xFFD700, 500); // Show transformation message var transformMsg = new Text2('noluyo lan!', { size: 80, fill: 0xFFD700 }); transformMsg.anchor.set(0.5, 0.5); LK.gui.center.addChild(transformMsg); transformMsg.y = 0; // Fade out message after 2 seconds LK.setTimeout(function () { tween(transformMsg, { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { transformMsg.destroy(); } }); }, 2000); } // Win condition at score 10 if (LK.getScore() === 10) { // Create win message var winMessage = new Text2('YARRRRRRAK!', { size: 100, fill: 0xFFD700 }); winMessage.anchor.set(0.5, 0.5); LK.gui.center.addChild(winMessage); winMessage.y = -100; var subMessage = new Text2('Burhan ve Nadir ciftleşti!', { size: 60, fill: 0x00FF7F }); subMessage.anchor.set(0.5, 0.5); LK.gui.center.addChild(subMessage); subMessage.y = 50; // Flash screen gold LK.effects.flashScreen(0xFFD700, 2000); // Stop the game gameState = 'gameover'; bird.isDead = true; // Clean up after showing message LK.setTimeout(function () { winMessage.destroy(); subMessage.destroy(); LK.showYouWin(); }, 3000); return; } var scoreSound = LK.getSound('score'); scoreSound.volume = soundVolume; 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' && !showingSettings) { // Convert touch coordinates to GUI center space for settings button var guiPos = LK.gui.center.toLocal({ x: x, y: y }); if (Math.abs(guiPos.x - settingsBtn.x) < 100 && Math.abs(guiPos.y - settingsBtn.y) < 40) { // Show settings showingSettings = true; tween(titleTxt, { alpha: 0 }, { duration: 300 }); tween(startBtn, { alpha: 0 }, { duration: 300 }); tween(bestScoreTxt, { alpha: 0 }, { duration: 300 }); tween(settingsBtn, { alpha: 0 }, { duration: 300 }); tween(settingsPanel, { alpha: 1 }, { duration: 500 }); return; } // 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 }); tween(settingsBtn, { alpha: 0, y: settingsBtn.y + 50 }, { duration: 500 }); // Smooth fade in only score display and hide instructions tween(scoreTxt, { alpha: 1 }, { duration: 800 }); tween(levelTxt, { alpha: 1 }, { duration: 800 }); tween(instructionTxt, { alpha: 0 }, { duration: 500 }); // Reset game LK.setScore(0); scoreTxt.setText('0'); currentLevel = 1; levelTxt.setText('Level 1'); } else if (gameState === 'menu' && showingSettings) { // Handle settings interactions - convert coordinates to settings panel space var panelPos = settingsPanel.toLocal({ x: x, y: y }); // Volume down button if (Math.abs(panelPos.x - volumeDownBtn.x) < 60 && Math.abs(panelPos.y - volumeDownBtn.y) < 40) { soundVolume = Math.max(0, soundVolume - 0.1); soundVolume = Math.round(soundVolume * 10) / 10; // Round to 1 decimal place storage.soundVolume = soundVolume; volumeText.setText('Volume: ' + Math.round(soundVolume * 100) + '%'); // Play test sound at new volume var testSound = LK.getSound('flap'); testSound.volume = 0.01 * soundVolume; testSound.play(); } // Volume up button else if (Math.abs(panelPos.x - volumeUpBtn.x) < 60 && Math.abs(panelPos.y - volumeUpBtn.y) < 40) { soundVolume = Math.min(1, soundVolume + 0.1); soundVolume = Math.round(soundVolume * 10) / 10; // Round to 1 decimal place storage.soundVolume = soundVolume; volumeText.setText('Volume: ' + Math.round(soundVolume * 100) + '%'); // Play test sound at new volume var testSound = LK.getSound('flap'); testSound.volume = 0.01 * soundVolume; testSound.play(); } // Back button else if (Math.abs(panelPos.x - backBtn.x) < 80 && Math.abs(panelPos.y - backBtn.y) < 40) { showingSettings = false; tween(settingsPanel, { alpha: 0 }, { duration: 300 }); tween(titleTxt, { alpha: 1 }, { duration: 500 }); tween(startBtn, { alpha: 1 }, { duration: 500 }); tween(bestScoreTxt, { alpha: 1 }, { duration: 500 }); tween(settingsBtn, { alpha: 1 }, { duration: 500 }); } } else if (gameState === 'playing' && gameStarted) { bird.flap(); } }; game.update = function () { if (gameState !== 'playing') { return; } // Spawn pipes pipeSpawnTimer++; if (pipeSpawnTimer >= pipeSpawnInterval) { spawnPipe(); pipeSpawnTimer = 0; } // Handle scrolling text scrollingTextTimer++; if (scrollingTextTimer >= scrollingTextInterval) { createScrollingText(); scrollingTextTimer = 0; // Randomize next interval between 5-15 seconds scrollingTextInterval = 300 + Math.random() * 600; } // 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 (birdType) {
var self = Container.call(this);
var assetName = birdType || 'bird';
self.birdType = assetName; // Track which bird type this is
var birdSprite = self.attachAsset(assetName, {
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.volume = 0.01 * soundVolume;
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.volume = 0.3 * soundVolume;
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;
// Replace Bird2 with original bird when it dies
if (self.birdType === 'Bird2') {
var oldX = self.x;
var oldY = self.y;
var oldVelocityY = self.velocityY;
var oldIsDead = self.isDead;
// Remove current bird
self.destroy();
// Create new original bird
bird = new Bird('bird');
bird.birdType = 'bird';
bird.x = oldX;
bird.y = oldY;
bird.velocityY = oldVelocityY;
bird.isDead = oldIsDead;
game.addChild(bird);
}
// Reset to original bird type when Bird2 dies
self.birdType = 'bird';
// Smooth fade out only score display
tween(scoreTxt, {
alpha: 0
}, {
duration: 500
});
tween(levelTxt, {
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
});
tween(settingsBtn, {
alpha: 1,
y: 200
}, {
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;
// Clean up scrolling text
if (currentScrollingText) {
currentScrollingText.destroy();
currentScrollingText = null;
}
scrollingTextTimer = 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 - 350
});
var bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0.0,
y: gapY + 350,
height: 2732 - (gapY + 350)
});
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;
var currentLevel = 1;
var scoresPerLevel = 10; // Points needed to advance to next level
// Scrolling text variables
var scrollingMessages = [" ne bakiyon oyun iste amcik !", "sikiş başliyor hazir mısın?", "Nadir:arda cok seksi?", "taytyirtan5643!", "Dostluk her yatalakı sokar!", "Burhan ve Nadir ve haykocepkin!", "apo kürtmü?", "İkiniz de birsik olmazsınız!"];
var scrollingTextTimer = 0;
var scrollingTextInterval = 600; // Show every 10 seconds during gameplay
var currentScrollingText = null;
// 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.birdType = 'bird'; // Track that we start with the original 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 level display
var levelTxt = new Text2('Level 1', {
size: 60,
fill: 0xFFD700
});
levelTxt.anchor.set(0.5, 0);
levelTxt.y = 200;
levelTxt.alpha = 0;
LK.gui.top.addChild(levelTxt);
// Create instructions
var instructionTxt = new Text2('Burhanı Nadire götür!', {
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 & Nadir Macerası', {
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);
startBtn.alpha = 0;
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;
// Create settings button
var settingsBtn = new Text2('SETTINGS', {
size: 60,
fill: 0xFFFFFF
});
settingsBtn.anchor.set(0.5, 0.5);
LK.gui.center.addChild(settingsBtn);
settingsBtn.y = 200;
// Game settings variables
var showingSettings = false;
var soundVolume = storage.soundVolume || 1.0;
// Settings panel elements
var settingsPanel = new Container();
LK.gui.center.addChild(settingsPanel);
settingsPanel.alpha = 0;
var settingsTitle = new Text2('SETTINGS', {
size: 70,
fill: 0xFFD700
});
settingsTitle.anchor.set(0.5, 0.5);
settingsPanel.addChild(settingsTitle);
settingsTitle.y = -150;
var volumeText = new Text2('Volume: ' + Math.round(soundVolume * 100) + '%', {
size: 50,
fill: 0xFFFFFF
});
volumeText.anchor.set(0.5, 0.5);
settingsPanel.addChild(volumeText);
volumeText.y = -50;
var volumeDownBtn = new Text2('[-]', {
size: 60,
fill: 0x00FF7F
});
volumeDownBtn.anchor.set(0.5, 0.5);
settingsPanel.addChild(volumeDownBtn);
volumeDownBtn.x = -150;
volumeDownBtn.y = 20;
var volumeUpBtn = new Text2('[+]', {
size: 60,
fill: 0x00FF7F
});
volumeUpBtn.anchor.set(0.5, 0.5);
settingsPanel.addChild(volumeUpBtn);
volumeUpBtn.x = 150;
volumeUpBtn.y = 20;
var backBtn = new Text2('BACK', {
size: 50,
fill: 0xFFA500
});
backBtn.anchor.set(0.5, 0.5);
settingsPanel.addChild(backBtn);
backBtn.y = 100;
// 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
});
tween(settingsBtn, {
y: 210
}, {
duration: 1800
});
};
floatAnimation();
// Function to create scrolling text
function createScrollingText() {
if (currentScrollingText) {
return;
} // Don't create if one is already active
var randomMessage = scrollingMessages[Math.floor(Math.random() * scrollingMessages.length)];
currentScrollingText = new Text2(randomMessage, {
size: 70,
fill: 0xFFD700
});
currentScrollingText.anchor.set(0.5, 0.5);
currentScrollingText.x = 2200; // Start from right edge
currentScrollingText.y = 400 + Math.random() * 800; // Random height
currentScrollingText.alpha = 0.8;
game.addChild(currentScrollingText);
// Animate scrolling from right to left
tween(currentScrollingText, {
x: -400 // Move to left edge
}, {
duration: 4000,
// 4 seconds to cross screen
onFinish: function onFinish() {
if (currentScrollingText) {
currentScrollingText.destroy();
currentScrollingText = null;
}
}
});
}
// Settings button glow effect
var settingsBtnGlow = function settingsBtnGlow() {
tween(settingsBtn, {
alpha: 0.7
}, {
duration: 900
});
};
settingsBtnGlow();
function spawnPipe() {
var gapY = 600 + Math.random() * 1200; // Increased gap range to make game easier
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());
// Switch to new bird when score reaches 5 (only if still using original bird)
if (LK.getScore() === 5 && bird.birdType !== 'Bird2') {
var oldX = bird.x;
var oldY = bird.y;
var oldVelocityY = bird.velocityY;
var oldIsDead = bird.isDead;
// Remove old bird
bird.destroy();
// Create new bird with Bird2 sprite
bird = new Bird('Bird2');
bird.birdType = 'Bird2'; // Track which bird type we're using
bird.x = oldX;
bird.y = oldY;
bird.velocityY = oldVelocityY;
bird.isDead = oldIsDead;
game.addChild(bird);
// Flash effect for bird change and show transformation message
LK.effects.flashScreen(0xFFD700, 500);
// Show transformation message
var transformMsg = new Text2('noluyo lan!', {
size: 80,
fill: 0xFFD700
});
transformMsg.anchor.set(0.5, 0.5);
LK.gui.center.addChild(transformMsg);
transformMsg.y = 0;
// Fade out message after 2 seconds
LK.setTimeout(function () {
tween(transformMsg, {
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
transformMsg.destroy();
}
});
}, 2000);
}
// Win condition at score 10
if (LK.getScore() === 10) {
// Create win message
var winMessage = new Text2('YARRRRRRAK!', {
size: 100,
fill: 0xFFD700
});
winMessage.anchor.set(0.5, 0.5);
LK.gui.center.addChild(winMessage);
winMessage.y = -100;
var subMessage = new Text2('Burhan ve Nadir ciftleşti!', {
size: 60,
fill: 0x00FF7F
});
subMessage.anchor.set(0.5, 0.5);
LK.gui.center.addChild(subMessage);
subMessage.y = 50;
// Flash screen gold
LK.effects.flashScreen(0xFFD700, 2000);
// Stop the game
gameState = 'gameover';
bird.isDead = true;
// Clean up after showing message
LK.setTimeout(function () {
winMessage.destroy();
subMessage.destroy();
LK.showYouWin();
}, 3000);
return;
}
var scoreSound = LK.getSound('score');
scoreSound.volume = soundVolume;
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' && !showingSettings) {
// Convert touch coordinates to GUI center space for settings button
var guiPos = LK.gui.center.toLocal({
x: x,
y: y
});
if (Math.abs(guiPos.x - settingsBtn.x) < 100 && Math.abs(guiPos.y - settingsBtn.y) < 40) {
// Show settings
showingSettings = true;
tween(titleTxt, {
alpha: 0
}, {
duration: 300
});
tween(startBtn, {
alpha: 0
}, {
duration: 300
});
tween(bestScoreTxt, {
alpha: 0
}, {
duration: 300
});
tween(settingsBtn, {
alpha: 0
}, {
duration: 300
});
tween(settingsPanel, {
alpha: 1
}, {
duration: 500
});
return;
}
// 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
});
tween(settingsBtn, {
alpha: 0,
y: settingsBtn.y + 50
}, {
duration: 500
});
// Smooth fade in only score display and hide instructions
tween(scoreTxt, {
alpha: 1
}, {
duration: 800
});
tween(levelTxt, {
alpha: 1
}, {
duration: 800
});
tween(instructionTxt, {
alpha: 0
}, {
duration: 500
});
// Reset game
LK.setScore(0);
scoreTxt.setText('0');
currentLevel = 1;
levelTxt.setText('Level 1');
} else if (gameState === 'menu' && showingSettings) {
// Handle settings interactions - convert coordinates to settings panel space
var panelPos = settingsPanel.toLocal({
x: x,
y: y
});
// Volume down button
if (Math.abs(panelPos.x - volumeDownBtn.x) < 60 && Math.abs(panelPos.y - volumeDownBtn.y) < 40) {
soundVolume = Math.max(0, soundVolume - 0.1);
soundVolume = Math.round(soundVolume * 10) / 10; // Round to 1 decimal place
storage.soundVolume = soundVolume;
volumeText.setText('Volume: ' + Math.round(soundVolume * 100) + '%');
// Play test sound at new volume
var testSound = LK.getSound('flap');
testSound.volume = 0.01 * soundVolume;
testSound.play();
}
// Volume up button
else if (Math.abs(panelPos.x - volumeUpBtn.x) < 60 && Math.abs(panelPos.y - volumeUpBtn.y) < 40) {
soundVolume = Math.min(1, soundVolume + 0.1);
soundVolume = Math.round(soundVolume * 10) / 10; // Round to 1 decimal place
storage.soundVolume = soundVolume;
volumeText.setText('Volume: ' + Math.round(soundVolume * 100) + '%');
// Play test sound at new volume
var testSound = LK.getSound('flap');
testSound.volume = 0.01 * soundVolume;
testSound.play();
}
// Back button
else if (Math.abs(panelPos.x - backBtn.x) < 80 && Math.abs(panelPos.y - backBtn.y) < 40) {
showingSettings = false;
tween(settingsPanel, {
alpha: 0
}, {
duration: 300
});
tween(titleTxt, {
alpha: 1
}, {
duration: 500
});
tween(startBtn, {
alpha: 1
}, {
duration: 500
});
tween(bestScoreTxt, {
alpha: 1
}, {
duration: 500
});
tween(settingsBtn, {
alpha: 1
}, {
duration: 500
});
}
} else if (gameState === 'playing' && gameStarted) {
bird.flap();
}
};
game.update = function () {
if (gameState !== 'playing') {
return;
}
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Handle scrolling text
scrollingTextTimer++;
if (scrollingTextTimer >= scrollingTextInterval) {
createScrollingText();
scrollingTextTimer = 0;
// Randomize next interval between 5-15 seconds
scrollingTextInterval = 300 + Math.random() * 600;
}
// Check collisions and scoring
checkCollisions();
// Clean up off-screen pipes
cleanupPipes();
};