Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

129 行
2.4 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 tank-facexy [txcor tycor]
  64. ;; Face a target at (txcor, tycor) like facexy, but don't
  65. ;; turn more than our max turn rate (max-turn¡):
  66. let old-heading heading
  67. facexy txcor tycor
  68. if subtract-headings old-heading heading > max-turn [
  69. set heading old-heading - max-turn
  70. ]
  71. if subtract-headings old-heading heading < 0 - max-turn [
  72. set heading old-heading + max-turn
  73. ]
  74. end
  75. to fire
  76. if ammunition > 0 and fire-cool-down = 0 [
  77. debug "FIRE" (word who " (" ammunition " left)")
  78. set ammunition ammunition - 1
  79. set fire-cool-down max-fire-rate
  80. fire-bullet
  81. play-sound "fire"
  82. ]
  83. end
  84. to shot-at
  85. debug "SHOT" (word who " by " ([shooter] of myself))
  86. set armor armor - 1
  87. ifelse armor = 0 [
  88. kill-tank
  89. ] [
  90. play-sound (word "shot " get-tank-affiliation)
  91. ]
  92. end
  93. to kill-tank
  94. debug "KILL" (word who " by " ([shooter] of myself))
  95. play-sound (word "kill " get-tank-affiliation)
  96. if is-player? [
  97. set player-deaths player-deaths + 1
  98. ]
  99. if [is-player?] of (turtle [shooter] of myself) [
  100. set player-kills player-kills + 1
  101. ]
  102. die
  103. end
  104. to-report get-tank-affiliation
  105. if is-player? [ report "player" ]
  106. if team = 0 [ report "ally" ]
  107. report "enemy"
  108. end
  109. to-report get-tank-color
  110. let affiliation get-tank-affiliation
  111. if affiliation = "player" [ report black ]
  112. if affiliation = "ally" [ report green ]
  113. if affiliation = "enemy" [ report red ]
  114. end