Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

58 linhas
1.2 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 + 10
  18. if player-accelerate-for > 60 [
  19. set player-accelerate-for 60
  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. let mouse-dist distancexy mouse-xcor mouse-ycor
  27. if mouse-dist < 3 [
  28. decelerate friction
  29. ]
  30. if mouse-dist < 1.5 [
  31. decelerate friction * 6.5
  32. ]
  33. if mouse-dist < 0.35 [
  34. set speed 0
  35. set player-accelerate-for 0
  36. ]
  37. facexy mouse-xcor mouse-ycor
  38. if subtract-headings old-heading heading > max-turn [
  39. set heading old-heading - max-turn
  40. ]
  41. if subtract-headings old-heading heading < 0 - max-turn [
  42. set heading old-heading + max-turn
  43. ]
  44. ]
  45. ifelse player-accelerate-for > 0 [
  46. set player-accelerate-for player-accelerate-for - 1
  47. set is-accelerating? true
  48. ] [
  49. set is-accelerating? false
  50. ]
  51. end