Browse Source

Clean up player logic such that the player respawns with throwing exceptions

master
Ben Kurtovic 13 years ago
parent
commit
ea0704a358
3 changed files with 35 additions and 22 deletions
  1. +2
    -17
      lobo.nlogo
  2. +32
    -5
      player.nls
  3. +1
    -0
      tank.nls

+ 2
- 17
lobo.nlogo View File

@@ -48,11 +48,7 @@ to setup
end

to go
if player != nobody [
ask player [
do-player-logic
]
]
do-player-logic
ask tanks [
do-tank-logic
]
@@ -75,18 +71,6 @@ to go
keep-time
end

to player-fire
ask player [
fire
]
end

to player-cancel-order
ask player [
cancel-order
]
end

;; ================
;; Other procedures
;; ================
@@ -105,6 +89,7 @@ to setup-defaults
set max-fps 30
set mouse-was-down? false
set sound-stopped? true
set player-death-time timer
set player-deaths 0
set player-has-target? false
set player-kills 0


+ 32
- 5
player.nls View File

@@ -3,6 +3,7 @@

globals [
player
player-death-time
player-deaths
player-has-target?
player-kills
@@ -22,6 +23,18 @@ to spawn-player [tank-xcor tank-ycor tank-heading]
end

to do-player-logic
ifelse player = nobody [
if timer - player-death-time > 1.5 [
spawn-player 0 0 0
]
] [
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
@@ -54,15 +67,29 @@ to do-player-logic
]
end

to player-fire
if player != nobody [
ask player [
fire
]
]
end

to player-place-pill
ask player [
place-pill
if player != nobody [
ask player [
place-pill
]
]
end

to cancel-order
if player-has-target? [
cancel-target
to player-cancel-order
if player != nobody [
ask player [
if player-has-target? [
cancel-target
]
]
]
end



+ 1
- 0
tank.nls View File

@@ -123,6 +123,7 @@ end

to kill-tank
if is-player? [
set player-death-time timer
set player-deaths player-deaths + 1
]
if [is-shooter-player?] of myself [


Loading…
Cancel
Save