Initial prompt
Flap & Bounce
User prompt
Remove the wall spawning from the game
User prompt
Remove wall related variables from the game
User prompt
Remove the Wall class
User prompt
Add a wall on the left and right side of the screen
User prompt
Make the bird fly back and forward between the walls, if the bird hit a wall it should bounce bounce and reverse direction
User prompt
Set the initial bird speed to 10
User prompt
Add x speed to the bird
User prompt
Make the background a light pastel blue
User prompt
When the bird bounce on a wall flip the bird graphic
User prompt
Add obstacles to the left and right wall that moves from the top of the screen to the bottom of the screen
User prompt
Make sure the bird can only bounce on a wall if it's moving towards the wall
User prompt
Flip the initial orientation of the bird graphic
User prompt
Have left and right obstacles spawn at random times
User prompt
Update the code so it supports multiple left and right obstacles
User prompt
Rotate obstacles 45 degrees
User prompt
Decrease the spawn rate of obstacles
User prompt
Have a single variable that determines the randomness of how fast obstacles spawn
User prompt
Only allow the bird to bounce on a wall, if it's currently moving towards that wall
User prompt
Flip the initial bird graphic direction
User prompt
Remove the current intersection logic between bird and obstacles
User prompt
Use simple distance logic to determine if the bird is touching an obstacle. If the bird touches one you should be game over
User prompt
Calculate the distance between the bird and obstacles, if the distance is below a threshold trigger game over
User prompt
Use a single variable to determine the distance threshold of bird dying.
User prompt
Refactor the obstacle distance test code into a single method and call that for both left and right obstacle tests
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.createAsset('bird', 'Bird character', .5, .5);
self.speed = 0;
self.gravity = 0.5;
self.lift = -15;
self.flap = function () {
self.speed = self.lift;
};
self.update = function () {
self.speed += self.gravity;
self.y += self.speed;
};
});
var Wall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.createAsset('wall', 'Wall obstacle', .5, .5);
self.speed = -2;
self.move = function () {
self.x += self.speed;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var bird = self.addChild(new Bird());
var walls = [];
bird.x = 1024;
bird.y = 1366;
var wallSpacing = 500;
var wallGap = 200;
var wallWidth = 100;
var createWall = function (x) {
var gapStart = Math.random() * (2732 - wallGap);
var topWall = self.addChild(new Wall());
var bottomWall = self.addChild(new Wall());
topWall.x = x;
topWall.y = gapStart - topWall.height;
bottomWall.x = x;
bottomWall.y = gapStart + wallGap;
walls.push(topWall);
walls.push(bottomWall);
};
createWall(2048);
stage.on('down', function (obj) {
bird.flap();
});
LK.on('tick', function () {
bird.update();
for (var i = 0; i < walls.length; i++) {
walls[i].move();
if (walls[i].x + walls[i].width < 0) {
walls[i].destroy();
walls.splice(i, 1);
i--;
}
}
if (walls[walls.length - 1].x < 2048 - wallSpacing) {
createWall(2048);
}
for (var i = 0; i < walls.length; i++) {
if (bird.intersects(walls[i])) {
LK.showGameOver();
}
}
if (bird.y < 0 || bird.y > 2732) {
LK.showGameOver();
}
});
});