Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

player.nls 1.4 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011-2012
  3. globals [
  4. player
  5. player-deaths
  6. player-has-target?
  7. player-kills
  8. player-target-xcor
  9. player-target-ycor
  10. ]
  11. ;; ==========
  12. ;; Procedures
  13. ;; ==========
  14. to spawn-player [tank-xcor tank-ycor tank-heading]
  15. create-tanks 1 [
  16. set player tank who
  17. set-tank-vars true 0 tank-xcor tank-ycor tank-heading
  18. ]
  19. end
  20. to do-player-logic
  21. if mouse-inside? [
  22. if mouse-down? and not mouse-was-down? [
  23. let txcor round mouse-xcor
  24. let tycor round mouse-ycor
  25. ifelse player-has-target? and player-target-xcor = txcor and player-target-ycor = tycor [
  26. cancel-target
  27. ] [
  28. set is-accelerating? true
  29. set player-has-target? true
  30. set player-target-xcor txcor
  31. set player-target-ycor tycor
  32. ]
  33. ]
  34. set mouse-was-down? mouse-down?
  35. ]
  36. ifelse player-has-target? [
  37. tank-facexy player-target-xcor player-target-ycor
  38. let dist distancexy player-target-xcor player-target-ycor
  39. if dist < 2 and speed > 0.075 [
  40. ; Turn on "brakes" if we're getting
  41. ; close and we're moving fast:
  42. decelerate friction * 5
  43. ]
  44. if dist < 0.1 [
  45. cancel-target
  46. ]
  47. ] [
  48. tank-facexy mouse-xcor mouse-ycor
  49. ]
  50. end
  51. to player-place-pill
  52. ask player [
  53. place-pill
  54. ]
  55. end
  56. to cancel-order
  57. if player-has-target? [
  58. cancel-target
  59. ]
  60. end
  61. to cancel-target
  62. set is-accelerating? false
  63. set player-has-target? false
  64. set speed speed / 2
  65. end