User prompt
Make the spikes disappear every bounce
User prompt
Make it so if the bird bounces on the right side the spike appears on the other side and vice versa
User prompt
Make it appear randomly on the walls every bounce
User prompt
Make a spike that sticks on the wall
User prompt
Make it flap the other way
User prompt
Make the bird rotate correctly
User prompt
No make it FLAP in the right direction
User prompt
Now make him flap the correct direction
Code edit (1 edits merged)
Please save this source code
User prompt
Make the bird face the direction it’s flying
User prompt
Still broken
User prompt
Can you fix this
User prompt
Make the bird faster
User prompt
Make the gravity stronger
User prompt
Make the bird jump higher
User prompt
Make the bird bigger
User prompt
Fix the bug that makes the bird stick to the wall
User prompt
Make the gravity stronger
User prompt
Make the bird faster and jump higher
User prompt
Make the bird larger
User prompt
Stop the seeds from moving
User prompt
Make it so every time the bird bounces two seeds spawn on the screen and despawn on the next bounce
User prompt
Can you make this game
User prompt
Bounce Bird
Initial prompt
Can you make a game where you’re a bird that clicks to fly and bounces off the walls called bounce bird
/**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); // Bird asset var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.5, scaleY: 3.5 }); // Bird physics properties self.velocityY = 0; self.velocityX = 12; // Increased from 8 to 12 for faster horizontal movement self.gravity = 1.0; // Increased from 0.7 to 1.0 for stronger gravity self.flapStrength = -20; // Increased from -15 to -20 for higher jumps self.lastX = 0; self.lastY = 0; self.lastWasIntersecting = false; // Handle tap/click on bird self.down = function (x, y, obj) { self.flap(); }; // Make bird flap wings self.flap = function () { self.velocityY = self.flapStrength; }; // Update bird physics self.update = function () { // Store last position self.lastX = self.x; self.lastY = self.y; // Apply gravity self.velocityY += self.gravity; // Update position self.y += self.velocityY; self.x += self.velocityX; // Visual feedback - rotate bird based on velocity var targetRotation = Math.min(Math.max(self.velocityY / 15, -0.5), 0.5); // Make bird face the direction it's flying by flipping the sprite if (self.velocityX > 0) { birdGraphics.scaleX = Math.abs(birdGraphics.scaleX); // Face right birdGraphics.rotation = targetRotation; // Apply rotation normally for right-facing bird } else { birdGraphics.scaleX = -Math.abs(birdGraphics.scaleX); // Face left birdGraphics.rotation = -targetRotation; // Invert rotation for left-facing bird } }; return self; }); var Seed = Container.expand(function () { var self = Container.call(this); // Seed asset var seedGraphics = self.attachAsset('seed', { anchorX: 0.5, anchorY: 0.5 }); // Seed properties self.lastWasIntersecting = false; self.speedX = 0; // Set speed to 0 to stop seeds from moving // Animation effect self.update = function () { // No longer updating x position seedGraphics.rotation += 0.05; // Remove seeds that are off-screen if (self.x < -50) { self.shouldBeRemoved = true; } }; return self; }); var Spike = Container.expand(function () { var self = Container.call(this); // Create spike shape using a triangle var spikeGraphics = self.attachAsset('shape', { width: 50, height: 50, color: 0xFF0000, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); // Rotate to make it look like a spike spikeGraphics.rotation = Math.PI / 4; // 45 degrees self.isStuck = false; self.wall = null; self.lastWasIntersecting = false; // Stick to a wall self.stickTo = function (wall) { self.isStuck = true; self.wall = wall; // Position on wall edge based on wall orientation if (wall.isVertical) { self.x = wall.x + (wall.x < 1024 ? 30 : -30); // Left or right wall // Keep y position where the collision happened } else { self.y = wall.y + (wall.y < 1366 ? 30 : -30); // Top or bottom wall // Keep x position where the collision happened } }; self.update = function () { // Nothing to update when stuck if (!self.isStuck) { // If not stuck, spike can move or be collected later self.rotation += 0.05; } }; return self; }); var Wall = Container.expand(function () { var self = Container.call(this); // Wall properties self.isVertical = true; self.wallGraphics = null; // Initialize with wall type (vertical/horizontal) self.init = function (vertical) { self.isVertical = vertical; if (vertical) { self.wallGraphics = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); } else { self.wallGraphics = self.attachAsset('ceiling', { anchorX: 0.5, anchorY: 0.5 }); } return self; }; return self; }); /**** * Initialize Game ****/ // Change background color to sky blue var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Assets for Bounce Bird // Change background color to sky blue game.setBackgroundColor(0x87CEEB); // Game variables var bird; var walls = []; var seeds = []; var spikes = []; var score = 0; var gameWidth = 2048; var gameHeight = 2732; // Create score text var scoreText = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreText.anchor.set(0, 0); LK.gui.topLeft.addChild(scoreText); scoreText.x = 120; // Avoid the top-left 100x100 menu area scoreText.y = 50; // Create bird bird = new Bird(); bird.x = gameWidth / 4; bird.y = gameHeight / 2; game.addChild(bird); // Create walls (top, bottom, left, right) function createWalls() { // Top wall (ceiling) var ceiling = new Wall().init(false); ceiling.x = gameWidth / 2; ceiling.y = 20; game.addChild(ceiling); walls.push(ceiling); // Bottom wall (floor) var floor = new Wall().init(false); floor.x = gameWidth / 2; floor.y = gameHeight - 20; game.addChild(floor); walls.push(floor); // Left wall var leftWall = new Wall().init(true); leftWall.x = 20; leftWall.y = gameHeight / 2; game.addChild(leftWall); walls.push(leftWall); // Right wall var rightWall = new Wall().init(true); rightWall.x = gameWidth - 20; rightWall.y = gameHeight / 2; game.addChild(rightWall); walls.push(rightWall); } // Create initial walls createWalls(); // Spawn a new seed at a random position function spawnSeed() { var seed = new Seed(); seed.x = gameWidth + 50; seed.y = Math.random() * (gameHeight - 200) + 100; seeds.push(seed); game.addChild(seed); } // Handle click/tap anywhere on screen game.down = function (x, y, obj) { bird.flap(); }; // Update function game.update = function () { // Seeds now spawn on bounce, not periodically // Update seeds for (var i = seeds.length - 1; i >= 0; i--) { var seed = seeds[i]; // Check for collision with bird var currentIntersecting = bird.intersects(seed); if (!seed.lastWasIntersecting && currentIntersecting) { // Collected seed score++; scoreText.setText("Score: " + score); LK.setScore(score); LK.getSound('collect').play(); // Remove seed seed.destroy(); seeds.splice(i, 1); } else { seed.lastWasIntersecting = currentIntersecting; // Remove seeds that should be removed if (seed.shouldBeRemoved) { seed.destroy(); seeds.splice(i, 1); } } } // Check for wall collisions for (var i = 0; i < walls.length; i++) { var wall = walls[i]; var currentIntersecting = bird.intersects(wall); if (!bird.lastWasIntersecting && currentIntersecting) { // Bird hit a wall - bounce! LK.getSound('bounce').play(); // Apply bounce physics based on which wall was hit if (wall.isVertical) { bird.velocityX *= -1; // Reverse horizontal direction // Push bird away from wall to prevent sticking bird.x += bird.velocityX > 0 ? 5 : -5; } else { bird.velocityY *= -0.8; // Reverse vertical direction with dampening // Push bird away from ceiling/floor to prevent sticking bird.y += bird.velocityY > 0 ? 5 : -5; } // Visual feedback for bounce LK.effects.flashObject(bird, 0xFFFFFF, 200); // Clear old seeds on bounce for (var j = seeds.length - 1; j >= 0; j--) { seeds[j].destroy(); seeds.splice(j, 1); } // Spawn two new seeds on bounce for (var k = 0; k < 2; k++) { var newSeed = new Seed(); newSeed.x = Math.random() * (gameWidth - 200) + 100; newSeed.y = Math.random() * (gameHeight - 200) + 100; seeds.push(newSeed); game.addChild(newSeed); } // Add a spike that sticks to the wall var spike = new Spike(); spike.x = bird.x; spike.y = bird.y; spike.stickTo(wall); spikes.push(spike); game.addChild(spike); // Set lastWasIntersecting for the specific wall collision that just happened bird.lastWasIntersecting = true; break; // Exit the loop after handling a collision } } // Reset lastWasIntersecting if not intersecting any wall var intersectingAnyWall = false; for (var i = 0; i < walls.length; i++) { if (bird.intersects(walls[i])) { intersectingAnyWall = true; break; } } if (!intersectingAnyWall) { bird.lastWasIntersecting = false; } // Check for spike collisions for (var i = 0; i < spikes.length; i++) { var spike = spikes[i]; var currentIntersecting = bird.intersects(spike); if (!spike.lastWasIntersecting && currentIntersecting) { // Bird hit a spike - game over! LK.effects.flashScreen(0xFF0000, 500); LK.showGameOver(); break; } spike.lastWasIntersecting = currentIntersecting; } // Check if bird flew off screen (game over condition) if (bird.y < -100 || bird.y > gameHeight + 100 || bird.x < -100 || bird.x > gameWidth + 100) { LK.effects.flashScreen(0xFF0000, 500); LK.showGameOver(); } };
===================================================================
--- original.js
+++ change.js
@@ -43,9 +43,9 @@
birdGraphics.scaleX = Math.abs(birdGraphics.scaleX); // Face right
birdGraphics.rotation = targetRotation; // Apply rotation normally for right-facing bird
} else {
birdGraphics.scaleX = -Math.abs(birdGraphics.scaleX); // Face left
- birdGraphics.rotation = targetRotation; // Use same rotation for left-facing bird (no negative)
+ birdGraphics.rotation = -targetRotation; // Invert rotation for left-facing bird
}
};
return self;
});
@@ -69,8 +69,46 @@
}
};
return self;
});
+var Spike = Container.expand(function () {
+ var self = Container.call(this);
+ // Create spike shape using a triangle
+ var spikeGraphics = self.attachAsset('shape', {
+ width: 50,
+ height: 50,
+ color: 0xFF0000,
+ shape: 'box',
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Rotate to make it look like a spike
+ spikeGraphics.rotation = Math.PI / 4; // 45 degrees
+ self.isStuck = false;
+ self.wall = null;
+ self.lastWasIntersecting = false;
+ // Stick to a wall
+ self.stickTo = function (wall) {
+ self.isStuck = true;
+ self.wall = wall;
+ // Position on wall edge based on wall orientation
+ if (wall.isVertical) {
+ self.x = wall.x + (wall.x < 1024 ? 30 : -30); // Left or right wall
+ // Keep y position where the collision happened
+ } else {
+ self.y = wall.y + (wall.y < 1366 ? 30 : -30); // Top or bottom wall
+ // Keep x position where the collision happened
+ }
+ };
+ self.update = function () {
+ // Nothing to update when stuck
+ if (!self.isStuck) {
+ // If not stuck, spike can move or be collected later
+ self.rotation += 0.05;
+ }
+ };
+ return self;
+});
var Wall = Container.expand(function () {
var self = Container.call(this);
// Wall properties
self.isVertical = true;
@@ -104,15 +142,16 @@
/****
* Game Code
****/
-// Change background color to sky blue
// Assets for Bounce Bird
+// Change background color to sky blue
game.setBackgroundColor(0x87CEEB);
// Game variables
var bird;
var walls = [];
var seeds = [];
+var spikes = [];
var score = 0;
var gameWidth = 2048;
var gameHeight = 2732;
// Create score text
@@ -227,8 +266,15 @@
newSeed.y = Math.random() * (gameHeight - 200) + 100;
seeds.push(newSeed);
game.addChild(newSeed);
}
+ // Add a spike that sticks to the wall
+ var spike = new Spike();
+ spike.x = bird.x;
+ spike.y = bird.y;
+ spike.stickTo(wall);
+ spikes.push(spike);
+ game.addChild(spike);
// Set lastWasIntersecting for the specific wall collision that just happened
bird.lastWasIntersecting = true;
break; // Exit the loop after handling a collision
}
@@ -243,8 +289,20 @@
}
if (!intersectingAnyWall) {
bird.lastWasIntersecting = false;
}
+ // Check for spike collisions
+ for (var i = 0; i < spikes.length; i++) {
+ var spike = spikes[i];
+ var currentIntersecting = bird.intersects(spike);
+ if (!spike.lastWasIntersecting && currentIntersecting) {
+ // Bird hit a spike - game over!
+ LK.effects.flashScreen(0xFF0000, 500);
+ LK.showGameOver();
+ break;
+ }
+ spike.lastWasIntersecting = currentIntersecting;
+ }
// Check if bird flew off screen (game over condition)
if (bird.y < -100 || bird.y > gameHeight + 100 || bird.x < -100 || bird.x > gameWidth + 100) {
LK.effects.flashScreen(0xFF0000, 500);
LK.showGameOver();
Big sunflower seed. In-Game asset. 2d. High contrast. No shadows
Square shaped gold bird. In-Game asset. 2d. High contrast. No shadows
Square shaped green bird facing to the right. In-Game asset. 2d. High contrast. No shadows
Square shaped orange bird facing right
Square shaped red bird facing right. In-Game asset. 2d. High contrast. No shadows
Square shaped rainbow bird facing right. In-Game asset. 2d. High contrast. No shadows