|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- ;; lobo: Logo Bolo
- ;; (c) Ben Kurtovic, 2011-2012
-
- globals [
- player
- player-deaths
- player-has-target?
- player-kills
- player-target-xcor
- player-target-ycor
- ]
-
- ;; ==========
- ;; Procedures
- ;; ==========
-
- to spawn-player [tank-heading]
- sprout-tanks 1 [
- set player tank who
- set-tank-vars true 0 tank-heading
- ]
- end
-
- to do-player-logic
- if player != nobody [
- ask player [
- do-player-movement
- ]
- ]
- end
-
- to do-player-movement
- if mouse-inside? [
- if mouse-down? and not mouse-was-down? [
- let txcor round mouse-xcor
- let tycor round mouse-ycor
- ifelse player-has-target? and player-target-xcor = txcor and player-target-ycor = tycor [
- cancel-target
- ] [
- set is-accelerating? true
- set player-has-target? true
- set player-target-xcor txcor
- set player-target-ycor tycor
- ]
- ]
- set mouse-was-down? mouse-down?
- ]
-
- ifelse player-has-target? [
- tank-facexy player-target-xcor player-target-ycor
- let dist distancexy player-target-xcor player-target-ycor
- if dist < 2 and speed > 0.075 [
- ; Turn on "brakes" if we're getting
- ; close and we're moving fast:
- decelerate friction * 5
- ]
- if dist < 0.1 [
- cancel-target
- ]
- ] [
- tank-facexy mouse-xcor mouse-ycor
- ]
- end
-
- to player-fire
- if player != nobody [
- ask player [
- fire
- ]
- ]
- end
-
- to player-place-pill
- if player != nobody [
- ask player [
- place-pill
- ]
- ]
- end
-
- to player-cancel-order
- if player != nobody [
- ask player [
- if player-has-target? [
- cancel-target
- ]
- ]
- ]
- end
-
- to cancel-target
- set is-accelerating? false
- set player-has-target? false
- set speed speed / 2
- end
|