Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

13 年前
13 年前
13 年前
13 年前
13 年前
13 年前
13 年前
13 年前
13 年前
13 年前
13 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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. __includes [
  7. "bullet.nls"
  8. "explosion.nls"
  9. "player.nls"
  10. "tank.nls"
  11. ]
  12. extensions [
  13. sound
  14. table
  15. ]
  16. globals [
  17. last-tick-time
  18. max-fps
  19. mouse-was-down?
  20. sounds
  21. ]
  22. ;; ===========================
  23. ;; Button-initiated procedures
  24. ;; ===========================
  25. to setup
  26. clear-all
  27. no-display
  28. setup-defaults
  29. make-sounds-table
  30. make-explosions-table
  31. load-map
  32. spawn-player
  33. spawn-tank 0 ask tank 1 [ setxy -6 0 ]
  34. spawn-tank 1 ask tank 2 [ setxy 6 0 ]
  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. ask explosions [
  49. keep-exploding
  50. ]
  51. show-crosshair
  52. render
  53. keep-time
  54. end
  55. to player-fire
  56. ask player [
  57. fire
  58. ]
  59. end
  60. to player-cancel-order
  61. ask player [
  62. cancel-order
  63. ]
  64. end
  65. ;; ================
  66. ;; Other procedures
  67. ;; ================
  68. to debug [action msg]
  69. ; Comment this and remove the output box
  70. ; to turn off debugging info:
  71. output-print (word (round timer) ": " action ": " msg)
  72. end
  73. to setup-defaults
  74. set-patch-size 30
  75. resize-world -8 8 -8 8
  76. set max-fps 30
  77. set mouse-was-down? false
  78. set player-deaths 0
  79. set player-has-target? false
  80. set player-kills 0
  81. set player-target-xcor 0
  82. set player-target-ycor 0
  83. end
  84. to make-sounds-table
  85. set sounds table:make
  86. table:put sounds "fire" "Hand Clap"
  87. table:put sounds "noammo" "Cowbell"
  88. table:put sounds "shot" "Acoustic Snare"
  89. table:put sounds "kill" "Electric Snare"
  90. end
  91. to load-map
  92. ask patches [
  93. set pcolor (random 3) - 5 + green
  94. ]
  95. end
  96. to show-crosshair
  97. clear-drawing
  98. if mouse-inside? [
  99. ask patch mouse-xcor mouse-ycor [
  100. draw-border white 1
  101. ]
  102. ]
  103. if player-has-target? [
  104. ask patch player-target-xcor player-target-ycor [
  105. draw-border white 2
  106. ]
  107. ]
  108. end
  109. to draw-border [b-color b-thickness]
  110. sprout 1 [
  111. set color b-color
  112. set pen-size b-thickness
  113. set heading 0
  114. fd 0.5
  115. pd
  116. rt 90
  117. fd 0.5
  118. repeat 3 [
  119. rt 90
  120. fd 1
  121. ]
  122. rt 90
  123. fd 0.5
  124. die
  125. ]
  126. end
  127. to render
  128. display
  129. no-display
  130. end
  131. to keep-time
  132. let time-since-last-tick timer - last-tick-time
  133. let wait-time (1 / max-fps) - time-since-last-tick
  134. wait wait-time
  135. tick
  136. set last-tick-time timer
  137. end
  138. to play-sound [name]
  139. if enable-sound? [
  140. let dist distancexy ([xcor] of player) ([ycor] of player)
  141. let volume 127 - (dist * 4)
  142. if volume > 0 [
  143. sound:play-drum (table:get sounds name) volume
  144. ]
  145. ]
  146. end
  147. @#$#@#$#@
  148. GRAPHICS-WINDOW
  149. 452
  150. 10
  151. 972
  152. 551
  153. 8
  154. 8
  155. 30.0
  156. 1
  157. 10
  158. 1
  159. 1
  160. 1
  161. 0
  162. 1
  163. 1
  164. 1
  165. -8
  166. 8
  167. -8
  168. 8
  169. 0
  170. 0
  171. 1
  172. frames
  173. BUTTON
  174. 43
  175. 100
  176. 138
  177. 133
  178. New Game
  179. setup
  180. NIL
  181. 1
  182. T
  183. OBSERVER
  184. NIL
  185. R
  186. NIL
  187. NIL
  188. BUTTON
  189. 290
  190. 99
  191. 384
  192. 132
  193. Play Game
  194. go
  195. T
  196. 1
  197. T
  198. OBSERVER
  199. NIL
  200. G
  201. NIL
  202. NIL
  203. MONITOR
  204. 269
  205. 290
  206. 389
  207. 339
  208. Player Speed
  209. [speed] of player
  210. 8
  211. 1
  212. 12
  213. BUTTON
  214. 109
  215. 172
  216. 230
  217. 224
  218. FIRE!
  219. player-fire
  220. NIL
  221. 1
  222. T
  223. OBSERVER
  224. NIL
  225. F
  226. NIL
  227. NIL
  228. MONITOR
  229. 270
  230. 350
  231. 389
  232. 399
  233. Player Has Target?
  234. player-has-target?
  235. 5
  236. 1
  237. 12
  238. OUTPUT
  239. 998
  240. 30
  241. 1375
  242. 521
  243. 12
  244. MONITOR
  245. 55
  246. 290
  247. 149
  248. 339
  249. Player Deaths
  250. player-deaths
  251. 17
  252. 1
  253. 12
  254. MONITOR
  255. 55
  256. 350
  257. 148
  258. 399
  259. Player Kills
  260. player-kills
  261. 17
  262. 1
  263. 12
  264. MONITOR
  265. 160
  266. 290
  267. 261
  268. 339
  269. Player Ammo
  270. [ammunition] of player
  271. 17
  272. 1
  273. 12
  274. MONITOR
  275. 160
  276. 350
  277. 260
  278. 399
  279. Player Armor
  280. [armor] of player
  281. 17
  282. 1
  283. 12
  284. SWITCH
  285. 264
  286. 179
  287. 394
  288. 212
  289. enable-sound?
  290. enable-sound?
  291. 0
  292. 1
  293. -1000
  294. MONITOR
  295. 272
  296. 411
  297. 390
  298. 460
  299. Player Target
  300. word \"(\" player-target-xcor \", \" player-target-ycor \")\"
  301. 10
  302. 1
  303. 12
  304. BUTTON
  305. 109
  306. 235
  307. 230
  308. 268
  309. Cancel Order
  310. player-cancel-order
  311. NIL
  312. 1
  313. T
  314. OBSERVER
  315. NIL
  316. C
  317. NIL
  318. NIL
  319. @#$#@#$#@
  320. WHAT IS IT?
  321. -----------
  322. This section could give a general understanding of what the model is trying to show or explain.
  323. HOW IT WORKS
  324. ------------
  325. This section could explain what rules the agents use to create the overall behavior of the model.
  326. HOW TO USE IT
  327. -------------
  328. This section could explain how to use the model, including a description of each of the items in the interface tab.
  329. THINGS TO NOTICE
  330. ----------------
  331. This section could give some ideas of things for the user to notice while running the model.
  332. THINGS TO TRY
  333. -------------
  334. This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
  335. EXTENDING THE MODEL
  336. -------------------
  337. 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.
  338. NETLOGO FEATURES
  339. ----------------
  340. 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.
  341. RELATED MODELS
  342. --------------
  343. This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
  344. CREDITS AND REFERENCES
  345. ----------------------
  346. 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.
  347. @#$#@#$#@
  348. default
  349. true
  350. 0
  351. Polygon -7500403 true true 150 5 40 250 150 205 260 250
  352. bullet
  353. true
  354. 5
  355. Rectangle -16777216 true false 135 30 165 90
  356. Rectangle -1 true false 135 90 165 150
  357. Rectangle -1 true false 135 150 165 210
  358. Polygon -16777216 true false 135 30 150 0 165 30 135 30
  359. Rectangle -2674135 true false 135 210 165 270
  360. Rectangle -16777216 true false 120 270 180 300
  361. Polygon -7500403 true false 195 210 165 150 165 210 195 210
  362. Rectangle -7500403 true false 165 210 195 268
  363. Rectangle -7500403 true false 105 210 135 268
  364. Polygon -7500403 true false 105 210 135 150 135 210 105 210
  365. explosion-decay
  366. false
  367. 0
  368. Circle -2674135 true false 2 2 295
  369. Circle -955883 true false 75 75 148
  370. explosion-kill
  371. false
  372. 0
  373. Circle -6459832 true false 2 2 297
  374. Circle -2674135 true false 30 30 240
  375. Circle -955883 true false 60 60 180
  376. Circle -1184463 true false 90 90 120
  377. explosion-shot
  378. false
  379. 0
  380. Circle -2674135 true false 0 0 300
  381. Circle -955883 true false 45 45 210
  382. Circle -1184463 true false 90 90 120
  383. tank
  384. true
  385. 1
  386. Rectangle -7500403 true false 78 85 116 103
  387. Polygon -7500403 true false 105 270 210 271 210 105 180 105 180 135 120 135 120 105 90 105 89 270
  388. Polygon -2674135 true true 120 105 90 105 90 180 120 180 120 195 180 195 180 180 210 180 210 105 180 105 165 105 165 135 135 135 135 105 120 105
  389. Polygon -1 true false 135 15 135 150 165 150 165 15
  390. Polygon -1 true false 67 105 67 255 97 255 97 105
  391. Polygon -1 true false 202 105 202 255 232 255 232 105
  392. Rectangle -7500403 true false 184 85 222 103
  393. @#$#@#$#@
  394. NetLogo 4.1.3
  395. @#$#@#$#@
  396. @#$#@#$#@
  397. @#$#@#$#@
  398. @#$#@#$#@
  399. @#$#@#$#@
  400. default
  401. 0.0
  402. -0.2 0 1.0 0.0
  403. 0.0 1 1.0 0.0
  404. 0.2 0 1.0 0.0
  405. link direction
  406. true
  407. 0
  408. Line -7500403 true 150 150 90 180
  409. Line -7500403 true 150 150 210 180
  410. @#$#@#$#@
  411. 0
  412. @#$#@#$#@