Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

119 rindas
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 20
  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. hatch-bullets 1 [
  69. set max-travel-distance 8
  70. set shooter [who] of myself
  71. set speed 1
  72. set travel-distance 0
  73. set color white
  74. set shape "bullet"
  75. set size 0.5
  76. lt random 10 ; Bullets shouldn't travel perfectly straight
  77. rt random 10
  78. ]
  79. play-sound "fire"
  80. ]
  81. end
  82. to shot-at [bullet]
  83. debug "SHOT" (word who " by " ([shooter] of myself))
  84. set armor armor - 1
  85. ifelse armor = 0 [
  86. debug "KILL" (word who " by " ([shooter] of myself))
  87. play-sound "kill"
  88. die
  89. ] [
  90. play-sound "shot"
  91. ]
  92. end
  93. to-report get-tank-affiliation
  94. if is-player? [ report "player" ]
  95. if team = 0 [ report "ally" ]
  96. report "enemy"
  97. end
  98. to-report get-tank-color
  99. let affiliation get-tank-affiliation
  100. if affiliation = "player" [ report black ]
  101. if affiliation = "ally" [ report green ]
  102. if affiliation = "enemy" [ report red ]
  103. end