Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.2 KiB

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