/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1"); var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bird = Container.expand(function (birdType, costumeId) { var self = Container.call(this); // Default to 'bird' if not specified var assetId = birdType === 'bird2' ? 'bird2' : 'bird'; var birdGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // Costume overlay logic if (typeof costumeId !== "number") costumeId = 0; self.costumeSprites = []; // Use new costume images for overlays if (costumeId === 1) { // Crown var crown = LK.getAsset('costume_crown', { anchorX: 0.5, anchorY: 1 }); crown.x = 0; // Move the crown VERY high for in-game bird crown.y = -birdGraphics.height * 1.2; self.addChild(crown); self.costumeSprites.push(crown); } if (costumeId === 2) { // Glasses var glasses = LK.getAsset('costume_glasses', { anchorX: 0.5, anchorY: 0.5 }); glasses.x = 0; glasses.y = -birdGraphics.height * 0.05; self.addChild(glasses); self.costumeSprites.push(glasses); } if (costumeId === 3) { // Mustache var mustache = LK.getAsset('costume_mustache', { anchorX: 0.5, anchorY: 0.5 }); mustache.x = 0; mustache.y = birdGraphics.height * 0.29; self.addChild(mustache); self.costumeSprites.push(mustache); } if (costumeId === 4) { // Beard var beard = LK.getAsset('costume_beard', { anchorX: 0.5, anchorY: 0.5 }); beard.x = 0; // Move the beard VERY low for in-game bird beard.y = birdGraphics.height * 1.1; self.addChild(beard); self.costumeSprites.push(beard); } if (costumeId === 5) { // Hat var hat = LK.getAsset('costume_hat', { anchorX: 0.5, anchorY: 1 }); hat.x = 0; hat.y = -birdGraphics.height * 0.95; self.addChild(hat); self.costumeSprites.push(hat); } if (costumeId === 6) { // Randomly select one of three flowers var flowerAssets = ['costume_flower1', 'costume_flower2', 'costume_flower3']; var flowerIndex = Math.floor(Math.random() * 3); var flowerId = flowerAssets[flowerIndex]; var flower = LK.getAsset(flowerId, { anchorX: 0.1, anchorY: 0.7 }); // Place flower further right and further down for default facing right flower.x = birdGraphics.width * 0.65; flower.y = birdGraphics.height * 0.35; self.addChild(flower); self.costumeSprites.push(flower); // Save reference for flipping self.roseSprite = flower; } self.xSpeed = 10.9375; self.ySpeed = -20; self.gravity = 1; self.lift = -15; self.flap = function () { self.ySpeed = self.lift * 1.5; LK.getSound('flap').play(); }; self._update_migrated = function () { if (game.isMouseDown) { self.ySpeed += self.gravity / 3; } else { self.ySpeed += self.gravity; } self.y += self.ySpeed; self.x += self.xSpeed; if (self.y <= 0 || self.y >= 2732) { self.speed = -self.speed; } var targetRotation = Math.atan2(self.ySpeed, self.xSpeed * self.scale.x) / 2; birdGraphics.rotation += (targetRotation - birdGraphics.rotation) / 10; // Make all costume overlays follow the bird's position, scale, and rotation exactly if (self.costumeSprites && self.costumeSprites.length) { for (var i = 0; i < self.costumeSprites.length; i++) { var sprite = self.costumeSprites[i]; // Always keep overlays at (0,0) relative to bird, so they move with the bird sprite.x = 0; sprite.y = 0; // Match scale and rotation to birdGraphics sprite.scale.x = birdGraphics.scale.x; sprite.scale.y = birdGraphics.scale.y; sprite.rotation = birdGraphics.rotation; } } }; self.flip = function () { self.scale.x *= -1; // If rose costume is active, mirror its x position to the other cheek if (self.roseSprite) { // If facing right, rose on right cheek; if facing left, rose on left cheek self.roseSprite.x = self.scale.x > 0 ? birdGraphics.width * 0.45 : -birdGraphics.width * 0.45; } }; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleShadow = self.attachAsset('obstacleShadow', { anchorX: 0.5, anchorY: 0.5 }); obstacleShadow.rotation = Math.PI / 4; var obstacleShadow2 = self.attachAsset('obstacleShadow2', { anchorX: 0.5, anchorY: 0.5 }); obstacleShadow2.rotation = Math.PI / 4; obstacleShadow2.y = -7; var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); obstacleGraphics.rotation = Math.PI / 4; self.speed = 5; self._move_migrated = function (speed) { self.y += speed; }; }); var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Costume image assets (replace id values with your own images in the asset manager) // Tutorial text will be created and added only after the game starts (see startGameWithSelectedBird) var tutorialTextWhite = null; var tutorialText = null; game.score = 0; game.obstacleSpeed = 5; // Default value, will be overwritten by selection screen game.obstacleSpeedIncrease = 0.005; game.checkObstacleCollision = function (obstacles) { for (var i = 0; i < obstacles.length; i++) { obstacles[i]._move_migrated(); var dist = Math.sqrt(Math.pow(bird.x - obstacles[i].x, 2) + Math.pow(bird.y - obstacles[i].y, 2)); if (dist < 280) { LK.setScore(game.score); LK.getSound('gameOverJingle').play(); LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { LK.showGameOver(); }, 2700); //{W} // Set to 2.7 seconds return; } } }; game.setBackgroundColor(0xffe0f0); // very light pink background var record = typeof storage.record === 'number' ? storage.record : 0; var scoreText = new Text2('0', { size: 150, fill: '#e75480', //{V} // vivid pink font: 'Impact', dropShadow: true, dropShadowColor: '#ffb6e6', //{Y} // light pink shadow dropShadowBlur: 5, dropShadowDistance: 7, dropShadowAngle: 0 }); scoreText.anchor.set(.5, 0); LK.gui.top.addChild(scoreText); var scoreText2 = new Text2('0', { size: 150, fill: '#ffb6e6', //{14} // light pink font: 'Impact' }); scoreText2.anchor.set(.5, 0); scoreText2.x = -4; scoreText2.y = -5; LK.gui.top.addChild(scoreText2); // Record (high score) text var recordText = new Text2('REKOR: ' + record, { size: 80, fill: '#e75480', font: 'Impact', dropShadow: true, dropShadowColor: '#ffb6e6', dropShadowBlur: 5, dropShadowDistance: 7, dropShadowAngle: 0 }); recordText.anchor.set(0.5, 0); recordText.y = 140; LK.gui.top.addChild(recordText); LK.gui.top.addChild(scoreText); // Character select state var characterSelected = false; var selectedBirdType = null; var bird = null; // --- Motivational Text for Selection Screen --- // Always show motivational text under record text on selection screen var motivationalText = new Text2("Rekoru geçiceksiiinn sana güveniyoruummm", { size: 60, fill: '#e75480', font: 'Impact', align: 'center', dropShadow: true, dropShadowColor: '#ffb6e6', dropShadowBlur: 5, dropShadowDistance: 7, dropShadowAngle: 0 }); motivationalText.anchor.set(0.5, 0); // Place under recordText (recordText.y + recordText.height + margin) motivationalText.x = 0; motivationalText.y = 140 + 90; // recordText.y + recordText.height (approx) + margin LK.gui.top.addChild(motivationalText); // Create character select UI var selectText = new Text2('Hangimizle oynamak istersin', { size: 80, fill: '#e75480', //{17} // vivid pink font: 'Impact', align: 'center' }); selectText.anchor.set(0.5, 1); selectText.x = 0; selectText.y = -200; LK.gui.center.addChild(selectText); // --- Speed selection UI (Top Right) --- var speedOptions = [{ label: "Yavaş", value: 0.003 }, { label: "Normal", value: 0.005 }, { label: "Hızlı", value: 0.009 }]; var selectedSpeedIndex = 1; // Default to "Normal" // Small speed display at top right var speedDisplayText = new Text2('Hız: ' + speedOptions[selectedSpeedIndex].label, { size: 60, fill: '#e75480', font: 'Impact', align: 'center' }); speedDisplayText.anchor.set(1, 0); // Top right speedDisplayText.x = -40; // Padding from right edge speedDisplayText.y = 20; speedDisplayText.interactive = true; LK.gui.topRight.addChild(speedDisplayText); // Add left/right arrows for speed selection var speedLeftArrow = new Text2('<', { size: 60, fill: '#e75480', font: 'Impact' }); speedLeftArrow.anchor.set(1, 0); speedLeftArrow.x = -170; speedLeftArrow.y = 20; speedLeftArrow.interactive = true; LK.gui.topRight.addChild(speedLeftArrow); var speedRightArrow = new Text2('>', { size: 60, fill: '#e75480', font: 'Impact' }); speedRightArrow.anchor.set(1, 0); speedRightArrow.x = 0; speedRightArrow.y = 20; speedRightArrow.interactive = true; LK.gui.topRight.addChild(speedRightArrow); function updateSpeedDisplay() { speedDisplayText.setText('Hız: ' + speedOptions[selectedSpeedIndex].label); } // Only allow speed change before character is selected speedLeftArrow.down = function () { if (characterSelected) return; if (selectedSpeedIndex > 0) { selectedSpeedIndex--; updateSpeedDisplay(); } }; speedRightArrow.down = function () { if (characterSelected) return; if (selectedSpeedIndex < speedOptions.length - 1) { selectedSpeedIndex++; updateSpeedDisplay(); } }; speedDisplayText.down = function () { // Optional: cycle through speeds by tapping the label itself if (characterSelected) return; selectedSpeedIndex = (selectedSpeedIndex + 1) % speedOptions.length; updateSpeedDisplay(); }; // --- End speed selection UI (Top Right) --- // Bird 1 preview and costume overlay var bird1Preview = LK.getAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); bird1Preview.x = -200; bird1Preview.y = 200; bird1Preview.scaleX = 2; bird1Preview.scaleY = 2; LK.gui.center.addChild(bird1Preview); // Costume overlay for bird1Preview var bird1CostumeOverlay = null; function updateBird1CostumeOverlay() { // Remove previous overlay if exists if (bird1CostumeOverlay && bird1Preview.parent) { bird1Preview.parent.removeChild(bird1CostumeOverlay); bird1CostumeOverlay = null; } // Add new overlay if not classic if (selectedCostume === 1) { // Crown bird1CostumeOverlay = LK.getAsset('costume_crown', { anchorX: 0.5, anchorY: 1 }); bird1CostumeOverlay.x = bird1Preview.x; bird1CostumeOverlay.y = bird1Preview.y - 120; bird1CostumeOverlay.scaleX = 2; bird1CostumeOverlay.scaleY = 2; LK.gui.center.addChild(bird1CostumeOverlay); } else if (selectedCostume === 2) { // Glasses bird1CostumeOverlay = LK.getAsset('costume_glasses', { anchorX: 0.5, anchorY: 0.5 }); bird1CostumeOverlay.x = bird1Preview.x; bird1CostumeOverlay.y = bird1Preview.y - 10; bird1CostumeOverlay.scaleX = 2; bird1CostumeOverlay.scaleY = 2; LK.gui.center.addChild(bird1CostumeOverlay); } else if (selectedCostume === 3) { // Mustache bird1CostumeOverlay = LK.getAsset('costume_mustache', { anchorX: 0.5, anchorY: 0.5 }); bird1CostumeOverlay.x = bird1Preview.x; bird1CostumeOverlay.y = bird1Preview.y + 60; bird1CostumeOverlay.scaleX = 2; bird1CostumeOverlay.scaleY = 2; LK.gui.center.addChild(bird1CostumeOverlay); } else if (selectedCostume === 4) { // Beard bird1CostumeOverlay = LK.getAsset('costume_beard', { anchorX: 0.5, anchorY: 0.5 }); bird1CostumeOverlay.x = bird1Preview.x; bird1CostumeOverlay.y = bird1Preview.y + 100; bird1CostumeOverlay.scaleX = 2; bird1CostumeOverlay.scaleY = 2; LK.gui.center.addChild(bird1CostumeOverlay); } else if (selectedCostume === 5) { // Hat bird1CostumeOverlay = LK.getAsset('costume_hat', { anchorX: 0.5, anchorY: 1 }); bird1CostumeOverlay.x = bird1Preview.x; bird1CostumeOverlay.y = bird1Preview.y - 95; bird1CostumeOverlay.scaleX = 2; bird1CostumeOverlay.scaleY = 2; LK.gui.center.addChild(bird1CostumeOverlay); } else if (selectedCostume === 6) { // Randomly select one of three flowers for preview var flowerAssets = ['costume_flower1', 'costume_flower2', 'costume_flower3']; var flowerIndex = Math.floor(Math.random() * 3); var flowerId = flowerAssets[flowerIndex]; bird1CostumeOverlay = LK.getAsset(flowerId, { anchorX: 0.1, anchorY: 0.7 }); bird1CostumeOverlay.x = bird1Preview.x + bird1Preview.width * 0.65; bird1CostumeOverlay.y = bird1Preview.y + bird1Preview.height * 0.35; bird1CostumeOverlay.scaleX = 2; bird1CostumeOverlay.scaleY = 2; LK.gui.center.addChild(bird1CostumeOverlay); } } updateBird1CostumeOverlay(); // Animate bird1Preview up and down function animateBird1PreviewDown() { tween(bird1Preview, { y: 240 }, { duration: 1200, easing: tween.sineInOut, onFinish: function onFinish() { animateBird1PreviewUp(); } }); } function animateBird1PreviewUp() { tween(bird1Preview, { y: 160 }, { duration: 1200, easing: tween.sineInOut, onFinish: function onFinish() { animateBird1PreviewDown(); } }); } animateBird1PreviewDown(); // Bird 2 preview and costume overlay var bird2Preview = LK.getAsset('bird2', { anchorX: 0.5, anchorY: 0.5 }); bird2Preview.x = 200; bird2Preview.y = 200; bird2Preview.scaleX = 2; bird2Preview.scaleY = 2; LK.gui.center.addChild(bird2Preview); // Costume overlay for bird1Preview and bird2Preview var bird1CostumeOverlay = null; var bird2CostumeOverlay = null; // Helper to update overlays' transform to match preview birds function updatePreviewCostumeOverlayTransforms() { if (bird1CostumeOverlay && bird1Preview) { bird1CostumeOverlay.x = bird1Preview.x; // Y offset depends on costume if (selectedCostume === 1) bird1CostumeOverlay.y = bird1Preview.y - 120;else if (selectedCostume === 2) bird1CostumeOverlay.y = bird1Preview.y - 10;else if (selectedCostume === 3) bird1CostumeOverlay.y = bird1Preview.y + 60;else if (selectedCostume === 4) bird1CostumeOverlay.y = bird1Preview.y + 100;else if (selectedCostume === 5) bird1CostumeOverlay.y = bird1Preview.y - 95;else if (selectedCostume === 6) { bird1CostumeOverlay.x = bird1Preview.x + bird1Preview.width * 0.65; bird1CostumeOverlay.y = bird1Preview.y + bird1Preview.height * 0.35; } bird1CostumeOverlay.scaleX = bird1Preview.scaleX; bird1CostumeOverlay.scaleY = bird1Preview.scaleY; } if (bird2CostumeOverlay && bird2Preview) { bird2CostumeOverlay.x = bird2Preview.x; if (selectedCostume === 1) bird2CostumeOverlay.y = bird2Preview.y - 120;else if (selectedCostume === 2) bird2CostumeOverlay.y = bird2Preview.y - 10;else if (selectedCostume === 3) bird2CostumeOverlay.y = bird2Preview.y + 60;else if (selectedCostume === 4) bird2CostumeOverlay.y = bird2Preview.y + 100;else if (selectedCostume === 5) bird2CostumeOverlay.y = bird2Preview.y - 95;else if (selectedCostume === 6) { bird2CostumeOverlay.x = bird2Preview.x + bird2Preview.width * 0.65; bird2CostumeOverlay.y = bird2Preview.y + bird2Preview.height * 0.35; } bird2CostumeOverlay.scaleX = bird2Preview.scaleX; bird2CostumeOverlay.scaleY = bird2Preview.scaleY; } } // Costume overlay for bird1Preview // Costume overlay for bird2Preview function updateBird2CostumeOverlay() { if (bird2CostumeOverlay && bird2Preview.parent) { bird2Preview.parent.removeChild(bird2CostumeOverlay); bird2CostumeOverlay = null; } if (selectedCostume === 1) { bird2CostumeOverlay = LK.getAsset('costume_crown', { anchorX: 0.5, anchorY: 1 }); } else if (selectedCostume === 2) { bird2CostumeOverlay = LK.getAsset('costume_glasses', { anchorX: 0.5, anchorY: 0.5 }); } else if (selectedCostume === 3) { bird2CostumeOverlay = LK.getAsset('costume_mustache', { anchorX: 0.5, anchorY: 0.5 }); } else if (selectedCostume === 4) { bird2CostumeOverlay = LK.getAsset('costume_beard', { anchorX: 0.5, anchorY: 0.5 }); } else if (selectedCostume === 5) { bird2CostumeOverlay = LK.getAsset('costume_hat', { anchorX: 0.5, anchorY: 1 }); } else if (selectedCostume === 6) { // Randomly select one of three flowers for preview var flowerAssets = ['costume_flower1', 'costume_flower2', 'costume_flower3']; var flowerIndex = Math.floor(Math.random() * 3); var flowerId = flowerAssets[flowerIndex]; bird2CostumeOverlay = LK.getAsset(flowerId, { anchorX: 0.1, anchorY: 0.7 }); } if (bird2CostumeOverlay) { LK.gui.center.addChild(bird2CostumeOverlay); updatePreviewCostumeOverlayTransforms(); } } updateBird1CostumeOverlay(); updateBird2CostumeOverlay(); // Animate overlays with preview birds function updatePreviewCostumeOverlayOnTick() { updatePreviewCostumeOverlayTransforms(); } LK.on('tick', updatePreviewCostumeOverlayOnTick); // --- Costume section button (center, below birds) --- var costumeButton = new Text2('Kostümler', { size: 80, fill: '#e75480', font: 'Impact', align: 'center' }); costumeButton.anchor.set(0.5, 0); costumeButton.x = 0; costumeButton.y = 500; costumeButton.interactive = true; LK.gui.center.addChild(costumeButton); var costumePanelOpen = false; // Animate bird2Preview up and down function animateBird2PreviewDown() { tween(bird2Preview, { y: 240 }, { duration: 1200, easing: tween.sineInOut, onFinish: animateBird2PreviewUp }); } function animateBird2PreviewUp() { tween(bird2Preview, { y: 160 }, { duration: 1200, easing: tween.sineInOut, onFinish: animateBird2PreviewDown }); } animateBird2PreviewUp(); // Add touch/click handlers for selection bird1Preview.interactive = true; bird2Preview.interactive = true; // Costume selection state var selectedCostume = 0; var costumePanel = null; var costumeOptions = [{ name: "Klasik", id: 0 }, { name: "Taç", id: 1 }, { name: "Gözlük", id: 2 }, { name: "Bıyık", id: 3 }, { name: "Sakal", id: 4 }, { name: "Şapka", id: 5 }, { name: "Gül", id: 6 }]; // Costume panel UI function showCostumePanel() { if (costumePanelOpen) return; costumePanelOpen = true; costumePanel = new Container(); // Panel background var panelBg = LK.getAsset('obstacleShadow2', { anchorX: 0.5, anchorY: 0.5 }); panelBg.width = 700; panelBg.height = 350; panelBg.x = 0; panelBg.y = 600; costumePanel.addChild(panelBg); // Costume option buttons (düzenli grid: 2 satır, 3 sütun) var gridCols = 3; var gridRows = Math.ceil(costumeOptions.length / gridCols); var optionWidth = 200; var optionHeight = 120; var startX = -optionWidth * (gridCols - 1) / 2; var startY = 600 - (gridRows - 1) * optionHeight / 2; for (var i = 0; i < costumeOptions.length; i++) { (function (idx) { var opt = costumeOptions[idx]; var col = idx % gridCols; var row = Math.floor(idx / gridCols); var btn = new Text2(opt.name, { size: 70, fill: selectedCostume === opt.id ? '#e75480' : '#ffb6e6', font: 'Impact', align: 'center' }); btn.anchor.set(0.5, 0.5); btn.x = startX + col * optionWidth; btn.y = startY + row * optionHeight; btn.interactive = true; btn.down = function () { selectedCostume = opt.id; // Refresh panel to show selection LK.gui.center.removeChild(costumePanel); costumePanelOpen = false; showCostumePanel(); // Update overlays on preview birds if (typeof updateBird1CostumeOverlay === "function") updateBird1CostumeOverlay(); if (typeof updateBird2CostumeOverlay === "function") updateBird2CostumeOverlay(); }; costumePanel.addChild(btn); })(i); } // Close button var closeBtn = new Text2('Kapat', { size: 60, fill: '#e75480', font: 'Impact' }); closeBtn.anchor.set(0.5, 0.5); closeBtn.x = 0; closeBtn.y = 800; closeBtn.interactive = true; closeBtn.down = function () { LK.gui.center.removeChild(costumePanel); costumePanelOpen = false; // Update overlays on preview birds if (typeof updateBird1CostumeOverlay === "function") updateBird1CostumeOverlay(); if (typeof updateBird2CostumeOverlay === "function") updateBird2CostumeOverlay(); }; costumePanel.addChild(closeBtn); LK.gui.center.addChild(costumePanel); } // Costume button handler costumeButton.down = function () { if (!costumePanelOpen) { showCostumePanel(); } }; bird1Preview.down = function (x, y, obj) { if (!characterSelected) { // Play a sound immediately after selecting a character LK.getSound('startsound').play(); // Animate scale up, then back to normal tween(bird1Preview, { scaleX: 2.4, scaleY: 2.4 }, { duration: 120, easing: tween.sineInOut, onFinish: function onFinish() { tween(bird1Preview, { scaleX: 2, scaleY: 2 }, { duration: 120, easing: tween.sineInOut, onFinish: function onFinish() { selectedBirdType = 'bird'; startGameWithSelectedBird(); } }); } }); } }; bird2Preview.down = function (x, y, obj) { if (!characterSelected) { // Play a sound immediately after selecting a character LK.getSound('startsound').play(); // Animate scale up, then back to normal tween(bird2Preview, { scaleX: 2.4, scaleY: 2.4 }, { duration: 120, easing: tween.sineInOut, onFinish: function onFinish() { tween(bird2Preview, { scaleX: 2, scaleY: 2 }, { duration: 120, easing: tween.sineInOut, onFinish: function onFinish() { selectedBirdType = 'bird2'; startGameWithSelectedBird(); } }); } }); } }; function startGameWithSelectedBird() { characterSelected = true; // Remove motivational text if present if (motivationalText && motivationalText.parent) { motivationalText.parent.removeChild(motivationalText); motivationalText = null; } // Remove selection UI LK.gui.center.removeChild(selectText); LK.gui.center.removeChild(bird1Preview); LK.gui.center.removeChild(bird2Preview); if (costumeButton && LK.gui.center.children.indexOf(costumeButton) !== -1) { LK.gui.center.removeChild(costumeButton); } if (costumePanel && LK.gui.center.children.indexOf(costumePanel) !== -1) { LK.gui.center.removeChild(costumePanel); } // Remove costume overlays from center of screen if (typeof bird1CostumeOverlay !== "undefined" && bird1CostumeOverlay && bird1CostumeOverlay.parent) { bird1CostumeOverlay.parent.removeChild(bird1CostumeOverlay); bird1CostumeOverlay = null; } if (typeof bird2CostumeOverlay !== "undefined" && bird2CostumeOverlay && bird2CostumeOverlay.parent) { bird2CostumeOverlay.parent.removeChild(bird2CostumeOverlay); bird2CostumeOverlay = null; } // Remove speed selection UI (top right) LK.gui.topRight.removeChild(speedDisplayText); LK.gui.topRight.removeChild(speedLeftArrow); LK.gui.topRight.removeChild(speedRightArrow); // Play a sound after selecting a character // (Moved to down handler for immediate feedback) // Add the selected bird to the game bird = game.addChild(new Bird(selectedBirdType, selectedCostume)); bird.x = 1024; bird.y = 1366; // If flower costume is selected, move flower overlay further right and further down on bird if (selectedCostume === 6 && bird.roseSprite) { // Place at far right and further down bird.roseSprite.x = bird.width * 0.65; bird.roseSprite.y = bird.height * 0.35; } // Apply selected speed game.obstacleSpeedIncrease = speedOptions[selectedSpeedIndex].value; // Continue with the rest of the game setup leftWall = game.addChild(new Wall()); leftWall.x = 0; leftWall.y = 1366; rightWall = game.addChild(new Wall()); rightWall.x = 2048; rightWall.y = 1366; leftObstacles = []; rightObstacles = []; obstacleSpawnRandomness = 120; obstacleSpawnRandomnessDecrease = 0.025 * (2 / 3); obstacleSpawnY = -500; leftObstacleSpawnTime = Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness; rightObstacleSpawnTime = Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness; game.isMouseDown = false; // Show tutorial text softly at the bottom when the game starts tutorialTextWhite = new Text2('Zıplamak için\nEkrana Dokunn', { size: 90, fill: '#ffb6e6', font: 'Impact', align: 'center' }); tutorialTextWhite.anchor.set(.5, 1); tutorialTextWhite.x = -4; tutorialTextWhite.y = -62; LK.gui.bottom.addChild(tutorialTextWhite); tutorialText = new Text2('Zıplamak için\nEkrana Dokunn', { size: 90, fill: '#e75480', font: 'Impact', dropShadow: true, dropShadowColor: '#ffb6e6', dropShadowBlur: 5, dropShadowDistance: 7, dropShadowAngle: 0, align: 'center' }); tutorialText.anchor.set(.5, 1); tutorialText.y = -50; LK.gui.bottom.addChild(tutorialText); } // Only allow input after character is selected game.down = function (x, y, obj) { if (characterSelected && bird) { bird.flap(); game.isMouseDown = true; } }; game.up = function (x, y, obj) { if (characterSelected) { game.isMouseDown = false; } }; game.update = function () { if (!characterSelected || !bird) { // Don't run gameplay logic until a bird is selected return; } bird._update_migrated(); if (game.score > 2) { tutorialText.y += 5; tutorialTextWhite.y += 5; } scoreText.setText(game.score); scoreText2.setText(game.score); // Update record if needed if (game.score > record) { record = game.score; storage.record = record; recordText.setText('REKOR: ' + record); } game.obstacleSpeed += game.obstacleSpeedIncrease; obstacleSpawnRandomness -= obstacleSpawnRandomnessDecrease; if (obstacleSpawnRandomness < 20) { obstacleSpawnRandomness = 20; } if (LK.ticks >= leftObstacleSpawnTime) { var newObstacle = game.addChildAt(new Obstacle(), 0); newObstacle.x = 0; newObstacle.y = obstacleSpawnY; leftObstacles.push(newObstacle); leftObstacleSpawnTime += Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness; } if (LK.ticks >= rightObstacleSpawnTime) { var newObstacle = game.addChildAt(new Obstacle(), 0); newObstacle.x = 2048; newObstacle.y = -newObstacle.height; rightObstacles.push(newObstacle); rightObstacleSpawnTime += Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness; } if (bird.intersects(leftWall) && bird.xSpeed < 0 || bird.intersects(rightWall) && bird.xSpeed > 0) { bird.xSpeed = -bird.xSpeed; bird.flip(); game.score++; LK.setScore(game.score); LK.getSound('bounce').play(); } for (var i = leftObstacles.length - 1; i >= 0; i--) { leftObstacles[i]._move_migrated(game.obstacleSpeed); if (leftObstacles[i].y > 3232) { leftObstacles[i].destroy(); leftObstacles.splice(i, 1); } } for (var i = rightObstacles.length - 1; i >= 0; i--) { rightObstacles[i]._move_migrated(game.obstacleSpeed); if (rightObstacles[i].y > 3232) { rightObstacles[i].destroy(); rightObstacles.splice(i, 1); } } game.checkObstacleCollision(leftObstacles); game.checkObstacleCollision(rightObstacles); if (bird.y < 0 || bird.y > 2732) { LK.setScore(game.score); LK.getSound('gameOverJingle').play(); LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { LK.showGameOver(); }, 2700); //{28} // Set to 2.7 seconds return; } };
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bird = Container.expand(function (birdType, costumeId) {
var self = Container.call(this);
// Default to 'bird' if not specified
var assetId = birdType === 'bird2' ? 'bird2' : 'bird';
var birdGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
// Costume overlay logic
if (typeof costumeId !== "number") costumeId = 0;
self.costumeSprites = [];
// Use new costume images for overlays
if (costumeId === 1) {
// Crown
var crown = LK.getAsset('costume_crown', {
anchorX: 0.5,
anchorY: 1
});
crown.x = 0;
// Move the crown VERY high for in-game bird
crown.y = -birdGraphics.height * 1.2;
self.addChild(crown);
self.costumeSprites.push(crown);
}
if (costumeId === 2) {
// Glasses
var glasses = LK.getAsset('costume_glasses', {
anchorX: 0.5,
anchorY: 0.5
});
glasses.x = 0;
glasses.y = -birdGraphics.height * 0.05;
self.addChild(glasses);
self.costumeSprites.push(glasses);
}
if (costumeId === 3) {
// Mustache
var mustache = LK.getAsset('costume_mustache', {
anchorX: 0.5,
anchorY: 0.5
});
mustache.x = 0;
mustache.y = birdGraphics.height * 0.29;
self.addChild(mustache);
self.costumeSprites.push(mustache);
}
if (costumeId === 4) {
// Beard
var beard = LK.getAsset('costume_beard', {
anchorX: 0.5,
anchorY: 0.5
});
beard.x = 0;
// Move the beard VERY low for in-game bird
beard.y = birdGraphics.height * 1.1;
self.addChild(beard);
self.costumeSprites.push(beard);
}
if (costumeId === 5) {
// Hat
var hat = LK.getAsset('costume_hat', {
anchorX: 0.5,
anchorY: 1
});
hat.x = 0;
hat.y = -birdGraphics.height * 0.95;
self.addChild(hat);
self.costumeSprites.push(hat);
}
if (costumeId === 6) {
// Randomly select one of three flowers
var flowerAssets = ['costume_flower1', 'costume_flower2', 'costume_flower3'];
var flowerIndex = Math.floor(Math.random() * 3);
var flowerId = flowerAssets[flowerIndex];
var flower = LK.getAsset(flowerId, {
anchorX: 0.1,
anchorY: 0.7
});
// Place flower further right and further down for default facing right
flower.x = birdGraphics.width * 0.65;
flower.y = birdGraphics.height * 0.35;
self.addChild(flower);
self.costumeSprites.push(flower);
// Save reference for flipping
self.roseSprite = flower;
}
self.xSpeed = 10.9375;
self.ySpeed = -20;
self.gravity = 1;
self.lift = -15;
self.flap = function () {
self.ySpeed = self.lift * 1.5;
LK.getSound('flap').play();
};
self._update_migrated = function () {
if (game.isMouseDown) {
self.ySpeed += self.gravity / 3;
} else {
self.ySpeed += self.gravity;
}
self.y += self.ySpeed;
self.x += self.xSpeed;
if (self.y <= 0 || self.y >= 2732) {
self.speed = -self.speed;
}
var targetRotation = Math.atan2(self.ySpeed, self.xSpeed * self.scale.x) / 2;
birdGraphics.rotation += (targetRotation - birdGraphics.rotation) / 10;
// Make all costume overlays follow the bird's position, scale, and rotation exactly
if (self.costumeSprites && self.costumeSprites.length) {
for (var i = 0; i < self.costumeSprites.length; i++) {
var sprite = self.costumeSprites[i];
// Always keep overlays at (0,0) relative to bird, so they move with the bird
sprite.x = 0;
sprite.y = 0;
// Match scale and rotation to birdGraphics
sprite.scale.x = birdGraphics.scale.x;
sprite.scale.y = birdGraphics.scale.y;
sprite.rotation = birdGraphics.rotation;
}
}
};
self.flip = function () {
self.scale.x *= -1;
// If rose costume is active, mirror its x position to the other cheek
if (self.roseSprite) {
// If facing right, rose on right cheek; if facing left, rose on left cheek
self.roseSprite.x = self.scale.x > 0 ? birdGraphics.width * 0.45 : -birdGraphics.width * 0.45;
}
};
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleShadow = self.attachAsset('obstacleShadow', {
anchorX: 0.5,
anchorY: 0.5
});
obstacleShadow.rotation = Math.PI / 4;
var obstacleShadow2 = self.attachAsset('obstacleShadow2', {
anchorX: 0.5,
anchorY: 0.5
});
obstacleShadow2.rotation = Math.PI / 4;
obstacleShadow2.y = -7;
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
obstacleGraphics.rotation = Math.PI / 4;
self.speed = 5;
self._move_migrated = function (speed) {
self.y += speed;
};
});
var Wall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Costume image assets (replace id values with your own images in the asset manager)
// Tutorial text will be created and added only after the game starts (see startGameWithSelectedBird)
var tutorialTextWhite = null;
var tutorialText = null;
game.score = 0;
game.obstacleSpeed = 5;
// Default value, will be overwritten by selection screen
game.obstacleSpeedIncrease = 0.005;
game.checkObstacleCollision = function (obstacles) {
for (var i = 0; i < obstacles.length; i++) {
obstacles[i]._move_migrated();
var dist = Math.sqrt(Math.pow(bird.x - obstacles[i].x, 2) + Math.pow(bird.y - obstacles[i].y, 2));
if (dist < 280) {
LK.setScore(game.score);
LK.getSound('gameOverJingle').play();
LK.effects.flashScreen(0xff0000, 600);
LK.setTimeout(function () {
LK.showGameOver();
}, 2700); //{W} // Set to 2.7 seconds
return;
}
}
};
game.setBackgroundColor(0xffe0f0); // very light pink background
var record = typeof storage.record === 'number' ? storage.record : 0;
var scoreText = new Text2('0', {
size: 150,
fill: '#e75480',
//{V} // vivid pink
font: 'Impact',
dropShadow: true,
dropShadowColor: '#ffb6e6',
//{Y} // light pink shadow
dropShadowBlur: 5,
dropShadowDistance: 7,
dropShadowAngle: 0
});
scoreText.anchor.set(.5, 0);
LK.gui.top.addChild(scoreText);
var scoreText2 = new Text2('0', {
size: 150,
fill: '#ffb6e6',
//{14} // light pink
font: 'Impact'
});
scoreText2.anchor.set(.5, 0);
scoreText2.x = -4;
scoreText2.y = -5;
LK.gui.top.addChild(scoreText2);
// Record (high score) text
var recordText = new Text2('REKOR: ' + record, {
size: 80,
fill: '#e75480',
font: 'Impact',
dropShadow: true,
dropShadowColor: '#ffb6e6',
dropShadowBlur: 5,
dropShadowDistance: 7,
dropShadowAngle: 0
});
recordText.anchor.set(0.5, 0);
recordText.y = 140;
LK.gui.top.addChild(recordText);
LK.gui.top.addChild(scoreText);
// Character select state
var characterSelected = false;
var selectedBirdType = null;
var bird = null;
// --- Motivational Text for Selection Screen ---
// Always show motivational text under record text on selection screen
var motivationalText = new Text2("Rekoru geçiceksiiinn sana güveniyoruummm", {
size: 60,
fill: '#e75480',
font: 'Impact',
align: 'center',
dropShadow: true,
dropShadowColor: '#ffb6e6',
dropShadowBlur: 5,
dropShadowDistance: 7,
dropShadowAngle: 0
});
motivationalText.anchor.set(0.5, 0);
// Place under recordText (recordText.y + recordText.height + margin)
motivationalText.x = 0;
motivationalText.y = 140 + 90; // recordText.y + recordText.height (approx) + margin
LK.gui.top.addChild(motivationalText);
// Create character select UI
var selectText = new Text2('Hangimizle oynamak istersin', {
size: 80,
fill: '#e75480',
//{17} // vivid pink
font: 'Impact',
align: 'center'
});
selectText.anchor.set(0.5, 1);
selectText.x = 0;
selectText.y = -200;
LK.gui.center.addChild(selectText);
// --- Speed selection UI (Top Right) ---
var speedOptions = [{
label: "Yavaş",
value: 0.003
}, {
label: "Normal",
value: 0.005
}, {
label: "Hızlı",
value: 0.009
}];
var selectedSpeedIndex = 1; // Default to "Normal"
// Small speed display at top right
var speedDisplayText = new Text2('Hız: ' + speedOptions[selectedSpeedIndex].label, {
size: 60,
fill: '#e75480',
font: 'Impact',
align: 'center'
});
speedDisplayText.anchor.set(1, 0); // Top right
speedDisplayText.x = -40; // Padding from right edge
speedDisplayText.y = 20;
speedDisplayText.interactive = true;
LK.gui.topRight.addChild(speedDisplayText);
// Add left/right arrows for speed selection
var speedLeftArrow = new Text2('<', {
size: 60,
fill: '#e75480',
font: 'Impact'
});
speedLeftArrow.anchor.set(1, 0);
speedLeftArrow.x = -170;
speedLeftArrow.y = 20;
speedLeftArrow.interactive = true;
LK.gui.topRight.addChild(speedLeftArrow);
var speedRightArrow = new Text2('>', {
size: 60,
fill: '#e75480',
font: 'Impact'
});
speedRightArrow.anchor.set(1, 0);
speedRightArrow.x = 0;
speedRightArrow.y = 20;
speedRightArrow.interactive = true;
LK.gui.topRight.addChild(speedRightArrow);
function updateSpeedDisplay() {
speedDisplayText.setText('Hız: ' + speedOptions[selectedSpeedIndex].label);
}
// Only allow speed change before character is selected
speedLeftArrow.down = function () {
if (characterSelected) return;
if (selectedSpeedIndex > 0) {
selectedSpeedIndex--;
updateSpeedDisplay();
}
};
speedRightArrow.down = function () {
if (characterSelected) return;
if (selectedSpeedIndex < speedOptions.length - 1) {
selectedSpeedIndex++;
updateSpeedDisplay();
}
};
speedDisplayText.down = function () {
// Optional: cycle through speeds by tapping the label itself
if (characterSelected) return;
selectedSpeedIndex = (selectedSpeedIndex + 1) % speedOptions.length;
updateSpeedDisplay();
};
// --- End speed selection UI (Top Right) ---
// Bird 1 preview and costume overlay
var bird1Preview = LK.getAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
bird1Preview.x = -200;
bird1Preview.y = 200;
bird1Preview.scaleX = 2;
bird1Preview.scaleY = 2;
LK.gui.center.addChild(bird1Preview);
// Costume overlay for bird1Preview
var bird1CostumeOverlay = null;
function updateBird1CostumeOverlay() {
// Remove previous overlay if exists
if (bird1CostumeOverlay && bird1Preview.parent) {
bird1Preview.parent.removeChild(bird1CostumeOverlay);
bird1CostumeOverlay = null;
}
// Add new overlay if not classic
if (selectedCostume === 1) {
// Crown
bird1CostumeOverlay = LK.getAsset('costume_crown', {
anchorX: 0.5,
anchorY: 1
});
bird1CostumeOverlay.x = bird1Preview.x;
bird1CostumeOverlay.y = bird1Preview.y - 120;
bird1CostumeOverlay.scaleX = 2;
bird1CostumeOverlay.scaleY = 2;
LK.gui.center.addChild(bird1CostumeOverlay);
} else if (selectedCostume === 2) {
// Glasses
bird1CostumeOverlay = LK.getAsset('costume_glasses', {
anchorX: 0.5,
anchorY: 0.5
});
bird1CostumeOverlay.x = bird1Preview.x;
bird1CostumeOverlay.y = bird1Preview.y - 10;
bird1CostumeOverlay.scaleX = 2;
bird1CostumeOverlay.scaleY = 2;
LK.gui.center.addChild(bird1CostumeOverlay);
} else if (selectedCostume === 3) {
// Mustache
bird1CostumeOverlay = LK.getAsset('costume_mustache', {
anchorX: 0.5,
anchorY: 0.5
});
bird1CostumeOverlay.x = bird1Preview.x;
bird1CostumeOverlay.y = bird1Preview.y + 60;
bird1CostumeOverlay.scaleX = 2;
bird1CostumeOverlay.scaleY = 2;
LK.gui.center.addChild(bird1CostumeOverlay);
} else if (selectedCostume === 4) {
// Beard
bird1CostumeOverlay = LK.getAsset('costume_beard', {
anchorX: 0.5,
anchorY: 0.5
});
bird1CostumeOverlay.x = bird1Preview.x;
bird1CostumeOverlay.y = bird1Preview.y + 100;
bird1CostumeOverlay.scaleX = 2;
bird1CostumeOverlay.scaleY = 2;
LK.gui.center.addChild(bird1CostumeOverlay);
} else if (selectedCostume === 5) {
// Hat
bird1CostumeOverlay = LK.getAsset('costume_hat', {
anchorX: 0.5,
anchorY: 1
});
bird1CostumeOverlay.x = bird1Preview.x;
bird1CostumeOverlay.y = bird1Preview.y - 95;
bird1CostumeOverlay.scaleX = 2;
bird1CostumeOverlay.scaleY = 2;
LK.gui.center.addChild(bird1CostumeOverlay);
} else if (selectedCostume === 6) {
// Randomly select one of three flowers for preview
var flowerAssets = ['costume_flower1', 'costume_flower2', 'costume_flower3'];
var flowerIndex = Math.floor(Math.random() * 3);
var flowerId = flowerAssets[flowerIndex];
bird1CostumeOverlay = LK.getAsset(flowerId, {
anchorX: 0.1,
anchorY: 0.7
});
bird1CostumeOverlay.x = bird1Preview.x + bird1Preview.width * 0.65;
bird1CostumeOverlay.y = bird1Preview.y + bird1Preview.height * 0.35;
bird1CostumeOverlay.scaleX = 2;
bird1CostumeOverlay.scaleY = 2;
LK.gui.center.addChild(bird1CostumeOverlay);
}
}
updateBird1CostumeOverlay();
// Animate bird1Preview up and down
function animateBird1PreviewDown() {
tween(bird1Preview, {
y: 240
}, {
duration: 1200,
easing: tween.sineInOut,
onFinish: function onFinish() {
animateBird1PreviewUp();
}
});
}
function animateBird1PreviewUp() {
tween(bird1Preview, {
y: 160
}, {
duration: 1200,
easing: tween.sineInOut,
onFinish: function onFinish() {
animateBird1PreviewDown();
}
});
}
animateBird1PreviewDown();
// Bird 2 preview and costume overlay
var bird2Preview = LK.getAsset('bird2', {
anchorX: 0.5,
anchorY: 0.5
});
bird2Preview.x = 200;
bird2Preview.y = 200;
bird2Preview.scaleX = 2;
bird2Preview.scaleY = 2;
LK.gui.center.addChild(bird2Preview);
// Costume overlay for bird1Preview and bird2Preview
var bird1CostumeOverlay = null;
var bird2CostumeOverlay = null;
// Helper to update overlays' transform to match preview birds
function updatePreviewCostumeOverlayTransforms() {
if (bird1CostumeOverlay && bird1Preview) {
bird1CostumeOverlay.x = bird1Preview.x;
// Y offset depends on costume
if (selectedCostume === 1) bird1CostumeOverlay.y = bird1Preview.y - 120;else if (selectedCostume === 2) bird1CostumeOverlay.y = bird1Preview.y - 10;else if (selectedCostume === 3) bird1CostumeOverlay.y = bird1Preview.y + 60;else if (selectedCostume === 4) bird1CostumeOverlay.y = bird1Preview.y + 100;else if (selectedCostume === 5) bird1CostumeOverlay.y = bird1Preview.y - 95;else if (selectedCostume === 6) {
bird1CostumeOverlay.x = bird1Preview.x + bird1Preview.width * 0.65;
bird1CostumeOverlay.y = bird1Preview.y + bird1Preview.height * 0.35;
}
bird1CostumeOverlay.scaleX = bird1Preview.scaleX;
bird1CostumeOverlay.scaleY = bird1Preview.scaleY;
}
if (bird2CostumeOverlay && bird2Preview) {
bird2CostumeOverlay.x = bird2Preview.x;
if (selectedCostume === 1) bird2CostumeOverlay.y = bird2Preview.y - 120;else if (selectedCostume === 2) bird2CostumeOverlay.y = bird2Preview.y - 10;else if (selectedCostume === 3) bird2CostumeOverlay.y = bird2Preview.y + 60;else if (selectedCostume === 4) bird2CostumeOverlay.y = bird2Preview.y + 100;else if (selectedCostume === 5) bird2CostumeOverlay.y = bird2Preview.y - 95;else if (selectedCostume === 6) {
bird2CostumeOverlay.x = bird2Preview.x + bird2Preview.width * 0.65;
bird2CostumeOverlay.y = bird2Preview.y + bird2Preview.height * 0.35;
}
bird2CostumeOverlay.scaleX = bird2Preview.scaleX;
bird2CostumeOverlay.scaleY = bird2Preview.scaleY;
}
}
// Costume overlay for bird1Preview
// Costume overlay for bird2Preview
function updateBird2CostumeOverlay() {
if (bird2CostumeOverlay && bird2Preview.parent) {
bird2Preview.parent.removeChild(bird2CostumeOverlay);
bird2CostumeOverlay = null;
}
if (selectedCostume === 1) {
bird2CostumeOverlay = LK.getAsset('costume_crown', {
anchorX: 0.5,
anchorY: 1
});
} else if (selectedCostume === 2) {
bird2CostumeOverlay = LK.getAsset('costume_glasses', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (selectedCostume === 3) {
bird2CostumeOverlay = LK.getAsset('costume_mustache', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (selectedCostume === 4) {
bird2CostumeOverlay = LK.getAsset('costume_beard', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (selectedCostume === 5) {
bird2CostumeOverlay = LK.getAsset('costume_hat', {
anchorX: 0.5,
anchorY: 1
});
} else if (selectedCostume === 6) {
// Randomly select one of three flowers for preview
var flowerAssets = ['costume_flower1', 'costume_flower2', 'costume_flower3'];
var flowerIndex = Math.floor(Math.random() * 3);
var flowerId = flowerAssets[flowerIndex];
bird2CostumeOverlay = LK.getAsset(flowerId, {
anchorX: 0.1,
anchorY: 0.7
});
}
if (bird2CostumeOverlay) {
LK.gui.center.addChild(bird2CostumeOverlay);
updatePreviewCostumeOverlayTransforms();
}
}
updateBird1CostumeOverlay();
updateBird2CostumeOverlay();
// Animate overlays with preview birds
function updatePreviewCostumeOverlayOnTick() {
updatePreviewCostumeOverlayTransforms();
}
LK.on('tick', updatePreviewCostumeOverlayOnTick);
// --- Costume section button (center, below birds) ---
var costumeButton = new Text2('Kostümler', {
size: 80,
fill: '#e75480',
font: 'Impact',
align: 'center'
});
costumeButton.anchor.set(0.5, 0);
costumeButton.x = 0;
costumeButton.y = 500;
costumeButton.interactive = true;
LK.gui.center.addChild(costumeButton);
var costumePanelOpen = false;
// Animate bird2Preview up and down
function animateBird2PreviewDown() {
tween(bird2Preview, {
y: 240
}, {
duration: 1200,
easing: tween.sineInOut,
onFinish: animateBird2PreviewUp
});
}
function animateBird2PreviewUp() {
tween(bird2Preview, {
y: 160
}, {
duration: 1200,
easing: tween.sineInOut,
onFinish: animateBird2PreviewDown
});
}
animateBird2PreviewUp();
// Add touch/click handlers for selection
bird1Preview.interactive = true;
bird2Preview.interactive = true;
// Costume selection state
var selectedCostume = 0;
var costumePanel = null;
var costumeOptions = [{
name: "Klasik",
id: 0
}, {
name: "Taç",
id: 1
}, {
name: "Gözlük",
id: 2
}, {
name: "Bıyık",
id: 3
}, {
name: "Sakal",
id: 4
}, {
name: "Şapka",
id: 5
}, {
name: "Gül",
id: 6
}];
// Costume panel UI
function showCostumePanel() {
if (costumePanelOpen) return;
costumePanelOpen = true;
costumePanel = new Container();
// Panel background
var panelBg = LK.getAsset('obstacleShadow2', {
anchorX: 0.5,
anchorY: 0.5
});
panelBg.width = 700;
panelBg.height = 350;
panelBg.x = 0;
panelBg.y = 600;
costumePanel.addChild(panelBg);
// Costume option buttons (düzenli grid: 2 satır, 3 sütun)
var gridCols = 3;
var gridRows = Math.ceil(costumeOptions.length / gridCols);
var optionWidth = 200;
var optionHeight = 120;
var startX = -optionWidth * (gridCols - 1) / 2;
var startY = 600 - (gridRows - 1) * optionHeight / 2;
for (var i = 0; i < costumeOptions.length; i++) {
(function (idx) {
var opt = costumeOptions[idx];
var col = idx % gridCols;
var row = Math.floor(idx / gridCols);
var btn = new Text2(opt.name, {
size: 70,
fill: selectedCostume === opt.id ? '#e75480' : '#ffb6e6',
font: 'Impact',
align: 'center'
});
btn.anchor.set(0.5, 0.5);
btn.x = startX + col * optionWidth;
btn.y = startY + row * optionHeight;
btn.interactive = true;
btn.down = function () {
selectedCostume = opt.id;
// Refresh panel to show selection
LK.gui.center.removeChild(costumePanel);
costumePanelOpen = false;
showCostumePanel();
// Update overlays on preview birds
if (typeof updateBird1CostumeOverlay === "function") updateBird1CostumeOverlay();
if (typeof updateBird2CostumeOverlay === "function") updateBird2CostumeOverlay();
};
costumePanel.addChild(btn);
})(i);
}
// Close button
var closeBtn = new Text2('Kapat', {
size: 60,
fill: '#e75480',
font: 'Impact'
});
closeBtn.anchor.set(0.5, 0.5);
closeBtn.x = 0;
closeBtn.y = 800;
closeBtn.interactive = true;
closeBtn.down = function () {
LK.gui.center.removeChild(costumePanel);
costumePanelOpen = false;
// Update overlays on preview birds
if (typeof updateBird1CostumeOverlay === "function") updateBird1CostumeOverlay();
if (typeof updateBird2CostumeOverlay === "function") updateBird2CostumeOverlay();
};
costumePanel.addChild(closeBtn);
LK.gui.center.addChild(costumePanel);
}
// Costume button handler
costumeButton.down = function () {
if (!costumePanelOpen) {
showCostumePanel();
}
};
bird1Preview.down = function (x, y, obj) {
if (!characterSelected) {
// Play a sound immediately after selecting a character
LK.getSound('startsound').play();
// Animate scale up, then back to normal
tween(bird1Preview, {
scaleX: 2.4,
scaleY: 2.4
}, {
duration: 120,
easing: tween.sineInOut,
onFinish: function onFinish() {
tween(bird1Preview, {
scaleX: 2,
scaleY: 2
}, {
duration: 120,
easing: tween.sineInOut,
onFinish: function onFinish() {
selectedBirdType = 'bird';
startGameWithSelectedBird();
}
});
}
});
}
};
bird2Preview.down = function (x, y, obj) {
if (!characterSelected) {
// Play a sound immediately after selecting a character
LK.getSound('startsound').play();
// Animate scale up, then back to normal
tween(bird2Preview, {
scaleX: 2.4,
scaleY: 2.4
}, {
duration: 120,
easing: tween.sineInOut,
onFinish: function onFinish() {
tween(bird2Preview, {
scaleX: 2,
scaleY: 2
}, {
duration: 120,
easing: tween.sineInOut,
onFinish: function onFinish() {
selectedBirdType = 'bird2';
startGameWithSelectedBird();
}
});
}
});
}
};
function startGameWithSelectedBird() {
characterSelected = true;
// Remove motivational text if present
if (motivationalText && motivationalText.parent) {
motivationalText.parent.removeChild(motivationalText);
motivationalText = null;
}
// Remove selection UI
LK.gui.center.removeChild(selectText);
LK.gui.center.removeChild(bird1Preview);
LK.gui.center.removeChild(bird2Preview);
if (costumeButton && LK.gui.center.children.indexOf(costumeButton) !== -1) {
LK.gui.center.removeChild(costumeButton);
}
if (costumePanel && LK.gui.center.children.indexOf(costumePanel) !== -1) {
LK.gui.center.removeChild(costumePanel);
}
// Remove costume overlays from center of screen
if (typeof bird1CostumeOverlay !== "undefined" && bird1CostumeOverlay && bird1CostumeOverlay.parent) {
bird1CostumeOverlay.parent.removeChild(bird1CostumeOverlay);
bird1CostumeOverlay = null;
}
if (typeof bird2CostumeOverlay !== "undefined" && bird2CostumeOverlay && bird2CostumeOverlay.parent) {
bird2CostumeOverlay.parent.removeChild(bird2CostumeOverlay);
bird2CostumeOverlay = null;
}
// Remove speed selection UI (top right)
LK.gui.topRight.removeChild(speedDisplayText);
LK.gui.topRight.removeChild(speedLeftArrow);
LK.gui.topRight.removeChild(speedRightArrow);
// Play a sound after selecting a character
// (Moved to down handler for immediate feedback)
// Add the selected bird to the game
bird = game.addChild(new Bird(selectedBirdType, selectedCostume));
bird.x = 1024;
bird.y = 1366;
// If flower costume is selected, move flower overlay further right and further down on bird
if (selectedCostume === 6 && bird.roseSprite) {
// Place at far right and further down
bird.roseSprite.x = bird.width * 0.65;
bird.roseSprite.y = bird.height * 0.35;
}
// Apply selected speed
game.obstacleSpeedIncrease = speedOptions[selectedSpeedIndex].value;
// Continue with the rest of the game setup
leftWall = game.addChild(new Wall());
leftWall.x = 0;
leftWall.y = 1366;
rightWall = game.addChild(new Wall());
rightWall.x = 2048;
rightWall.y = 1366;
leftObstacles = [];
rightObstacles = [];
obstacleSpawnRandomness = 120;
obstacleSpawnRandomnessDecrease = 0.025 * (2 / 3);
obstacleSpawnY = -500;
leftObstacleSpawnTime = Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness;
rightObstacleSpawnTime = Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness;
game.isMouseDown = false;
// Show tutorial text softly at the bottom when the game starts
tutorialTextWhite = new Text2('Zıplamak için\nEkrana Dokunn', {
size: 90,
fill: '#ffb6e6',
font: 'Impact',
align: 'center'
});
tutorialTextWhite.anchor.set(.5, 1);
tutorialTextWhite.x = -4;
tutorialTextWhite.y = -62;
LK.gui.bottom.addChild(tutorialTextWhite);
tutorialText = new Text2('Zıplamak için\nEkrana Dokunn', {
size: 90,
fill: '#e75480',
font: 'Impact',
dropShadow: true,
dropShadowColor: '#ffb6e6',
dropShadowBlur: 5,
dropShadowDistance: 7,
dropShadowAngle: 0,
align: 'center'
});
tutorialText.anchor.set(.5, 1);
tutorialText.y = -50;
LK.gui.bottom.addChild(tutorialText);
}
// Only allow input after character is selected
game.down = function (x, y, obj) {
if (characterSelected && bird) {
bird.flap();
game.isMouseDown = true;
}
};
game.up = function (x, y, obj) {
if (characterSelected) {
game.isMouseDown = false;
}
};
game.update = function () {
if (!characterSelected || !bird) {
// Don't run gameplay logic until a bird is selected
return;
}
bird._update_migrated();
if (game.score > 2) {
tutorialText.y += 5;
tutorialTextWhite.y += 5;
}
scoreText.setText(game.score);
scoreText2.setText(game.score);
// Update record if needed
if (game.score > record) {
record = game.score;
storage.record = record;
recordText.setText('REKOR: ' + record);
}
game.obstacleSpeed += game.obstacleSpeedIncrease;
obstacleSpawnRandomness -= obstacleSpawnRandomnessDecrease;
if (obstacleSpawnRandomness < 20) {
obstacleSpawnRandomness = 20;
}
if (LK.ticks >= leftObstacleSpawnTime) {
var newObstacle = game.addChildAt(new Obstacle(), 0);
newObstacle.x = 0;
newObstacle.y = obstacleSpawnY;
leftObstacles.push(newObstacle);
leftObstacleSpawnTime += Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness;
}
if (LK.ticks >= rightObstacleSpawnTime) {
var newObstacle = game.addChildAt(new Obstacle(), 0);
newObstacle.x = 2048;
newObstacle.y = -newObstacle.height;
rightObstacles.push(newObstacle);
rightObstacleSpawnTime += Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness;
}
if (bird.intersects(leftWall) && bird.xSpeed < 0 || bird.intersects(rightWall) && bird.xSpeed > 0) {
bird.xSpeed = -bird.xSpeed;
bird.flip();
game.score++;
LK.setScore(game.score);
LK.getSound('bounce').play();
}
for (var i = leftObstacles.length - 1; i >= 0; i--) {
leftObstacles[i]._move_migrated(game.obstacleSpeed);
if (leftObstacles[i].y > 3232) {
leftObstacles[i].destroy();
leftObstacles.splice(i, 1);
}
}
for (var i = rightObstacles.length - 1; i >= 0; i--) {
rightObstacles[i]._move_migrated(game.obstacleSpeed);
if (rightObstacles[i].y > 3232) {
rightObstacles[i].destroy();
rightObstacles.splice(i, 1);
}
}
game.checkObstacleCollision(leftObstacles);
game.checkObstacleCollision(rightObstacles);
if (bird.y < 0 || bird.y > 2732) {
LK.setScore(game.score);
LK.getSound('gameOverJingle').play();
LK.effects.flashScreen(0xff0000, 600);
LK.setTimeout(function () {
LK.showGameOver();
}, 2700); //{28} // Set to 2.7 seconds
return;
}
};
Dusty pink wall with hearts inside . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat Let the hearts be hearts of vibrant colors and various pink emojis and let the wall be square
powder pink square. In-Game asset. 2d. High contrast. No shadows
pixel sun glasses . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
brown beard. In-Game asset. 2d. High contrast. No shadows
king crown. In-Game asset. 2d. High contrast. No shadows
bıyık. In-Game asset. 2d. High contrast. No shadows
gri tonlarında şapka. In-Game asset. 2d. High contrast. No shadows
red rose realistic. In-Game asset. 2d. High contrast. No shadows
Daisy Bouquet Realistic. In-Game asset. 2d. High contrast. No shadows
pink flower bouquet realistic. In-Game asset. 2d. High contrast. No shadows