|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- ;; 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-xcor tank-ycor tank-heading]
- create-tanks 1 [
- set player tank who
- set-tank-vars true 0 tank-xcor tank-ycor tank-heading
- ]
- end
-
- to do-player-logic
- 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-place-pill
- ask player [
- place-pill
- ]
- end
-
- to cancel-order
- if player-has-target? [
- cancel-target
- ]
- end
-
- to cancel-target
- set is-accelerating? false
- set player-has-target? false
- set speed speed / 2
- end
|