User prompt
Make the code that test if obstacles should spawn test for >= rather than OO
User prompt
slowly decrease obstacleSpawnRandomness as the game progresses
User prompt
Make the obstacle speed increase half as fast
User prompt
Make sure checkObstacleCollision is called for both left and right obstacles
User prompt
If obstacles move off screen delete them from the obstacle array and destroy them
User prompt
Do not reset the y of obstacles in the obstacle move class
User prompt
set obstacleSpawnY to -500
User prompt
Increase obstacle speed as the game progresses
User prompt
Set initial y speed of bird to -20
User prompt
Define a fixed obstacle speed in the game class and use that when calling the move function on obstacles
User prompt
Parse a speed variable when calling move function on obstacles
User prompt
Make sure to parse a speed variable to the move function of obstacles
User prompt
Parse a speed variable to the obstacle move function
User prompt
Make obstacles move faster as time progresses
User prompt
Make x speed 25% faster
User prompt
Increase flip power
User prompt
Increase gravity
User prompt
Add 15deg to the target rotation
User prompt
Add 30deg to the target rotation
User prompt
Smooth out bird rotation
User prompt
Decrease the aggressiveness of bird rotation
User prompt
Multiple speed with scale.x in the bird rotation calculation
User prompt
Make the rotation of the bird relative to the y speed of the bird. Do not factor in x speed
User prompt
Make the rotation of the bird relative to the y speed of the bird
User prompt
When flipping the bird, flip the graphics rather than self
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; } var targetRotation = Math.atan2(self.ySpeed, self.xSpeed * self.scale.x) / 2 + Math.PI / 12; birdGraphics.rotation += (targetRotation - birdGraphics.rotation) / 10; }; 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 obstacleSpawnY = -100; 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 = obstacleSpawnY; 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 = -newObstacle.height; 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
@@ -31,9 +31,9 @@
self.x += self.xSpeed;
if (self.y <= 0 || self.y >= 2732) {
self.speed = -self.speed;
}
- var targetRotation = Math.atan2(self.ySpeed, self.xSpeed * self.scale.x) / 2 + Math.PI / 6;
+ var targetRotation = Math.atan2(self.ySpeed, self.xSpeed * self.scale.x) / 2 + Math.PI / 12;
birdGraphics.rotation += (targetRotation - birdGraphics.rotation) / 10;
};
self.flip = function () {
self.scale.x *= -1;