Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

361 satır
5.1 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. player-deaths
  21. player-kills
  22. ]
  23. ;; ===========================
  24. ;; Button-initiated procedures
  25. ;; ===========================
  26. to setup
  27. clear-all
  28. no-display
  29. setup-defaults
  30. ask patches [
  31. set pcolor (random 3) - 5 + green
  32. ]
  33. spawn-player
  34. spawn-tank 1
  35. render
  36. set last-tick-time timer
  37. end
  38. to go
  39. ask player [
  40. do-player-logic
  41. ]
  42. ask tanks [
  43. do-tank-logic
  44. ]
  45. ask bullets [
  46. do-bullet-logic
  47. ]
  48. show-crosshair
  49. render
  50. keep-time
  51. end
  52. ;; ================
  53. ;; Other procedures
  54. ;; ================
  55. to debug [action msg]
  56. output-print (word (round timer) ": " action ": " msg)
  57. end
  58. to setup-defaults
  59. set-patch-size 30
  60. resize-world -8 8 -8 8
  61. set max-fps 30
  62. set mouse-was-down? false
  63. set player-accelerate-for 0
  64. set player-deaths 0
  65. set player-kills 0
  66. end
  67. to show-crosshair
  68. clear-drawing
  69. if mouse-inside? [
  70. ask patch mouse-xcor mouse-ycor [
  71. sprout 1 [
  72. set color white
  73. set heading 0
  74. make-square
  75. die
  76. ]
  77. ]
  78. ]
  79. end
  80. to make-square
  81. fd 0.5
  82. pd
  83. rt 90
  84. fd 0.5
  85. repeat 3 [
  86. rt 90
  87. fd 1
  88. ]
  89. rt 90
  90. fd 0.5
  91. end
  92. to render
  93. display
  94. no-display
  95. end
  96. to keep-time
  97. let time-since-last-tick timer - last-tick-time
  98. let wait-time (1 / max-fps) - time-since-last-tick
  99. wait wait-time
  100. tick
  101. set last-tick-time timer
  102. end
  103. @#$#@#$#@
  104. GRAPHICS-WINDOW
  105. 452
  106. 10
  107. 972
  108. 551
  109. 8
  110. 8
  111. 30.0
  112. 1
  113. 10
  114. 1
  115. 1
  116. 1
  117. 0
  118. 1
  119. 1
  120. 1
  121. -8
  122. 8
  123. -8
  124. 8
  125. 0
  126. 0
  127. 1
  128. ticks
  129. BUTTON
  130. 43
  131. 100
  132. 138
  133. 133
  134. New Game
  135. setup
  136. NIL
  137. 1
  138. T
  139. OBSERVER
  140. NIL
  141. R
  142. NIL
  143. NIL
  144. BUTTON
  145. 290
  146. 99
  147. 384
  148. 132
  149. Play Game
  150. go
  151. T
  152. 1
  153. T
  154. OBSERVER
  155. NIL
  156. G
  157. NIL
  158. NIL
  159. MONITOR
  160. 269
  161. 290
  162. 389
  163. 339
  164. Player Speed
  165. [speed] of player
  166. 8
  167. 1
  168. 12
  169. BUTTON
  170. 148
  171. 181
  172. 269
  173. 233
  174. FIRE!
  175. player-fire
  176. NIL
  177. 1
  178. T
  179. OBSERVER
  180. NIL
  181. F
  182. NIL
  183. NIL
  184. MONITOR
  185. 270
  186. 350
  187. 389
  188. 399
  189. Player Accel Time
  190. player-accelerate-for
  191. 5
  192. 1
  193. 12
  194. OUTPUT
  195. 998
  196. 30
  197. 1375
  198. 521
  199. 12
  200. MONITOR
  201. 55
  202. 290
  203. 149
  204. 339
  205. Player Deaths
  206. player-deaths
  207. 17
  208. 1
  209. 12
  210. MONITOR
  211. 55
  212. 350
  213. 148
  214. 399
  215. Player Kills
  216. player-kills
  217. 17
  218. 1
  219. 12
  220. MONITOR
  221. 160
  222. 290
  223. 261
  224. 339
  225. Player Ammo
  226. [ammunition] of player
  227. 17
  228. 1
  229. 12
  230. MONITOR
  231. 160
  232. 350
  233. 260
  234. 399
  235. Player Armor
  236. [armor] of player
  237. 17
  238. 1
  239. 12
  240. @#$#@#$#@
  241. WHAT IS IT?
  242. -----------
  243. This section could give a general understanding of what the model is trying to show or explain.
  244. HOW IT WORKS
  245. ------------
  246. This section could explain what rules the agents use to create the overall behavior of the model.
  247. HOW TO USE IT
  248. -------------
  249. This section could explain how to use the model, including a description of each of the items in the interface tab.
  250. THINGS TO NOTICE
  251. ----------------
  252. This section could give some ideas of things for the user to notice while running the model.
  253. THINGS TO TRY
  254. -------------
  255. This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
  256. EXTENDING THE MODEL
  257. -------------------
  258. 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.
  259. NETLOGO FEATURES
  260. ----------------
  261. 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.
  262. RELATED MODELS
  263. --------------
  264. This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
  265. CREDITS AND REFERENCES
  266. ----------------------
  267. 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.
  268. @#$#@#$#@
  269. default
  270. true
  271. 0
  272. Polygon -7500403 true true 150 5 40 250 150 205 260 250
  273. bullet
  274. true
  275. 5
  276. Rectangle -16777216 true false 135 30 165 90
  277. Rectangle -1 true false 135 90 165 150
  278. Rectangle -1 true false 135 150 165 210
  279. Polygon -16777216 true false 135 30 150 0 165 30 135 30
  280. Rectangle -16777216 true false 120 270 120 270
  281. Rectangle -2674135 true false 135 210 165 270
  282. Rectangle -16777216 true false 120 270 180 300
  283. Polygon -7500403 true false 195 210 165 150 165 210 195 210
  284. Rectangle -7500403 true false 165 210 195 268
  285. Rectangle -7500403 true false 105 210 135 268
  286. Polygon -7500403 true false 105 210 135 150 135 210 105 210
  287. tank
  288. true
  289. 1
  290. Rectangle -7500403 true false 78 85 116 103
  291. Polygon -7500403 true false 105 270 210 271 210 105 180 105 180 135 120 135 120 105 90 105 89 270
  292. 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
  293. Polygon -1 true false 135 15 135 150 165 150 165 15
  294. Polygon -1 true false 67 105 67 255 97 255 97 105
  295. Polygon -1 true false 202 105 202 255 232 255 232 105
  296. Rectangle -7500403 true false 184 85 222 103
  297. @#$#@#$#@
  298. NetLogo 4.1.3
  299. @#$#@#$#@
  300. @#$#@#$#@
  301. @#$#@#$#@
  302. @#$#@#$#@
  303. @#$#@#$#@
  304. default
  305. 0.0
  306. -0.2 0 1.0 0.0
  307. 0.0 1 1.0 0.0
  308. 0.2 0 1.0 0.0
  309. link direction
  310. true
  311. 0
  312. Line -7500403 true 150 150 90 180
  313. Line -7500403 true 150 150 210 180
  314. @#$#@#$#@
  315. 0
  316. @#$#@#$#@