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.3 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011
  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
  15. create-tanks 1 [
  16. set player tank who
  17. set-tank-vars 0 true
  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 cancel-order
  52. if player-has-target? [
  53. cancel-target
  54. ]
  55. end
  56. to cancel-target
  57. set is-accelerating? false
  58. set player-has-target? false
  59. set speed speed / 2
  60. end