Browse Source

Cleaned up user interface a lot.

Added support for placing pillboxes.
master
Ben Kurtovic 12 years ago
parent
commit
c9adb16142
5 changed files with 163 additions and 207 deletions
  1. +10
    -11
      base.nls
  2. +106
    -172
      lobo.nlogo
  3. +29
    -17
      pillbox.nls
  4. +12
    -0
      player.nls
  5. +6
    -7
      tank.nls

+ 10
- 11
base.nls View File

@@ -1,11 +1,6 @@
;; lobo: Logo Bolo ;; lobo: Logo Bolo
;; (c) Ben Kurtovic, 2011 ;; (c) Ben Kurtovic, 2011


globals [
base-max-ammo
base-max-armor
]

breed [bases base] breed [bases base]


bases-own [ bases-own [
@@ -14,6 +9,8 @@ bases-own [
last-ammo-regen last-ammo-regen
last-armor-regen last-armor-regen
last-refuel last-refuel
max-ammo
max-armor
team team
] ]


@@ -23,17 +20,19 @@ bases-own [


to spawn-base [base-xcor base-ycor] to spawn-base [base-xcor base-ycor]
create-bases 1 [ create-bases 1 [
set-base-vars base-max-ammo base-max-armor -1 base-xcor base-ycor
set-base-vars 50 20 -1 base-xcor base-ycor
] ]
end end


to set-base-vars [b-ammo b-armor b-team b-xcor b-ycor] to set-base-vars [b-ammo b-armor b-team b-xcor b-ycor]
set ammunition b-ammo set ammunition b-ammo
set armor b-armor set armor b-armor
set team b-team
set last-ammo-regen timer set last-ammo-regen timer
set last-armor-regen timer set last-armor-regen timer
set last-refuel timer set last-refuel timer
set max-ammo b-armor
set max-armor b-armor
set team b-team


set color get-base-color set color get-base-color
set shape "base" set shape "base"
@@ -71,7 +70,7 @@ end
to refuel-tank [tank-to-refuel] to refuel-tank [tank-to-refuel]
let time-since-last-refuel timer - last-refuel let time-since-last-refuel timer - last-refuel
ask tank-to-refuel [ ask tank-to-refuel [
ifelse armor < tank-max-armor and ([armor] of myself) > 1 [
ifelse armor < max-armor and ([armor] of myself) > 1 [
if time-since-last-refuel > 25 / max-fps [ ; 25 frames if time-since-last-refuel > 25 / max-fps [ ; 25 frames
set armor armor + 1 set armor armor + 1
ask myself [ ask myself [
@@ -80,7 +79,7 @@ to refuel-tank [tank-to-refuel]
] ]
] ]
] [ ] [
if ammunition < tank-max-ammo and ([ammunition] of myself) > 1 [
if ammunition < max-ammo and ([ammunition] of myself) > 1 [
if time-since-last-refuel > 10 / max-fps [ ; 10 frames if time-since-last-refuel > 10 / max-fps [ ; 10 frames
set ammunition ammunition + 1 set ammunition ammunition + 1
ask myself [ ask myself [
@@ -97,11 +96,11 @@ to regenerate
let time-since-last-ammo-regen timer - last-ammo-regen let time-since-last-ammo-regen timer - last-ammo-regen
let time-since-last-armor-regen timer - last-armor-regen let time-since-last-armor-regen timer - last-armor-regen


if ammunition < base-max-ammo and time-since-last-ammo-regen > 6 [
if ammunition < max-ammo and time-since-last-ammo-regen > 6 [
set ammunition ammunition + 1 set ammunition ammunition + 1
set last-ammo-regen timer set last-ammo-regen timer
] ]
if armor < base-max-armor and time-since-last-armor-regen > 15 [
if armor < max-armor and time-since-last-armor-regen > 15 [
set armor armor + 1 set armor armor + 1
set last-armor-regen timer set last-armor-regen timer
] ]


+ 106
- 172
lobo.nlogo View File

@@ -47,7 +47,7 @@ end


to go to go
ask player [ ask player [
do-player-logic
do-player-logic
] ]
ask tanks [ ask tanks [
do-tank-logic do-tank-logic
@@ -89,12 +89,12 @@ end
to debug [agent action msg] to debug [agent action msg]
; Comment this and remove the output box ; Comment this and remove the output box
; to turn off debugging info: ; to turn off debugging info:
output-print (word (round timer) ": " agent ": " action " (" msg ")")
print (word (round timer) ": " agent ": " action " (" msg ")")
end end


to setup-defaults to setup-defaults
set-patch-size 30
resize-world -8 8 -8 8
set-patch-size 20
resize-world -17 17 -12 12
set max-fps 30 set max-fps 30
set mouse-was-down? false set mouse-was-down? false
set player-deaths 0 set player-deaths 0
@@ -102,12 +102,6 @@ to setup-defaults
set player-kills 0 set player-kills 0
set player-target-xcor 0 set player-target-xcor 0
set player-target-ycor 0 set player-target-ycor 0
set tank-max-ammo 24
set tank-max-armor 8
set base-max-ammo 50
set base-max-armor 20
set pill-anger-range [1.2 0.2]
set pill-max-armor 8
end end


to make-sounds-table to make-sounds-table
@@ -117,6 +111,8 @@ to make-sounds-table
table:put sounds "noammo" "Cowbell" table:put sounds "noammo" "Cowbell"
table:put sounds "pickup" "Hi Bongo" table:put sounds "pickup" "Hi Bongo"
table:put sounds "shot" "Acoustic Snare" table:put sounds "shot" "Acoustic Snare"
table:put sounds "place" "Vibraslap"
table:put sounds "nopill" "Cowbell"
end end


to load-map to load-map
@@ -159,6 +155,21 @@ to draw-border [b-color b-thickness]
end end


to show-hud to show-hud
ask patch (max-pxcor - 1) (max-pycor - 1) [
set plabel (word "Armor: " [armor] of player)
]
ask patch (max-pxcor - 1) (max-pycor - 2) [
set plabel (word "Ammo: " [ammunition] of player)
]
ask patch (max-pxcor - 1) (max-pycor - 3) [
set plabel (word "Pillboxes: " [number-of-pills] of player)
]
ask patch (max-pxcor - 1) (min-pycor + 2) [
set plabel (word "Deaths: " player-deaths)
]
ask patch (max-pxcor - 1) (min-pycor + 1) [
set plabel (word "Kills: " player-kills)
]
end end


to render to render
@@ -177,7 +188,7 @@ end
to play-sound [name] to play-sound [name]
if enable-sound? [ if enable-sound? [
let dist distancexy ([xcor] of player) ([ycor] of player) let dist distancexy ([xcor] of player) ([ycor] of player)
let volume 127 - (dist * 4)
let volume 127 - (dist * 8)
if volume > 0 [ if volume > 0 [
sound:play-drum (table:get sounds name) volume sound:play-drum (table:get sounds name) volume
] ]
@@ -185,36 +196,36 @@ to play-sound [name]
end end
@#$#@#$#@ @#$#@#$#@
GRAPHICS-WINDOW GRAPHICS-WINDOW
452
254
10 10
972
551
8
8
30.0
964
541
17
12
20.0
1 1
10
12
1 1
1 1
1 1
0 0
0
0
1 1
1
1
-8
8
-8
8
-17
17
-12
12
0 0
0 0
1 1
frames frames


BUTTON BUTTON
43
100
138
133
19
143
114
176
New Game New Game
setup setup
NIL NIL
@@ -227,10 +238,10 @@ NIL
NIL NIL


BUTTON BUTTON
290
99
384
132
129
143
223
176
Play Game Play Game
go go
T T
@@ -242,23 +253,12 @@ G
NIL NIL
NIL NIL


MONITOR
269
290
389
339
Player Speed
[speed] of player
8
1
12

BUTTON BUTTON
109
172
230
21
208
224 224
FIRE!
255
Fire!
player-fire player-fire
NIL NIL
1 1
@@ -269,95 +269,22 @@ F
NIL NIL
NIL NIL


MONITOR
270
350
389
399
Player Has Target?
player-has-target?
5
1
12

OUTPUT
1012
10
1500
557
12

MONITOR
55
290
149
339
Player Deaths
player-deaths
17
1
12

MONITOR
55
350
148
399
Player Kills
player-kills
17
1
12

MONITOR
160
290
261
339
Player Ammo
[ammunition] of player
17
1
12

MONITOR
160
350
260
399
Player Armor
[armor] of player
17
1
12

SWITCH SWITCH
264
179
394
212
50
97
186
130
enable-sound? enable-sound?
enable-sound? enable-sound?
0 0
1 1
-1000 -1000


MONITOR
272
411
390
460
Player Target
word \"(\" player-target-xcor \", \" player-target-ycor \")\"
10
1
12

BUTTON BUTTON
109
235
230
268
22
308
225
341
Cancel Order Cancel Order
player-cancel-order player-cancel-order
NIL NIL
@@ -369,54 +296,61 @@ C
NIL NIL
NIL NIL


BUTTON
109
536
368
569
NIL
ask one-of bases [claim-base tank 2]
NIL
TEXTBOX
16
14
303
53
LoBo: Logo Bolo
28
0.0
1 1
T
OBSERVER
NIL
NIL
NIL
NIL


MONITOR
160
412
259
461
Player's Pills
[number-of-pills] of player
17
TEXTBOX
41
53
304
87
a game by Ben Kurtovic
14
0.0
1 1
12


MONITOR
261
584
357
629
Pillbox Anger
[anger] of pillbox 4
6
TEXTBOX
19
75
241
93
---------------------------------
11
0.0
1 1

TEXTBOX
21
185
262
213
---------------------------------
11 11
0.0
1


MONITOR
148
584
246
629
Pillbox Armor
[armor] of pillbox 4
17
BUTTON
22
265
225
298
Place Pill
player-place-pill
NIL
1 1
11
T
OBSERVER
NIL
P
NIL
NIL


@#$#@#$#@ @#$#@#$#@
WHAT IS IT? WHAT IS IT?
@@ -560,10 +494,10 @@ Rectangle -7500403 true false 255 135 300 165
Polygon -7500403 true false 30 60 30 30 60 30 90 60 60 90 30 60 Polygon -7500403 true false 30 60 30 30 60 30 90 60 60 90 30 60
Polygon -7500403 true false 60 270 30 270 30 240 60 210 90 240 60 270 Polygon -7500403 true false 60 270 30 270 30 240 60 210 90 240 60 270
Polygon -7500403 true false 270 240 270 270 240 270 210 240 240 210 270 240 Polygon -7500403 true false 270 240 270 270 240 270 210 240 240 210 270 240
Polygon -2674135 true true 195 165 210 180 210 180 210 210 180 210 165 195
Polygon -2674135 true true 165 105 180 90 180 90 210 90 210 120 195 135
Polygon -2674135 true true 105 135 90 120 90 120 90 90 120 90 135 105
Polygon -2674135 true true 135 195 120 210 120 210 90 210 90 180 105 165
Polygon -2674135 true true 195 165 210 180 210 210 180 210 165 195
Polygon -2674135 true true 165 105 180 90 210 90 210 120 195 135
Polygon -2674135 true true 105 135 90 120 90 90 120 90 135 105
Polygon -2674135 true true 135 195 120 210 90 210 90 180 105 165


tank tank
true true


+ 29
- 17
pillbox.nls View File

@@ -1,18 +1,15 @@
;; lobo: Logo Bolo ;; lobo: Logo Bolo
;; (c) Ben Kurtovic, 2011 ;; (c) Ben Kurtovic, 2011


globals [
pill-anger-range
pill-max-armor
]

breed [pillboxes pillbox] breed [pillboxes pillbox]


pillboxes-own [ pillboxes-own [
alive? alive?
anger anger
anger-range
armor armor
last-fire-time last-fire-time
max-armor
team team
] ]


@@ -22,33 +19,40 @@ pillboxes-own [


to spawn-pillbox [pill-xcor pill-ycor] to spawn-pillbox [pill-xcor pill-ycor]
create-pillboxes 1 [ create-pillboxes 1 [
set-pill-vars (first pill-anger-range) pill-max-armor -1 pill-xcor pill-ycor
set-pill-vars -1
setxy pill-xcor pill-ycor
]
end

to hatch-pillbox
hatch 1 [
debug who "PILL-HATCH" (word "by " ([who] of myself))
set breed pillboxes
set-pill-vars [team] of myself
] ]
end end


to set-pill-vars [p-anger p-armor p-team p-xcor p-ycor]
to set-pill-vars [p-team]
set alive? true set alive? true
set anger p-anger
set armor p-armor
set anger 1.2
set anger-range [1.2 0.2]
set armor 8
set last-fire-time timer set last-fire-time timer
set max-armor 8
set team p-team set team p-team


set color get-pill-color set color get-pill-color
set shape "pillbox-alive" set shape "pillbox-alive"
set size 1.1 set size 1.1
setxy p-xcor p-ycor
end end


to do-pill-logic to do-pill-logic
set label armor set label armor
ifelse alive? [ ifelse alive? [
if timer - last-fire-time > anger [ if timer - last-fire-time > anger [
let targets tanks in-radius 9
let targets tanks with [team != [team] of myself] in-radius 9
if any? targets [ if any? targets [
let target min-one-of targets [distancexy [xcor] of myself [ycor] of myself]
face target
fire-bullet 9
set last-fire-time timer
pill-fire-at min-one-of targets [distancexy [xcor] of myself [ycor] of myself]
] ]
] ]
relax relax
@@ -59,6 +63,14 @@ to do-pill-logic
] ]
end end


to pill-fire-at [target]
debug who "PILL-FIRE" (word "at " [who] of target)
face target
play-sound "fire"
fire-bullet 9
set last-fire-time timer
end

to pill-shot-at to pill-shot-at
set armor armor - 1 set armor armor - 1
ifelse armor = 0 [ ifelse armor = 0 [
@@ -76,7 +88,7 @@ to pill-shot-at
end end


to relax to relax
let min-anger first pill-anger-range
let min-anger first anger-range
set anger anger + 0.00025 set anger anger + 0.00025
if anger > min-anger [ if anger > min-anger [
set anger min-anger set anger min-anger
@@ -84,7 +96,7 @@ to relax
end end


to enrage to enrage
let max-anger last pill-anger-range
let max-anger last anger-range
set anger anger - 0.2 set anger anger - 0.2
if anger < max-anger [ if anger < max-anger [
set anger max-anger set anger max-anger


+ 12
- 0
player.nls View File

@@ -54,6 +54,18 @@ to do-player-logic
] ]
end end


to player-place-pill
ask player [
ifelse number-of-pills > 0 [
set number-of-pills number-of-pills - 1
hatch-pillbox
play-sound "place"
] [
play-sound "nopill"
]
]
end

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


+ 6
- 7
tank.nls View File

@@ -1,11 +1,6 @@
;; lobo: Logo Bolo ;; lobo: Logo Bolo
;; (c) Ben Kurtovic, 2011 ;; (c) Ben Kurtovic, 2011


globals [
tank-max-ammo
tank-max-armor
]

breed [tanks tank] breed [tanks tank]


tanks-own [ tanks-own [
@@ -16,6 +11,8 @@ tanks-own [
friction friction
is-accelerating? is-accelerating?
is-player? is-player?
max-ammo
max-armor
max-fire-rate max-fire-rate
max-speed max-speed
max-turn max-turn
@@ -36,12 +33,14 @@ end


to set-tank-vars [player? tteam txcor tycor theading] to set-tank-vars [player? tteam txcor tycor theading]
set acceleration 0.03 set acceleration 0.03
set ammunition tank-max-ammo
set armor tank-max-armor
set ammunition 20
set armor 8
set fire-cool-down 0 set fire-cool-down 0
set friction 0.0075 set friction 0.0075
set is-accelerating? false set is-accelerating? false
set is-player? player? set is-player? player?
set max-ammo 24
set max-armor 8
set max-fire-rate 7 set max-fire-rate 7
set max-speed 0.25 set max-speed 0.25
set max-turn 24 set max-turn 24


Loading…
Cancel
Save