Advertisement
Guest User

Flappy Bird

a guest
Jan 10th, 2015
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. ================================================================PIPE===============================================================
  2. patches-own [num oldcolor]
  3. to setup
  4. ca
  5. ask patches [
  6. set num 0
  7. ]
  8. end
  9.  
  10. to move
  11. reset-ticks
  12. wait 0.1
  13. ask patches [
  14. set oldcolor pcolor
  15. ]
  16. ask patches with [pxcor < max-pxcor] [
  17. set pcolor [oldcolor] of patch (pxcor + 1) pycor
  18. ]
  19. tick
  20. end
  21.  
  22. to line
  23. reset-ticks
  24. let x (random 20 - 6)
  25. ask patches [
  26. if ((pxcor > 10) and (pxcor < 15)) and ((pycor > -16) and ((pycor < x) and (pycor > (x - 5)))) [
  27. set pcolor white
  28. ]
  29. if pxcor = 14 [
  30. set num num + 1
  31. ]
  32. ]
  33. end
  34.  
  35. to pipe
  36. repeat 10 [move]
  37. line
  38. end
  39. ================================================================BIRD=============================================================
  40. globals [jump? score]
  41. to setup
  42. ca
  43. cro 1
  44. ask turtles [
  45. setxy -10 0
  46. set size 5
  47. set shape "bird-norm"
  48. ]
  49. ask patches [
  50. if pycor = -16 [set pcolor green]
  51. ]
  52. end
  53.  
  54. to flap
  55. set heading 0
  56. set shape "bird-norm"
  57. repeat 5 [
  58. fd 1
  59. wait 0.01]
  60. end
  61.  
  62. to go
  63. set shape "bird-fall"
  64. set heading 180
  65. fd 1
  66. wait 0.1
  67. if mouse-down? and not jump? [flap]
  68. set jump? mouse-down?
  69. if (pycor = -14) or (pcolor = white) [
  70. ask patch 0 0 [
  71. set plabel "Game Over"
  72. ]
  73. ]
  74. end
  75. ==========================================================BIRD WITH [STOP]=======================================================
  76. globals [jump? score]
  77. to setup
  78. ca
  79. cro 1
  80. ask turtles [
  81. setxy -10 0
  82. set size 5
  83. set shape "bird-norm"
  84. ]
  85. ask patches [
  86. if pycor = -16 [set pcolor green]
  87. ]
  88. end
  89.  
  90. to flap
  91. set heading 0
  92. set shape "bird-norm"
  93. repeat 5 [
  94. fd 1
  95. wait 0.01]
  96. end
  97.  
  98. to go
  99. set shape "bird-fall"
  100. set heading 180
  101. fd 1
  102. wait 0.1
  103. if mouse-down? and not jump? [flap]
  104. set jump? mouse-down?
  105. if (pycor = -14) or (pcolor = white) [
  106. ask patch 0 0 [
  107. set plabel "Game Over"
  108. ]
  109. stop
  110. ]
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement