Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
Change interval.
Browse files Browse the repository at this point in the history
Signed-off-by: cyberzhg <[email protected]>
  • Loading branch information
CyberZHG committed Mar 22, 2014
1 parent 5ce7c3d commit 5701827
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions js_flappy/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,43 @@
window.requestAnimationFrame(function () {
var game = new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
var cnt = 0;
setInterval(function() {
function jumper() {
if (cnt > 0) {
--cnt;
return;
}
var birdTop = parseFloat(game.actuator.birdobj.style.top);
var blockATop = parseFloat(game.actuator.blockobja.style.top);
var blockBTop = parseFloat(game.actuator.blockobjb.style.top);
var blockCTop = parseFloat(game.actuator.blockobjc.style.top);
var blockDTop = parseFloat(game.actuator.blockobjd.style.top);
var blockALeft = parseFloat(game.actuator.blockobja.style.left);
var type1 = blockATop < 180 ? (blockBTop < 180 ? 0 : 1) : 2;
var type2 = blockCTop < 180 ? (blockDTop < 180 ? 0 : 1) : 2;
if (blockALeft < -72) {
type1 = type2;
}
var flag = false;
if (type1 === 0) {
if (birdTop > 355) {
flag = true;
} else {
var birdTop = parseFloat(game.actuator.birdobj.style.top);
var blockATop = parseFloat(game.actuator.blockobja.style.top);
var blockBTop = parseFloat(game.actuator.blockobjb.style.top);
var blockCTop = parseFloat(game.actuator.blockobjc.style.top);
var blockDTop = parseFloat(game.actuator.blockobjd.style.top);
var blockALeft = parseFloat(game.actuator.blockobja.style.left);
var type1 = blockATop < 180 ? (blockBTop < 180 ? 0 : 1) : 2;
var type2 = blockCTop < 180 ? (blockDTop < 180 ? 0 : 1) : 2;
if (blockALeft < -72) {
type1 = type2;
}
} else if (type1 === 1) {
if (birdTop > 220) {
flag = true;
var flag = false;
if (type1 === 0) {
if (birdTop > 355) {
flag = true;
}
} else if (type1 === 1) {
if (birdTop > 220) {
flag = true;
}
} else {
if (birdTop > 100) {
flag = true;
}
}
} else {
if (birdTop > 100) {
flag = true;
if (flag) {
game.jump();
cnt = 1;
}
}
if (flag) {
game.jump();
cnt = 1;
}
}, 50);
setTimeout(function() {
jumper();
}, 384 / Math.sqrt(game.score + 256));
}
jumper();
});

0 comments on commit 5701827

Please sign in to comment.