Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

273 linhas
4.4 KiB

  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011
  3. ;;
  4. ;; Logo Bolo is a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo.
  5. ;;
  6. ;; ============
  7. ;; Declarations
  8. ;; ============
  9. __includes [
  10. "bullet.nls"
  11. "player.nls"
  12. "tank.nls"
  13. ]
  14. globals [
  15. last-tick-time
  16. max-fps
  17. mouse-was-down?
  18. player
  19. player-accelerate-for
  20. ]
  21. ;; ===========================
  22. ;; Button-initiated procedures
  23. ;; ===========================
  24. to setup
  25. clear-all
  26. no-display
  27. setup-defaults
  28. ask patches [
  29. set pcolor (random 3) - 5 + green
  30. ]
  31. spawn-player
  32. render
  33. set last-tick-time timer
  34. end
  35. to go
  36. ask player [
  37. do-player-logic
  38. ]
  39. ask tanks [
  40. do-tank-logic
  41. ]
  42. ask bullets [
  43. do-bullet-logic
  44. ]
  45. render
  46. keep-time
  47. end
  48. ;; ================
  49. ;; Other procedures
  50. ;; ================
  51. to setup-defaults
  52. set-patch-size 30
  53. resize-world -8 8 -8 8
  54. set max-fps 30
  55. set mouse-was-down? false
  56. set player-accelerate-for 0
  57. end
  58. to render
  59. display
  60. no-display
  61. end
  62. to keep-time
  63. let time-since-last-tick timer - last-tick-time
  64. let wait-time (1 / max-fps) - time-since-last-tick
  65. wait wait-time
  66. tick
  67. set last-tick-time timer
  68. end
  69. @#$#@#$#@
  70. GRAPHICS-WINDOW
  71. 475
  72. 10
  73. 995
  74. 551
  75. 8
  76. 8
  77. 30.0
  78. 1
  79. 10
  80. 1
  81. 1
  82. 1
  83. 0
  84. 1
  85. 1
  86. 1
  87. -8
  88. 8
  89. -8
  90. 8
  91. 0
  92. 0
  93. 1
  94. ticks
  95. BUTTON
  96. 66
  97. 100
  98. 161
  99. 133
  100. New Game
  101. setup
  102. NIL
  103. 1
  104. T
  105. OBSERVER
  106. NIL
  107. R
  108. NIL
  109. NIL
  110. BUTTON
  111. 313
  112. 99
  113. 407
  114. 132
  115. Play Game
  116. go
  117. T
  118. 1
  119. T
  120. OBSERVER
  121. NIL
  122. G
  123. NIL
  124. NIL
  125. MONITOR
  126. 297
  127. 382
  128. 410
  129. 427
  130. Player Speed
  131. [speed] of player
  132. 8
  133. 1
  134. 11
  135. BUTTON
  136. 108
  137. 176
  138. 285
  139. 252
  140. FIRE!
  141. player-fire
  142. NIL
  143. 1
  144. T
  145. OBSERVER
  146. NIL
  147. F
  148. NIL
  149. NIL
  150. MONITOR
  151. 296
  152. 433
  153. 410
  154. 478
  155. Player Accel Time
  156. player-accelerate-for
  157. 5
  158. 1
  159. 11
  160. @#$#@#$#@
  161. WHAT IS IT?
  162. -----------
  163. This section could give a general understanding of what the model is trying to show or explain.
  164. HOW IT WORKS
  165. ------------
  166. This section could explain what rules the agents use to create the overall behavior of the model.
  167. HOW TO USE IT
  168. -------------
  169. This section could explain how to use the model, including a description of each of the items in the interface tab.
  170. THINGS TO NOTICE
  171. ----------------
  172. This section could give some ideas of things for the user to notice while running the model.
  173. THINGS TO TRY
  174. -------------
  175. This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
  176. EXTENDING THE MODEL
  177. -------------------
  178. This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
  179. NETLOGO FEATURES
  180. ----------------
  181. This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
  182. RELATED MODELS
  183. --------------
  184. This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
  185. CREDITS AND REFERENCES
  186. ----------------------
  187. This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.
  188. @#$#@#$#@
  189. default
  190. true
  191. 0
  192. Polygon -7500403 true true 150 5 40 250 150 205 260 250
  193. bullet
  194. true
  195. 5
  196. Rectangle -16777216 true false 135 30 165 90
  197. Rectangle -1 true false 135 90 165 150
  198. Rectangle -1 true false 135 150 165 210
  199. Polygon -16777216 true false 135 30 150 0 165 30 135 30
  200. Rectangle -16777216 true false 120 270 120 270
  201. Rectangle -2674135 true false 135 210 165 270
  202. Rectangle -16777216 true false 120 270 180 300
  203. Polygon -7500403 true false 195 210 165 150 165 210 195 210
  204. Rectangle -7500403 true false 165 210 195 268
  205. Rectangle -7500403 true false 105 210 135 268
  206. Polygon -7500403 true false 105 210 135 150 135 210 105 210
  207. tank
  208. true
  209. 1
  210. Rectangle -7500403 true false 78 85 116 103
  211. Polygon -7500403 true false 105 270 210 271 210 105 180 105 180 135 120 135 120 105 90 105 89 270
  212. Polygon -2674135 true true 120 105 120 105 90 105 90 180 120 180 120 195 180 195 180 180 210 180 210 105 180 105 180 105 165 105 165 135 135 135 135 105 120 105
  213. Polygon -1 true false 135 15 135 150 165 150 165 15
  214. Polygon -1 true false 67 105 67 255 97 255 97 105
  215. Polygon -1 true false 202 105 202 255 232 255 232 105
  216. Rectangle -7500403 true false 184 85 222 103
  217. @#$#@#$#@
  218. NetLogo 4.1.3
  219. @#$#@#$#@
  220. @#$#@#$#@
  221. @#$#@#$#@
  222. @#$#@#$#@
  223. @#$#@#$#@
  224. default
  225. 0.0
  226. -0.2 0 1.0 0.0
  227. 0.0 1 1.0 0.0
  228. 0.2 0 1.0 0.0
  229. link direction
  230. true
  231. 0
  232. Line -7500403 true 150 150 90 180
  233. Line -7500403 true 150 150 210 180
  234. @#$#@#$#@
  235. 0
  236. @#$#@#$#@