Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

116 Zeilen
2.1 KiB

  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011
  3. breed [tanks tank]
  4. tanks-own [
  5. acceleration
  6. ammunition
  7. armor
  8. fire-cool-down
  9. friction
  10. is-accelerating?
  11. is-player?
  12. max-fire-rate
  13. max-speed
  14. max-turn
  15. speed
  16. team
  17. ]
  18. to spawn-tank [tank-team]
  19. create-tanks 1 [
  20. set-tank-vars tank-team false
  21. ]
  22. end
  23. to set-tank-vars [tank-team player-tank?]
  24. set acceleration 0.03
  25. set ammunition 24
  26. set armor 8
  27. set fire-cool-down 0
  28. set friction 0.0075
  29. set is-accelerating? false
  30. set is-player? player-tank?
  31. set max-fire-rate 7
  32. set max-speed 0.25
  33. set max-turn 24
  34. set speed 0
  35. set team tank-team
  36. set color get-tank-color
  37. set heading 0
  38. set shape "tank"
  39. set size 1.5
  40. end
  41. to do-tank-logic
  42. if is-accelerating? [
  43. accelerate acceleration
  44. ]
  45. fd speed
  46. decelerate friction
  47. if fire-cool-down > 0 [
  48. set fire-cool-down fire-cool-down - 1
  49. ]
  50. end
  51. to accelerate [amount]
  52. set speed speed + amount
  53. if speed > max-speed [
  54. set speed max-speed
  55. ]
  56. end
  57. to decelerate [amount]
  58. set speed speed - amount
  59. if speed < 0 [
  60. set speed 0
  61. ]
  62. end
  63. to fire
  64. if ammunition > 0 and fire-cool-down = 0 [
  65. debug "FIRE" (word who " (" ammunition " left)")
  66. set ammunition ammunition - 1
  67. set fire-cool-down max-fire-rate
  68. fire-bullet
  69. play-sound "fire"
  70. ]
  71. end
  72. to shot-at
  73. debug "SHOT" (word who " by " ([shooter] of myself))
  74. set armor armor - 1
  75. ifelse armor = 0 [
  76. kill-tank
  77. ] [
  78. play-sound (word "shot " get-tank-affiliation)
  79. ]
  80. end
  81. to kill-tank
  82. debug "KILL" (word who " by " ([shooter] of myself))
  83. play-sound (word "kill " get-tank-affiliation)
  84. if is-player? [
  85. set player-deaths player-deaths + 1
  86. ]
  87. if [is-player?] of (turtle [shooter] of myself) [
  88. set player-kills player-kills + 1
  89. ]
  90. die
  91. end
  92. to-report get-tank-affiliation
  93. if is-player? [ report "player" ]
  94. if team = 0 [ report "ally" ]
  95. report "enemy"
  96. end
  97. to-report get-tank-color
  98. let affiliation get-tank-affiliation
  99. if affiliation = "player" [ report black ]
  100. if affiliation = "ally" [ report green ]
  101. if affiliation = "enemy" [ report red ]
  102. end