Skip to content

Instantly share code, notes, and snippets.

@tsholmes
Created February 11, 2014 00:54
Show Gist options
  • Save tsholmes/8927374 to your computer and use it in GitHub Desktop.
Save tsholmes/8927374 to your computer and use it in GitHub Desktop.
(function(){
var counter = 0;
function flappyai() {
if (ingame && !gameover) {
var next = 0;
var nextx = 10000;
var nexty = 100;
for (var i = 1; i <= 3; i++) {
var tube = $("#tube" + i).get(0).style.left;
tube = Number(tube.substring(0,tube.length-2));
if (tube > 40 && tube < nextx) {
next = i;
nextx = tube;
tube = $("#tube" + i + "top").get(0).style.top;
nexty = Number(tube.substring(0,tube.length-2)) + 600;
}
}
if (nexty > 250) nexty = 250;
var bird = $("#bird").offset().top - $("#game").offset().top - 80;
if (bird > nexty + 130 && fall_bird > 0 && counter > 3) {
$("#tap").click();
counter = 0;
}
counter++;
}
setTimeout(flappyai, 20);
}
flappyai();
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment