User prompt
El terreno sea un poco más largo
User prompt
Agrega física al pájaro para que salte un poco más
User prompt
Que los birds sean un poco grandes pero no tan grandes
User prompt
Que no sea difícil pasar los obstáculos
User prompt
Los obstáculos que sean un poco más fácil de pasar y que los tubos sean largos
User prompt
Los obstáculos que estén un poco alejados para que de tiempo de pasarlo
User prompt
Mejora la colicion al morir y mejora los obstáculos donde aparecen
User prompt
Ahora hazlo un poco más grande el juego
User prompt
Cada vez que doy tap to play muero arreglalo y has que al dar tap to play comienze el juego parecido a flappy bird ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Al tocar play no muera corrige el error
User prompt
Arregla ese error que es al tocar la pantalla me muero pon un botón que diga play para comenzar el juego
User prompt
Un botón para cambiar de personaje ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
Crea un menú o menu de carga que diga play y que entre en la pantalla ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
La generación de terreno que sea más realista y los obstáculos también y corrige el sistema de puntos cada vez que me da un punto me muero ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Uncaught TypeError: storage.getInt is not a function' in or related to this line: 'var bestScore = storage.getInt('highScore', 0);' Line Number: 236 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Que tenga un menú y pantalla un poco más chico para que sea un juego de celular
Code edit (1 edits merged)
Please save this source code
User prompt
Flappy Wings
Initial prompt
Has un juego como Flappy Bird
/**** * 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.8; self.flapPower = -12; self.maxVelocity = 15; self.minVelocity = -15; self.flap = function () { self.velocity = self.flapPower; LK.getSound('flap').play(); // Add slight rotation animation tween(birdGraphics, { rotation: -0.3 }, { duration: 100 }); tween(birdGraphics, { rotation: 0.5 }, { duration: 200, onFinish: function onFinish() { tween(birdGraphics, { rotation: 0 }, { duration: 300 }); } }); }; self.update = function () { // Apply gravity self.velocity += self.gravity; // Limit velocity if (self.velocity > self.maxVelocity) self.velocity = self.maxVelocity; if (self.velocity < self.minVelocity) self.velocity = self.minVelocity; // Update position self.y += self.velocity; // Rotate bird based on velocity var targetRotation = Math.max(-0.5, Math.min(0.8, self.velocity * 0.05)); birdGraphics.rotation = targetRotation; }; return self; }); var Pipe = Container.expand(function () { var self = Container.call(this); self.speed = -4; self.scored = false; // Create top pipe self.topPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 1 }); // Create bottom pipe self.bottomPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0 }); self.setGap = function (centerY, gapSize) { self.topPipe.y = centerY - gapSize / 2; self.bottomPipe.y = centerY + gapSize / 2; }; self.update = function () { self.x += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var bird; var pipes = []; var ground; var gameStarted = false; var gameOver = false; var pipeSpawnTimer = 0; var pipeSpawnInterval = 90; // frames var gapSize = 300; var scrollSpeed = 4; // UI Elements var scoreTxt = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var instructionTxt = new Text2('TAP TO START', { size: 60, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2 - 200; game.addChild(instructionTxt); // Initialize bird bird = game.addChild(new Bird()); bird.x = 2048 / 4; bird.y = 2732 / 2; // Create ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1 })); ground.x = 0; ground.y = 2732; // Function to spawn pipe function spawnPipe() { var pipe = new Pipe(); var centerY = 400 + Math.random() * (2732 - 600 - gapSize); pipe.setGap(centerY, gapSize); pipe.x = 2048 + 100; pipes.push(pipe); game.addChild(pipe); } // Function to start game function startGame() { if (!gameStarted && !gameOver) { gameStarted = true; instructionTxt.visible = false; bird.flap(); } } // Function to reset game function resetGame() { // Clean up pipes for (var i = 0; i < pipes.length; i++) { pipes[i].destroy(); } pipes = []; // Reset bird bird.x = 2048 / 4; bird.y = 2732 / 2; bird.velocity = 0; // Reset game state gameStarted = false; gameOver = false; pipeSpawnTimer = 0; LK.setScore(0); scoreTxt.setText('0'); // Show instruction instructionTxt.visible = true; } // Touch/click handlers game.down = function (x, y, obj) { if (!gameStarted) { startGame(); } else if (!gameOver) { bird.flap(); } else { resetGame(); } }; // Main game loop game.update = function () { if (!gameStarted || gameOver) return; // Spawn pipes pipeSpawnTimer++; if (pipeSpawnTimer >= pipeSpawnInterval) { spawnPipe(); pipeSpawnTimer = 0; } // Update pipes for (var i = pipes.length - 1; i >= 0; i--) { var pipe = pipes[i]; // Check for scoring if (!pipe.scored && pipe.x + 60 < bird.x) { pipe.scored = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); LK.getSound('score').play(); } // Check collision with bird var birdBounds = { x: bird.x - 40, y: bird.y - 30, width: 80, height: 60 }; var topPipeBounds = { x: pipe.x - 60, y: 0, width: 120, height: pipe.topPipe.y }; var bottomPipeBounds = { x: pipe.x - 60, y: pipe.bottomPipe.y, width: 120, height: 2732 - pipe.bottomPipe.y }; // Check collision if (birdBounds.x < topPipeBounds.x + topPipeBounds.width && birdBounds.x + birdBounds.width > topPipeBounds.x && birdBounds.y < topPipeBounds.y + topPipeBounds.height && birdBounds.y + birdBounds.height > topPipeBounds.y || birdBounds.x < bottomPipeBounds.x + bottomPipeBounds.width && birdBounds.x + birdBounds.width > bottomPipeBounds.x && birdBounds.y < bottomPipeBounds.y + bottomPipeBounds.height && birdBounds.y + birdBounds.height > bottomPipeBounds.y) { gameOver = true; LK.getSound('hit').play(); LK.effects.flashScreen(0xff0000, 500); LK.showGameOver(); return; } // Remove off-screen pipes if (pipe.x < -200) { pipe.destroy(); pipes.splice(i, 1); } } // Check ground collision if (bird.y + 30 >= ground.y) { gameOver = true; LK.getSound('hit').play(); LK.effects.flashScreen(0xff0000, 500); LK.showGameOver(); return; } // Check ceiling collision if (bird.y - 30 <= 0) { gameOver = true; LK.getSound('hit').play(); LK.effects.flashScreen(0xff0000, 500); LK.showGameOver(); return; } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,241 @@
-/****
+/****
+* 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.8;
+ self.flapPower = -12;
+ self.maxVelocity = 15;
+ self.minVelocity = -15;
+ self.flap = function () {
+ self.velocity = self.flapPower;
+ LK.getSound('flap').play();
+ // Add slight rotation animation
+ tween(birdGraphics, {
+ rotation: -0.3
+ }, {
+ duration: 100
+ });
+ tween(birdGraphics, {
+ rotation: 0.5
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ tween(birdGraphics, {
+ rotation: 0
+ }, {
+ duration: 300
+ });
+ }
+ });
+ };
+ self.update = function () {
+ // Apply gravity
+ self.velocity += self.gravity;
+ // Limit velocity
+ if (self.velocity > self.maxVelocity) self.velocity = self.maxVelocity;
+ if (self.velocity < self.minVelocity) self.velocity = self.minVelocity;
+ // Update position
+ self.y += self.velocity;
+ // Rotate bird based on velocity
+ var targetRotation = Math.max(-0.5, Math.min(0.8, self.velocity * 0.05));
+ birdGraphics.rotation = targetRotation;
+ };
+ return self;
+});
+var Pipe = Container.expand(function () {
+ var self = Container.call(this);
+ self.speed = -4;
+ self.scored = false;
+ // Create top pipe
+ self.topPipe = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ // Create bottom pipe
+ self.bottomPipe = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ self.setGap = function (centerY, gapSize) {
+ self.topPipe.y = centerY - gapSize / 2;
+ self.bottomPipe.y = centerY + gapSize / 2;
+ };
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var bird;
+var pipes = [];
+var ground;
+var gameStarted = false;
+var gameOver = false;
+var pipeSpawnTimer = 0;
+var pipeSpawnInterval = 90; // frames
+var gapSize = 300;
+var scrollSpeed = 4;
+// UI Elements
+var scoreTxt = new Text2('0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+var instructionTxt = new Text2('TAP TO START', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+instructionTxt.anchor.set(0.5, 0.5);
+instructionTxt.x = 2048 / 2;
+instructionTxt.y = 2732 / 2 - 200;
+game.addChild(instructionTxt);
+// Initialize bird
+bird = game.addChild(new Bird());
+bird.x = 2048 / 4;
+bird.y = 2732 / 2;
+// Create ground
+ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 1
+}));
+ground.x = 0;
+ground.y = 2732;
+// Function to spawn pipe
+function spawnPipe() {
+ var pipe = new Pipe();
+ var centerY = 400 + Math.random() * (2732 - 600 - gapSize);
+ pipe.setGap(centerY, gapSize);
+ pipe.x = 2048 + 100;
+ pipes.push(pipe);
+ game.addChild(pipe);
+}
+// Function to start game
+function startGame() {
+ if (!gameStarted && !gameOver) {
+ gameStarted = true;
+ instructionTxt.visible = false;
+ bird.flap();
+ }
+}
+// Function to reset game
+function resetGame() {
+ // Clean up pipes
+ for (var i = 0; i < pipes.length; i++) {
+ pipes[i].destroy();
+ }
+ pipes = [];
+ // Reset bird
+ bird.x = 2048 / 4;
+ bird.y = 2732 / 2;
+ bird.velocity = 0;
+ // Reset game state
+ gameStarted = false;
+ gameOver = false;
+ pipeSpawnTimer = 0;
+ LK.setScore(0);
+ scoreTxt.setText('0');
+ // Show instruction
+ instructionTxt.visible = true;
+}
+// Touch/click handlers
+game.down = function (x, y, obj) {
+ if (!gameStarted) {
+ startGame();
+ } else if (!gameOver) {
+ bird.flap();
+ } else {
+ resetGame();
+ }
+};
+// Main game loop
+game.update = function () {
+ if (!gameStarted || gameOver) return;
+ // Spawn pipes
+ pipeSpawnTimer++;
+ if (pipeSpawnTimer >= pipeSpawnInterval) {
+ spawnPipe();
+ pipeSpawnTimer = 0;
+ }
+ // Update pipes
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ var pipe = pipes[i];
+ // Check for scoring
+ if (!pipe.scored && pipe.x + 60 < bird.x) {
+ pipe.scored = true;
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ LK.getSound('score').play();
+ }
+ // Check collision with bird
+ var birdBounds = {
+ x: bird.x - 40,
+ y: bird.y - 30,
+ width: 80,
+ height: 60
+ };
+ var topPipeBounds = {
+ x: pipe.x - 60,
+ y: 0,
+ width: 120,
+ height: pipe.topPipe.y
+ };
+ var bottomPipeBounds = {
+ x: pipe.x - 60,
+ y: pipe.bottomPipe.y,
+ width: 120,
+ height: 2732 - pipe.bottomPipe.y
+ };
+ // Check collision
+ if (birdBounds.x < topPipeBounds.x + topPipeBounds.width && birdBounds.x + birdBounds.width > topPipeBounds.x && birdBounds.y < topPipeBounds.y + topPipeBounds.height && birdBounds.y + birdBounds.height > topPipeBounds.y || birdBounds.x < bottomPipeBounds.x + bottomPipeBounds.width && birdBounds.x + birdBounds.width > bottomPipeBounds.x && birdBounds.y < bottomPipeBounds.y + bottomPipeBounds.height && birdBounds.y + birdBounds.height > bottomPipeBounds.y) {
+ gameOver = true;
+ LK.getSound('hit').play();
+ LK.effects.flashScreen(0xff0000, 500);
+ LK.showGameOver();
+ return;
+ }
+ // Remove off-screen pipes
+ if (pipe.x < -200) {
+ pipe.destroy();
+ pipes.splice(i, 1);
+ }
+ }
+ // Check ground collision
+ if (bird.y + 30 >= ground.y) {
+ gameOver = true;
+ LK.getSound('hit').play();
+ LK.effects.flashScreen(0xff0000, 500);
+ LK.showGameOver();
+ return;
+ }
+ // Check ceiling collision
+ if (bird.y - 30 <= 0) {
+ gameOver = true;
+ LK.getSound('hit').play();
+ LK.effects.flashScreen(0xff0000, 500);
+ LK.showGameOver();
+ return;
+ }
+};
\ No newline at end of file