Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

bullet.nls 1.7 KiB

13 anni fa
13 anni fa
13 anni fa
13 anni fa
13 anni fa
13 anni fa
13 anni fa
13 anni fa
13 anni fa
13 anni fa
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011-2012
  3. breed [bullets bullet]
  4. bullets-own [
  5. is-shooter-player?
  6. is-shooter-tank?
  7. max-travel-distance
  8. shooter
  9. speed
  10. team-of-shooter
  11. travel-distance
  12. ]
  13. ;; ==========
  14. ;; Procedures
  15. ;; ==========
  16. to fire-bullet [dist]
  17. hatch-bullets 1 [
  18. set max-travel-distance dist
  19. set is-shooter-player? false
  20. set is-shooter-tank? false
  21. if [breed] of myself = tanks [
  22. if [is-player?] of myself [
  23. set is-shooter-player? true
  24. ]
  25. set is-shooter-tank? true
  26. ]
  27. set shooter [who] of myself
  28. set speed 1
  29. set team-of-shooter [team] of myself
  30. set travel-distance 0
  31. set color white
  32. set label ""
  33. set shape "bullet"
  34. set size 0.5
  35. ; Bullets shouldn't travel perfectly straight:
  36. lt random 5
  37. rt random 5
  38. ]
  39. end
  40. to do-bullet-logic
  41. fd speed
  42. set travel-distance travel-distance + speed
  43. if travel-distance >= max-travel-distance [
  44. explode "small"
  45. die
  46. ]
  47. let mxcor xcor
  48. let mycor ycor
  49. let shootable-pills-here pillboxes-here with [alive? = true]
  50. let targets (turtle-set tanks-here shootable-pills-here)
  51. if is-shooter-tank? [ ; Only tanks can shoot at bases
  52. let shootable-bases-here bases-here with [armor > 0 and team != -1 and team != [team-of-shooter] of myself]
  53. set targets (turtle-set targets shootable-bases-here)
  54. ]
  55. let target min-one-of targets [distancexy mxcor mycor]
  56. if target != nobody [
  57. ask target [
  58. if distancexy mxcor mycor < 0.65 [
  59. if breed = tanks [ tank-shot-at ]
  60. if breed = pillboxes [ pill-shot-at ]
  61. if breed = bases [ base-shot-at ]
  62. ask myself [
  63. die
  64. ]
  65. ]
  66. ]
  67. ]
  68. end