Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

53 rader
1.1 KiB

  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011
  3. to spawn-player
  4. create-tanks 1 [
  5. set player tank who
  6. set-tank-vars 0 true
  7. ]
  8. end
  9. to player-fire
  10. ask player [
  11. fire
  12. ]
  13. end
  14. to do-player-logic
  15. if mouse-inside? [
  16. if mouse-down? and not mouse-was-down? [
  17. set player-accelerate-for player-accelerate-for + 5
  18. if player-accelerate-for > 30 [
  19. set player-accelerate-for 30
  20. ]
  21. ]
  22. set mouse-was-down? mouse-down?
  23. let old-heading heading
  24. ; Slow down the tank a bit more than usual if we're
  25. ; very close to the mouse:
  26. if distancexy mouse-xcor mouse-ycor < 2.5 [
  27. set speed speed - friction
  28. if speed < 0 [
  29. set speed 0
  30. ]
  31. ]
  32. facexy mouse-xcor mouse-ycor
  33. if subtract-headings old-heading heading > max-turn [
  34. set heading old-heading - max-turn
  35. ]
  36. if subtract-headings old-heading heading < 0 - max-turn [
  37. set heading old-heading + max-turn
  38. ]
  39. ]
  40. ifelse player-accelerate-for > 0 [
  41. set player-accelerate-for player-accelerate-for - 1
  42. set is-accelerating? true
  43. ] [
  44. set is-accelerating? false
  45. ]
  46. end