Advertisement
Conderoga

flappy bird typing

Feb 10th, 2014
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function(){
  2. var goUp = function(){Ω.input.lastKey=window.game.screen.bird.curWord[window.game.screen.bird.curIdx].charCodeAt(0);window.game.screen.bird.tick();};
  3. window.first_loop = true;
  4. window.loop_id = setInterval(function(){
  5. if (window.first_loop) {
  6. goUp();
  7. window.first_loop = false;
  8. }
  9. var bird = window.game.screen.bird;
  10. var pipes = window.game.screen.pipes;
  11. var nearestUp, nearestDown, nearestX = 10000000;
  12. for(var i = 0; i < pipes.length; i++) {
  13. var p = pipes[i];
  14. if (p.x > bird.x - 48 && p.x <= nearestX) {
  15. nearestX = p.x;
  16. if (p.dir == 'down') {
  17. nearestDown = p;
  18. } else {
  19. nearestUp = p;
  20. }
  21. }
  22. }
  23. var lowerBound = nearestUp.y;
  24. var upperBound = nearestDown.y + 320;
  25. if (bird.y + 40 > lowerBound) {
  26. goUp();
  27. }
  28. }, 10);
  29. window.onkeydown = function(e) {
  30. var code = e.keycode ? e.keyCode : e.which;
  31. if (code === " ".charCodeAt(0)) {
  32. clearInterval(window.loop_id);
  33. }
  34. };
  35. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement