User prompt
añade musica
User prompt
haz que las tuberías aparezcan cuando apareces
User prompt
haz que la hitbox de las tuberías coincida con los assets
User prompt
haz que esten un poco mas separado
User prompt
haz que el huequito vaya cambiando de sitio en la tuberia
User prompt
haz las texturas que toquen el cola o la tierra
User prompt
haz que tenga un hueco las tuberías para pasar
User prompt
haz que las partes de arriba o de abajo 👇 no se Bea ósea que la tubería ocupe toda la pantalla
User prompt
mejora las texturas
User prompt
haz que el juego empiece cuando toques la pantalla
User prompt
haz que esten un poco mas separados las tuberías
User prompt
haz que salte un poco mas y que el espacio de las tuberías sea un poco mas grande
User prompt
haz que al tocar el cielo mueras
User prompt
haz que al tocar el suola o la parte mas alta del cielo mueras
User prompt
haz que al tocar una tubería mueras automáticamente
User prompt
haz que las tuberías estén un poco mas separadas
User prompt
haz que los huis sea un poco mas grandes
User prompt
haz que las tuberías ocupen todo verticalmente
Code edit (1 edits merged)
Please save this source code
User prompt
Soaring Wings - Dynamic Flappy Adventure
Initial prompt
Creas un flappy bird con buenas físicas que sea realista con buenas gráficos y que vaya cambiando el fondo
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Background = Container.expand(function () {
var self = Container.call(this);
self.backgroundLayers = [];
self.currentTheme = 0;
self.themes = ['background1', 'background2', 'background3'];
self.transitionTimer = 0;
self.transitionDuration = 1800; // 30 seconds at 60fps
// Create initial background
var bg1 = self.attachAsset(self.themes[self.currentTheme], {
anchorX: 0,
anchorY: 0
});
self.backgroundLayers.push(bg1);
self.update = function () {
self.transitionTimer++;
if (self.transitionTimer >= self.transitionDuration) {
self.transitionTimer = 0;
self.currentTheme = (self.currentTheme + 1) % self.themes.length;
// Create new background for transition
var newBg = LK.getAsset(self.themes[self.currentTheme], {
anchorX: 0,
anchorY: 0,
alpha: 0
});
self.addChild(newBg);
self.backgroundLayers.push(newBg);
// Fade in new background
tween(newBg, {
alpha: 1
}, {
duration: 2000
});
// Fade out old backgrounds
for (var i = 0; i < self.backgroundLayers.length - 1; i++) {
var oldBg = self.backgroundLayers[i];
tween(oldBg, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
oldBg.destroy();
}
});
}
// Keep only the new background in array
self.backgroundLayers = [newBg];
}
};
return self;
});
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 0;
self.gravity = 0.8;
self.flapPower = -12;
self.maxFallSpeed = 15;
self.isDead = false;
self.flap = function () {
if (!self.isDead) {
self.velocityY = self.flapPower;
LK.getSound('flap').play();
// Wing flap animation
tween(birdGraphics, {
scaleY: 1.2
}, {
duration: 100,
onFinish: function onFinish() {
tween(birdGraphics, {
scaleY: 1.0
}, {
duration: 100
});
}
});
}
};
self.update = function () {
if (!self.isDead) {
// Apply gravity
self.velocityY += self.gravity;
// Limit fall speed
if (self.velocityY > self.maxFallSpeed) {
self.velocityY = self.maxFallSpeed;
}
// Update position
self.y += self.velocityY;
// Rotate bird based on velocity
var targetRotation = Math.min(Math.max(self.velocityY * 0.1, -0.5), 1.5);
birdGraphics.rotation = targetRotation;
// Keep bird in bounds
if (self.y < 0) {
self.y = 0;
self.velocityY = 0;
}
if (self.y > 2732 - 150 - 30) {
// Ground collision
self.y = 2732 - 150 - 30;
self.die();
}
}
};
self.die = function () {
if (!self.isDead) {
self.isDead = true;
LK.getSound('hit').play();
// Death animation
tween(birdGraphics, {
rotation: Math.PI,
alpha: 0.7
}, {
duration: 1000
});
tween(self, {
y: 2732 - 150 - 30
}, {
duration: 1000,
easing: tween.bounceOut
});
}
};
return self;
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -1;
self.update = function () {
self.x += self.speed;
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.gapSize = 300;
self.speed = -4;
self.scored = false;
// Top pipe
var topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
// Bottom pipe
var bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
self.setGapPosition = function (gapY) {
topPipe.y = gapY - self.gapSize / 2;
bottomPipe.y = gapY + self.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 clouds = [];
var ground;
var backgroundSystem;
var gameStarted = false;
var pipeSpawnTimer = 0;
var cloudSpawnTimer = 0;
var difficultyTimer = 0;
// UI
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
var instructionTxt = new Text2('TAP TO FLAP', {
size: 80,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionTxt);
// Initialize background system
backgroundSystem = game.addChild(new Background());
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2732 - 150
}));
// Create bird
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = 1366;
// Initial clouds
for (var i = 0; i < 3; i++) {
var cloud = game.addChild(new Cloud());
cloud.x = Math.random() * 2048;
cloud.y = Math.random() * 800 + 200;
cloud.alpha = 0.7;
clouds.push(cloud);
}
function startGame() {
if (!gameStarted) {
gameStarted = true;
instructionTxt.visible = false;
}
}
function spawnPipe() {
var pipe = game.addChild(new Pipe());
pipe.x = 2048 + 60;
// Dynamic difficulty - reduce gap size over time
var difficultyFactor = Math.min(LK.getScore() * 0.02, 0.3);
pipe.gapSize = Math.max(250 - difficultyFactor * 100, 180);
var gapY = Math.random() * (1800 - 600) + 600;
pipe.setGapPosition(gapY);
pipes.push(pipe);
}
function spawnCloud() {
var cloud = game.addChild(new Cloud());
cloud.x = 2048 + 100;
cloud.y = Math.random() * 1000 + 200;
cloud.alpha = 0.6;
cloud.scaleX = Math.random() * 0.5 + 0.5;
cloud.scaleY = Math.random() * 0.5 + 0.5;
clouds.push(cloud);
}
// Game input
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
}
bird.flap();
};
// Game update loop
game.update = function () {
// Update background system
backgroundSystem.update();
if (gameStarted && !bird.isDead) {
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= 90) {
// Every 1.5 seconds
pipeSpawnTimer = 0;
spawnPipe();
}
// Spawn clouds
cloudSpawnTimer++;
if (cloudSpawnTimer >= 240) {
// Every 4 seconds
cloudSpawnTimer = 0;
spawnCloud();
}
// Update and check 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
if (pipe.intersects(bird)) {
bird.die();
LK.effects.flashScreen(0xff0000, 500);
LK.setTimeout(function () {
LK.showGameOver();
}, 1500);
}
// Remove off-screen pipes
if (pipe.x < -150) {
pipe.destroy();
pipes.splice(i, 1);
}
}
// Update and manage clouds
for (var j = clouds.length - 1; j >= 0; j--) {
var cloud = clouds[j];
if (cloud.x < -250) {
cloud.destroy();
clouds.splice(j, 1);
}
}
}
// Show game over if bird hits ground
if (bird.isDead && bird.y >= 2732 - 150 - 30) {
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,317 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Background = Container.expand(function () {
+ var self = Container.call(this);
+ self.backgroundLayers = [];
+ self.currentTheme = 0;
+ self.themes = ['background1', 'background2', 'background3'];
+ self.transitionTimer = 0;
+ self.transitionDuration = 1800; // 30 seconds at 60fps
+ // Create initial background
+ var bg1 = self.attachAsset(self.themes[self.currentTheme], {
+ anchorX: 0,
+ anchorY: 0
+ });
+ self.backgroundLayers.push(bg1);
+ self.update = function () {
+ self.transitionTimer++;
+ if (self.transitionTimer >= self.transitionDuration) {
+ self.transitionTimer = 0;
+ self.currentTheme = (self.currentTheme + 1) % self.themes.length;
+ // Create new background for transition
+ var newBg = LK.getAsset(self.themes[self.currentTheme], {
+ anchorX: 0,
+ anchorY: 0,
+ alpha: 0
+ });
+ self.addChild(newBg);
+ self.backgroundLayers.push(newBg);
+ // Fade in new background
+ tween(newBg, {
+ alpha: 1
+ }, {
+ duration: 2000
+ });
+ // Fade out old backgrounds
+ for (var i = 0; i < self.backgroundLayers.length - 1; i++) {
+ var oldBg = self.backgroundLayers[i];
+ tween(oldBg, {
+ alpha: 0
+ }, {
+ duration: 2000,
+ onFinish: function onFinish() {
+ oldBg.destroy();
+ }
+ });
+ }
+ // Keep only the new background in array
+ self.backgroundLayers = [newBg];
+ }
+ };
+ return self;
+});
+var Bird = Container.expand(function () {
+ var self = Container.call(this);
+ var birdGraphics = self.attachAsset('bird', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocityY = 0;
+ self.gravity = 0.8;
+ self.flapPower = -12;
+ self.maxFallSpeed = 15;
+ self.isDead = false;
+ self.flap = function () {
+ if (!self.isDead) {
+ self.velocityY = self.flapPower;
+ LK.getSound('flap').play();
+ // Wing flap animation
+ tween(birdGraphics, {
+ scaleY: 1.2
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(birdGraphics, {
+ scaleY: 1.0
+ }, {
+ duration: 100
+ });
+ }
+ });
+ }
+ };
+ self.update = function () {
+ if (!self.isDead) {
+ // Apply gravity
+ self.velocityY += self.gravity;
+ // Limit fall speed
+ if (self.velocityY > self.maxFallSpeed) {
+ self.velocityY = self.maxFallSpeed;
+ }
+ // Update position
+ self.y += self.velocityY;
+ // Rotate bird based on velocity
+ var targetRotation = Math.min(Math.max(self.velocityY * 0.1, -0.5), 1.5);
+ birdGraphics.rotation = targetRotation;
+ // Keep bird in bounds
+ if (self.y < 0) {
+ self.y = 0;
+ self.velocityY = 0;
+ }
+ if (self.y > 2732 - 150 - 30) {
+ // Ground collision
+ self.y = 2732 - 150 - 30;
+ self.die();
+ }
+ }
+ };
+ self.die = function () {
+ if (!self.isDead) {
+ self.isDead = true;
+ LK.getSound('hit').play();
+ // Death animation
+ tween(birdGraphics, {
+ rotation: Math.PI,
+ alpha: 0.7
+ }, {
+ duration: 1000
+ });
+ tween(self, {
+ y: 2732 - 150 - 30
+ }, {
+ duration: 1000,
+ easing: tween.bounceOut
+ });
+ }
+ };
+ return self;
+});
+var Cloud = Container.expand(function () {
+ var self = Container.call(this);
+ var cloudGraphics = self.attachAsset('cloud', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -1;
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
+var Pipe = Container.expand(function () {
+ var self = Container.call(this);
+ self.gapSize = 300;
+ self.speed = -4;
+ self.scored = false;
+ // Top pipe
+ var topPipe = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ // Bottom pipe
+ var bottomPipe = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ self.setGapPosition = function (gapY) {
+ topPipe.y = gapY - self.gapSize / 2;
+ bottomPipe.y = gapY + self.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 clouds = [];
+var ground;
+var backgroundSystem;
+var gameStarted = false;
+var pipeSpawnTimer = 0;
+var cloudSpawnTimer = 0;
+var difficultyTimer = 0;
+// UI
+var scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+scoreTxt.y = 100;
+var instructionTxt = new Text2('TAP TO FLAP', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+instructionTxt.anchor.set(0.5, 0.5);
+LK.gui.center.addChild(instructionTxt);
+// Initialize background system
+backgroundSystem = game.addChild(new Background());
+// Create ground
+ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 2732 - 150
+}));
+// Create bird
+bird = game.addChild(new Bird());
+bird.x = 300;
+bird.y = 1366;
+// Initial clouds
+for (var i = 0; i < 3; i++) {
+ var cloud = game.addChild(new Cloud());
+ cloud.x = Math.random() * 2048;
+ cloud.y = Math.random() * 800 + 200;
+ cloud.alpha = 0.7;
+ clouds.push(cloud);
+}
+function startGame() {
+ if (!gameStarted) {
+ gameStarted = true;
+ instructionTxt.visible = false;
+ }
+}
+function spawnPipe() {
+ var pipe = game.addChild(new Pipe());
+ pipe.x = 2048 + 60;
+ // Dynamic difficulty - reduce gap size over time
+ var difficultyFactor = Math.min(LK.getScore() * 0.02, 0.3);
+ pipe.gapSize = Math.max(250 - difficultyFactor * 100, 180);
+ var gapY = Math.random() * (1800 - 600) + 600;
+ pipe.setGapPosition(gapY);
+ pipes.push(pipe);
+}
+function spawnCloud() {
+ var cloud = game.addChild(new Cloud());
+ cloud.x = 2048 + 100;
+ cloud.y = Math.random() * 1000 + 200;
+ cloud.alpha = 0.6;
+ cloud.scaleX = Math.random() * 0.5 + 0.5;
+ cloud.scaleY = Math.random() * 0.5 + 0.5;
+ clouds.push(cloud);
+}
+// Game input
+game.down = function (x, y, obj) {
+ if (!gameStarted) {
+ startGame();
+ }
+ bird.flap();
+};
+// Game update loop
+game.update = function () {
+ // Update background system
+ backgroundSystem.update();
+ if (gameStarted && !bird.isDead) {
+ // Spawn pipes
+ pipeSpawnTimer++;
+ if (pipeSpawnTimer >= 90) {
+ // Every 1.5 seconds
+ pipeSpawnTimer = 0;
+ spawnPipe();
+ }
+ // Spawn clouds
+ cloudSpawnTimer++;
+ if (cloudSpawnTimer >= 240) {
+ // Every 4 seconds
+ cloudSpawnTimer = 0;
+ spawnCloud();
+ }
+ // Update and check 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
+ if (pipe.intersects(bird)) {
+ bird.die();
+ LK.effects.flashScreen(0xff0000, 500);
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 1500);
+ }
+ // Remove off-screen pipes
+ if (pipe.x < -150) {
+ pipe.destroy();
+ pipes.splice(i, 1);
+ }
+ }
+ // Update and manage clouds
+ for (var j = clouds.length - 1; j >= 0; j--) {
+ var cloud = clouds[j];
+ if (cloud.x < -250) {
+ cloud.destroy();
+ clouds.splice(j, 1);
+ }
+ }
+ }
+ // Show game over if bird hits ground
+ if (bird.isDead && bird.y >= 2732 - 150 - 30) {
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 1000);
+ }
+};
\ No newline at end of file