Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- ;; 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
|