瀏覽代碼

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

master
Ben Kurtovic 13 年之前
父節點
當前提交
ea0704a358
共有 3 個檔案被更改,包括 35 行新增22 行删除
  1. +2
    -17
      lobo.nlogo
  2. +32
    -5
      player.nls
  3. +1
    -0
      tank.nls

+ 2
- 17
lobo.nlogo 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存