Browse Source

"C" cancels the current order, i.e., destroys our target

master
Ben Kurtovic 13 years ago
parent
commit
3511867b11
2 changed files with 40 additions and 8 deletions
  1. +28
    -0
      lobo.nlogo
  2. +12
    -8
      player.nls

+ 28
- 0
lobo.nlogo View File

@@ -61,6 +61,18 @@ to go
keep-time keep-time
end end


to player-fire
ask player [
fire
]
end

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

;; ================ ;; ================
;; Other procedures ;; Other procedures
;; ================ ;; ================
@@ -320,6 +332,22 @@ word \"(\" player-target-xcor \", \" player-target-ycor \")\"
1 1
12 12


BUTTON
109
235
230
268
Cancel Order
player-cancel-order
NIL
1
T
OBSERVER
NIL
C
NIL
NIL

@#$#@#$#@ @#$#@#$#@
WHAT IS IT? WHAT IS IT?
----------- -----------


+ 12
- 8
player.nls View File

@@ -8,12 +8,6 @@ to spawn-player
] ]
end end


to player-fire
ask player [
fire
]
end

to do-player-logic to do-player-logic
if mouse-inside? [ if mouse-inside? [
if mouse-down? and not mouse-was-down? [ if mouse-down? and not mouse-was-down? [
@@ -32,10 +26,20 @@ to do-player-logic
decelerate friction * 5 decelerate friction * 5
] ]
if dist < 0.1 [ if dist < 0.1 [
set is-accelerating? false
set player-has-target? false
cancel-target
] ]
] [ ] [
tank-facexy mouse-xcor mouse-ycor tank-facexy mouse-xcor mouse-ycor
] ]
end end

to cancel-order
if player-has-target? [
cancel-target
]
end

to cancel-target
set is-accelerating? false
set player-has-target? false
end

Loading…
Cancel
Save