User prompt
Multiple rotation with bird x scale when calculating rotation
User prompt
Factor in if the bird is flipped or not when calculating rotation
User prompt
Make sure the rotation is correct when the bird is flipped
User prompt
Make the rotation of the bird be relative to it's y speed
User prompt
Use a fixed variable in game class to determine the spawn y of obstacles
User prompt
Also make sure right obstacles spawn outside the screen at the top
User prompt
Make sure the obstacles spawn outside the screen at the top
User prompt
Increase the flap power by 25%
User prompt
Increase the flap power by 75%
User prompt
Increase the obstacle intersection distance to 250
User prompt
Make bird move 75% faster left and right
User prompt
Increase the obstacle test distance to 200
User prompt
Use the obstacle intersection method to test left and right obstacles in the tick function
User prompt
Move the obstacle intersection function into the global game scope
User prompt
Refactor the obstacle distance test code into a single method and call that for both left and right obstacle tests
User prompt
Use a single variable to determine the distance threshold of bird dying.
User prompt
Calculate the distance between the bird and obstacles, if the distance is below a threshold trigger game over
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
Remove the current intersection logic between bird and obstacles
User prompt
Flip the initial bird graphic direction
User prompt
Only allow the bird to bounce on a wall, if it's currently moving towards that wall
User prompt
Have a single variable that determines the randomness of how fast obstacles spawn
User prompt
Decrease the spawn rate of obstacles
User prompt
Rotate obstacles 45 degrees
User prompt
Update the code so it supports multiple left and right obstacles
var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.createAsset('obstacle', 'Obstacle', .5, .5); obstacleGraphics.rotation = Math.PI / 4; self.speed = 5; self.move = function () { self.y += self.speed; if (self.y > 2732) { self.y = 0; } }; }); var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.createAsset('wall', 'Wall', .5, .5); }); var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.createAsset('bird', 'Bird character', .5, .5); birdGraphics.scale.x = 1; self.xSpeed = 8.75; self.ySpeed = 0; self.gravity = 0.5; self.lift = -15; self.flap = function () { self.ySpeed = self.lift * 1.25; }; self.update = function () { self.ySpeed += self.gravity; self.y += self.ySpeed; self.x += self.xSpeed; if (self.y <= 0 || self.y >= 2732) { self.speed = -self.speed; } }; self.flip = function () { self.scale.x *= -1; }; }); var Game = Container.expand(function () { var self = Container.call(this); self.checkObstacleCollision = function (obstacles) { for (var i = 0; i < obstacles.length; i++) { obstacles[i].move(); var dist = Math.sqrt(Math.pow(bird.x - obstacles[i].x, 2) + Math.pow(bird.y - obstacles[i].y, 2)); if (dist < 250) { LK.showGameOver(); } } }; LK.stageContainer.setBackgroundColor(0xadd8e6); var bird = self.addChild(new Bird()); var leftWall = self.addChild(new Wall()); leftWall.x = 0; leftWall.y = 1366; var rightWall = self.addChild(new Wall()); rightWall.x = 2048; rightWall.y = 1366; var leftObstacles = [], rightObstacles = []; var obstacleSpawnRandomness = 120; var leftObstacleSpawnTime = Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness; var rightObstacleSpawnTime = Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness; bird.x = 1024; bird.y = 1366; stage.on('down', function (obj) { bird.flap(); }); LK.on('tick', function () { bird.update(); if (LK.ticks == leftObstacleSpawnTime) { var newObstacle = self.addChild(new Obstacle()); newObstacle.x = 0; newObstacle.y = -newObstacle.height; leftObstacles.push(newObstacle); leftObstacleSpawnTime += Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness; } if (LK.ticks == rightObstacleSpawnTime) { var newObstacle = self.addChild(new Obstacle()); newObstacle.x = 2048; newObstacle.y = 0; rightObstacles.push(newObstacle); rightObstacleSpawnTime += Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness; } if (bird.intersects(leftWall) && bird.xSpeed < 0 || bird.intersects(rightWall) && bird.xSpeed > 0) { bird.xSpeed = -bird.xSpeed; bird.flip(); } self.checkObstacleCollision(leftObstacles); self.checkObstacleCollision(rightObstacles); if (bird.y < 0 || bird.y > 2732) { LK.showGameOver(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -69,9 +69,9 @@
bird.update();
if (LK.ticks == leftObstacleSpawnTime) {
var newObstacle = self.addChild(new Obstacle());
newObstacle.x = 0;
- newObstacle.y = 0;
+ newObstacle.y = -newObstacle.height;
leftObstacles.push(newObstacle);
leftObstacleSpawnTime += Math.floor(Math.random() * obstacleSpawnRandomness) + obstacleSpawnRandomness;
}
if (LK.ticks == rightObstacleSpawnTime) {