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.
|
- ;; 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
|