User prompt
Aslan assetimi silin
User prompt
Aslan fotoğraf değişimi iptal et
User prompt
Her 5 seviye geçişinde aslan fotoğrafı değişsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Sağ alta bir aslan asseti ekleyelim
User prompt
Oyuncu 10 seviye geçtiğinde ekrana great! Yaz
User prompt
Flappy Flight ismini Flying Bird olrak değiştir
User prompt
Please fix the bug: 'TypeError: storage.getItem is not a function' in or related to this line: 'var highScore = storage.getItem('highScore') || 0;' Line Number: 631 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Uncaught TypeError: storage.get is not a function' in or related to this line: 'var highScore = storage.get('highScore') || 0;' Line Number: 148 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Ayarlar seçeneği rekorların bir üstünde olsun
User prompt
Rekor sistemini ayarlarda değil ayrı bir seçenek olarak olsun
User prompt
Please fix the bug: 'Uncaught TypeError: storage.getItem is not a function' in or related to this line: 'var highScore = storage.getItem('highScore') || 0;' Line Number: 305
User prompt
Rekor sistemini ekleyin
User prompt
Rekor sistemini kaldır
User prompt
Oyuna bir rekor sistemi ekleyin ve ayarlar sekmesinden görüntülensin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Bulutun opaklığını arttırın
User prompt
Üst bulutu ortaya çek
User prompt
Far clouds cismini y eksenini biraz aşağı çekin
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'then')' in or related to this line: 'tween(self, {' Line Number: 40
User prompt
Arka planı 3d gibi efektler ekleyelim
User prompt
Son dediğimi iptal et
User prompt
Oyunda karekter zıplamasına göre hareket eden ağaçlar ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Son dediğimi iptal et
User prompt
Arka planda kamera açısına göre hareket eden ağaçlar yapalım
User prompt
Ayarlar menüsün yazılarının arkasında gölge olsun
User prompt
Oyuna bir başlama ve ayarlar menüsü ekleyelim
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.velocity = 0; self.gravity = 0.5; self.flapStrength = -12; self.isDead = false; self.flap = function () { if (!self.isDead) { self.velocity = self.flapStrength; LK.getSound('flap').play(); // Rotate bird up when flapping tween(self, { rotation: -0.5 }, { duration: 100, easing: tween.linear }); // Make trees respond to jump for (var i = 0; i < trees.length; i++) { if (trees[i].respondToJump) { trees[i].respondToJump(self.flapStrength); } } } }; self.update = function () { if (self.isDead) { return; } // Apply gravity and update position self.velocity += self.gravity; self.y += self.velocity; // Rotate bird based on velocity if (self.velocity > 0) { var targetRotation = Math.min(self.velocity * 0.05, 1.2); tween(self, { rotation: targetRotation }, { duration: 100, easing: tween.linear }); } }; self.die = function () { if (!self.isDead) { self.isDead = true; LK.getSound('hit').play(); } }; return self; }); var Menu = Container.expand(function () { var self = Container.call(this); // Create menu background var menuBg = LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0, alpha: 0.8 }); self.addChild(menuBg); // Create title var titleText = new Text2('Flappy Flight', { size: 150, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 600; self.addChild(titleText); // Create play button var playButton = new Text2('Play', { size: 100, fill: 0xFFFFFF }); playButton.anchor.set(0.5, 0.5); playButton.x = 2048 / 2; playButton.y = 1100; self.addChild(playButton); // Create settings button var settingsButton = new Text2('Settings', { size: 100, fill: 0xFFFFFF }); settingsButton.anchor.set(0.5, 0.5); settingsButton.x = 2048 / 2; settingsButton.y = 1300; self.addChild(settingsButton); // Event handlers playButton.down = function () { if (self.onPlay) { self.onPlay(); } }; settingsButton.down = function () { if (self.onSettings) { self.onSettings(); } }; return self; }); var Pipe = Container.expand(function () { var self = Container.call(this); var topPipe = self.attachAsset('pipeTop', { anchorX: 0.5, anchorY: 1.0 }); var bottomPipe = self.attachAsset('pipeBottom', { anchorX: 0.5, anchorY: 0 }); self.gapHeight = 400; self.gapPosition = 0; self.speed = 5; self.scored = false; self.setGapPosition = function (position) { self.gapPosition = position; // Position pipes to create gap topPipe.y = position - self.gapHeight / 2; bottomPipe.y = position + self.gapHeight / 2; }; self.update = function () { self.x -= self.speed; }; return self; }); var Settings = Container.expand(function () { var self = Container.call(this); // Create settings background var settingsBg = LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0, alpha: 0.8 }); self.addChild(settingsBg); // Create title var titleText = new Text2('Settings', { size: 150, fill: 0xFFFFFF, shadow: { color: 0x000000, blur: 10, offsetX: 3, offsetY: 3 } }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 600; self.addChild(titleText); // Music toggle var musicText = new Text2('Music: ON', { size: 100, fill: 0xFFFFFF, shadow: { color: 0x000000, blur: 10, offsetX: 3, offsetY: 3 } }); musicText.anchor.set(0.5, 0.5); musicText.x = 2048 / 2; musicText.y = 1000; self.addChild(musicText); // Sound toggle var soundText = new Text2('Sound: ON', { size: 100, fill: 0xFFFFFF, shadow: { color: 0x000000, blur: 10, offsetX: 3, offsetY: 3 } }); soundText.anchor.set(0.5, 0.5); soundText.x = 2048 / 2; soundText.y = 1200; self.addChild(soundText); // Back button var backButton = new Text2('Back', { size: 100, fill: 0xFFFFFF, shadow: { color: 0x000000, blur: 10, offsetX: 3, offsetY: 3 } }); backButton.anchor.set(0.5, 0.5); backButton.x = 2048 / 2; backButton.y = 1400; self.addChild(backButton); // State variables self.musicEnabled = true; self.soundEnabled = true; // Event handlers musicText.down = function () { self.musicEnabled = !self.musicEnabled; musicText.setText('Music: ' + (self.musicEnabled ? 'ON' : 'OFF')); if (self.onMusicToggle) { self.onMusicToggle(self.musicEnabled); } }; soundText.down = function () { self.soundEnabled = !self.soundEnabled; soundText.setText('Sound: ' + (self.soundEnabled ? 'ON' : 'OFF')); if (self.onSoundToggle) { self.onSoundToggle(self.soundEnabled); } }; backButton.down = function () { if (self.onBack) { self.onBack(); } }; return self; }); var Tree = Container.expand(function () { var self = Container.call(this); // Create tree trunk var trunk = LK.getAsset('ground', { anchorX: 0.5, anchorY: 1.0, width: 40, height: 200, tint: 0x8b4513 }); // Create tree top (leaves) var leaves = LK.getAsset('ground', { anchorX: 0.5, anchorY: 1.0, width: 120, height: 150, tint: 0x228B22, y: -200 }); self.addChild(trunk); self.addChild(leaves); // Variables for movement self.baseY = 0; self.swayAmount = 0; self.swaySpeed = 0.05; self.swayDirection = 1; self.swayOffset = Math.random() * Math.PI * 2; // Random starting phase // Response to bird jump self.respondToJump = function (jumpStrength) { // Add a sway effect when bird jumps tween(self, { rotation: -0.1 * jumpStrength / 12 }, { duration: 200, easing: tween.elasticOut, onFinish: function onFinish() { // Return to normal position tween(self, { rotation: 0 }, { duration: 300, easing: tween.easeOut }); } }); }; self.update = function () { // Natural gentle swaying motion self.rotation = Math.sin(LK.ticks * self.swaySpeed + self.swayOffset) * 0.01; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var bird; var pipes = []; var trees = []; var ground; var background; var isGameStarted = false; var pipeSpawnTimer = 0; var pipeSpawnInterval = 120; // frames (2 seconds at 60fps) var lastPipeX = 0; var gameover = false; // Menu management var mainMenu; var settingsMenu; var gameState = 'MENU'; // MENU, SETTINGS, GAME var musicEnabled = true; var soundEnabled = true; // GUI var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create tap to start text (but don't add it yet) var startTxt = new Text2('Tap to Start', { size: 80, fill: 0xFFFFFF }); startTxt.anchor.set(0.5, 0.5); // Create background background = LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); game.addChild(background); // Create trees function createTrees() { // Clear existing trees for (var i = trees.length - 1; i >= 0; i--) { game.removeChild(trees[i]); trees[i].destroy(); } trees = []; // Create new trees for (var i = 0; i < 5; i++) { var tree = new Tree(); tree.x = 200 + i * 400; tree.y = 2732 - 100; // Place on ground tree.baseY = tree.y; game.addChild(tree); trees.push(tree); // Make sure trees are behind bird and pipes game.setChildIndex(tree, 1); } } createTrees(); // Create ground ground = LK.getAsset('ground', { anchorX: 0, anchorY: 0, x: 0, y: 2732 - 100 }); game.addChild(ground); // Create bird bird = new Bird(); bird.x = 400; bird.y = 2732 / 2; game.addChild(bird); // Create menus mainMenu = new Menu(); mainMenu.onPlay = function () { showGame(); }; mainMenu.onSettings = function () { showSettings(); }; game.addChild(mainMenu); settingsMenu = new Settings(); settingsMenu.onBack = function () { showMainMenu(); }; settingsMenu.onMusicToggle = function (enabled) { musicEnabled = enabled; if (enabled) { LK.playMusic('gameMusic', { fade: { start: 0, end: 0.4, duration: 1000 } }); } else { LK.stopMusic(); } }; settingsMenu.onSoundToggle = function (enabled) { soundEnabled = enabled; }; settingsMenu.visible = false; game.addChild(settingsMenu); // Start music LK.playMusic('gameMusic', { fade: { start: 0, end: 0.4, duration: 1000 } }); // Game functions function spawnPipe() { var pipe = new Pipe(); pipe.x = 2048 + 150; // Start just off-screen // Random gap position between 500 and 2732-500 (avoiding too close to top/bottom) var minY = 500; var maxY = 2732 - 500; var gapY = minY + Math.random() * (maxY - minY); pipe.setGapPosition(gapY); pipes.push(pipe); game.addChild(pipe); // Place pipe behind bird but in front of background game.setChildIndex(pipe, 1); lastPipeX = pipe.x; } function startGame() { if (!isGameStarted) { isGameStarted = true; gameover = false; LK.setScore(0); scoreTxt.setText(0); // Start music if enabled if (musicEnabled) { LK.playMusic('gameMusic', { fade: { start: 0, end: 0.4, duration: 1000 } }); } // Remove start text if (startTxt.parent) { startTxt.parent.removeChild(startTxt); } // Initial bird flap with sound based on settings if (soundEnabled) { bird.flap(); } else { // Just apply velocity without sound bird.velocity = bird.flapStrength; tween(bird, { rotation: -0.5 }, { duration: 100, easing: tween.linear }); } } } function checkCollisions() { // Check if bird hits ground if (bird.y + 40 > ground.y) { bird.y = ground.y - 40; // Prevent bird from going through ground gameOver(); return true; } // Check if bird hits ceiling if (bird.y - 40 < 0) { bird.y = 40; // Prevent bird from going through ceiling bird.velocity = 0; } // Check collision with pipes for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; // Get pipe children (top and bottom pipes) var topPipe = pipe.children[0]; var bottomPipe = pipe.children[1]; // Calculate collision areas var birdLeft = bird.x - 40; var birdRight = bird.x + 40; var birdTop = bird.y - 40; var birdBottom = bird.y + 40; var pipeLeft = pipe.x - 75; var pipeRight = pipe.x + 75; var topPipeBottom = pipe.gapPosition - pipe.gapHeight / 2; var bottomPipeTop = pipe.gapPosition + pipe.gapHeight / 2; // Check for collision if (birdRight > pipeLeft && birdLeft < pipeRight) { if (birdTop < topPipeBottom || birdBottom > bottomPipeTop) { gameOver(); return true; } } // Check for score if (!pipe.scored && birdLeft > pipe.x) { pipe.scored = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); LK.getSound('score').play(); } } return false; } function gameOver() { if (!gameover) { gameover = true; bird.die(); // Flash screen and show game over LK.effects.flashScreen(0xFF0000, 500); // Wait a moment before showing game over LK.setTimeout(function () { LK.showGameOver(); // After game over, show the main menu again LK.setTimeout(function () { showMainMenu(); }, 500); }, 1000); } } function showMainMenu() { gameState = 'MENU'; mainMenu.visible = true; settingsMenu.visible = false; bird.visible = false; // Hide the game elements for (var i = 0; i < pipes.length; i++) { pipes[i].visible = false; } // Remove start text if visible if (startTxt.parent) { startTxt.parent.removeChild(startTxt); } } function showSettings() { gameState = 'SETTINGS'; mainMenu.visible = false; settingsMenu.visible = true; bird.visible = false; } function showGame() { gameState = 'GAME'; mainMenu.visible = false; settingsMenu.visible = false; bird.visible = true; // Show all game elements for (var i = 0; i < pipes.length; i++) { pipes[i].visible = true; } resetGame(); // Add the start text LK.gui.center.addChild(startTxt); } function resetGame() { // Remove all pipes for (var i = pipes.length - 1; i >= 0; i--) { game.removeChild(pipes[i]); pipes[i].destroy(); } pipes = []; // Reset bird bird.velocity = 0; bird.rotation = 0; bird.y = 2732 / 2; bird.isDead = false; // Reset game state isGameStarted = false; gameover = false; pipeSpawnTimer = 0; LK.setScore(0); scoreTxt.setText("0"); // Recreate trees in initial positions createTrees(); // Show start text LK.gui.center.addChild(startTxt); } // Input handlers game.down = function (x, y, obj) { if (gameState === 'MENU' || gameState === 'SETTINGS') { // Menu input is handled by menu button objects return; } if (!isGameStarted) { startGame(); } else if (!gameover) { if (soundEnabled) { bird.flap(); } else { // Just update velocity without sound bird.velocity = bird.flapStrength; // Rotate bird up when flapping tween(bird, { rotation: -0.5 }, { duration: 100, easing: tween.linear }); // Make trees respond to jump even when sound is off for (var i = 0; i < trees.length; i++) { if (trees[i].respondToJump) { trees[i].respondToJump(bird.flapStrength); } } } } }; // Game update loop game.update = function () { // If in menu or settings, don't update game logic if (gameState === 'MENU' || gameState === 'SETTINGS') { return; } if (!isGameStarted) { // Bird gently floats up and down before game starts bird.y = 2732 / 2 + Math.sin(LK.ticks / 30) * 20; return; } if (!gameover) { // Update bird bird.update(); // Spawn pipes pipeSpawnTimer++; if (pipeSpawnTimer >= pipeSpawnInterval) { spawnPipe(); pipeSpawnTimer = 0; } // Update and clean up pipes for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].update(); // Remove pipes that are off-screen if (pipes[i].x < -200) { game.removeChild(pipes[i]); pipes[i].destroy(); pipes.splice(i, 1); } } // Update trees for (var i = 0; i < trees.length; i++) { trees[i].update(); // Reposition trees that are off-screen if (trees[i].x < -100) { var lastTreeX = -Infinity; for (var j = 0; j < trees.length; j++) { if (trees[j].x > lastTreeX) { lastTreeX = trees[j].x; } } trees[i].x = lastTreeX + 400; } // Move trees at half the speed of pipes to create parallax effect trees[i].x -= 2.5; } // Check collisions checkCollisions(); } };
===================================================================
--- original.js
+++ change.js
@@ -26,8 +26,14 @@
}, {
duration: 100,
easing: tween.linear
});
+ // Make trees respond to jump
+ for (var i = 0; i < trees.length; i++) {
+ if (trees[i].respondToJump) {
+ trees[i].respondToJump(self.flapStrength);
+ }
+ }
}
};
self.update = function () {
if (self.isDead) {
@@ -226,8 +232,60 @@
}
};
return self;
});
+var Tree = Container.expand(function () {
+ var self = Container.call(this);
+ // Create tree trunk
+ var trunk = LK.getAsset('ground', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ width: 40,
+ height: 200,
+ tint: 0x8b4513
+ });
+ // Create tree top (leaves)
+ var leaves = LK.getAsset('ground', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ width: 120,
+ height: 150,
+ tint: 0x228B22,
+ y: -200
+ });
+ self.addChild(trunk);
+ self.addChild(leaves);
+ // Variables for movement
+ self.baseY = 0;
+ self.swayAmount = 0;
+ self.swaySpeed = 0.05;
+ self.swayDirection = 1;
+ self.swayOffset = Math.random() * Math.PI * 2; // Random starting phase
+ // Response to bird jump
+ self.respondToJump = function (jumpStrength) {
+ // Add a sway effect when bird jumps
+ tween(self, {
+ rotation: -0.1 * jumpStrength / 12
+ }, {
+ duration: 200,
+ easing: tween.elasticOut,
+ onFinish: function onFinish() {
+ // Return to normal position
+ tween(self, {
+ rotation: 0
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ }
+ });
+ };
+ self.update = function () {
+ // Natural gentle swaying motion
+ self.rotation = Math.sin(LK.ticks * self.swaySpeed + self.swayOffset) * 0.01;
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -240,8 +298,9 @@
****/
// Game variables
var bird;
var pipes = [];
+var trees = [];
var ground;
var background;
var isGameStarted = false;
var pipeSpawnTimer = 0;
@@ -274,8 +333,29 @@
x: 0,
y: 0
});
game.addChild(background);
+// Create trees
+function createTrees() {
+ // Clear existing trees
+ for (var i = trees.length - 1; i >= 0; i--) {
+ game.removeChild(trees[i]);
+ trees[i].destroy();
+ }
+ trees = [];
+ // Create new trees
+ for (var i = 0; i < 5; i++) {
+ var tree = new Tree();
+ tree.x = 200 + i * 400;
+ tree.y = 2732 - 100; // Place on ground
+ tree.baseY = tree.y;
+ game.addChild(tree);
+ trees.push(tree);
+ // Make sure trees are behind bird and pipes
+ game.setChildIndex(tree, 1);
+ }
+}
+createTrees();
// Create ground
ground = LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
@@ -488,8 +568,10 @@
gameover = false;
pipeSpawnTimer = 0;
LK.setScore(0);
scoreTxt.setText("0");
+ // Recreate trees in initial positions
+ createTrees();
// Show start text
LK.gui.center.addChild(startTxt);
}
// Input handlers
@@ -512,8 +594,14 @@
}, {
duration: 100,
easing: tween.linear
});
+ // Make trees respond to jump even when sound is off
+ for (var i = 0; i < trees.length; i++) {
+ if (trees[i].respondToJump) {
+ trees[i].respondToJump(bird.flapStrength);
+ }
+ }
}
}
};
// Game update loop
@@ -545,8 +633,24 @@
pipes[i].destroy();
pipes.splice(i, 1);
}
}
+ // Update trees
+ for (var i = 0; i < trees.length; i++) {
+ trees[i].update();
+ // Reposition trees that are off-screen
+ if (trees[i].x < -100) {
+ var lastTreeX = -Infinity;
+ for (var j = 0; j < trees.length; j++) {
+ if (trees[j].x > lastTreeX) {
+ lastTreeX = trees[j].x;
+ }
+ }
+ trees[i].x = lastTreeX + 400;
+ }
+ // Move trees at half the speed of pipes to create parallax effect
+ trees[i].x -= 2.5;
+ }
// Check collisions
checkCollisions();
}
};
\ No newline at end of file
Orman vektör tarzda. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Orman vektör gökyüzü gölgeli hafif siyah Arka plan. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Ağaç kütüğü vektör tarzda dik bir adet koyu kahverengi. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Sarı muhabbet kuşu sevimli küçük vektör ve piksel sanatı. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Bulut piksel sanatı. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows