Browse Source

Map loading; lobo-default-map.png; documentation

master
Ben Kurtovic 12 years ago
parent
commit
d4cc0606d4
7 changed files with 153 additions and 56 deletions
  1. +1
    -0
      .gitignore
  2. +4
    -6
      base.nls
  3. BIN
     
  4. +138
    -42
      lobo.nlogo
  5. +4
    -5
      pillbox.nls
  6. +3
    -0
      player.nls
  7. +3
    -3
      tank.nls

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
.DS_Store

+ 4
- 6
base.nls View File

@@ -18,13 +18,13 @@ bases-own [
;; Procedures ;; Procedures
;; ========== ;; ==========


to spawn-base [base-xcor base-ycor]
create-bases 1 [
set-base-vars 50 20 -1 base-xcor base-ycor
to spawn-base
sprout-bases 1 [
set-base-vars 50 20 -1
] ]
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]
set ammunition b-ammo set ammunition b-ammo
set armor b-armor set armor b-armor
set last-ammo-regen timer set last-ammo-regen timer
@@ -37,7 +37,6 @@ to set-base-vars [b-ammo b-armor b-team b-xcor b-ycor]
set color get-base-color set color get-base-color
set shape "base" set shape "base"
set size 1.15 set size 1.15
setxy b-xcor b-ycor
end end


to do-base-logic to do-base-logic
@@ -57,7 +56,6 @@ to do-base-logic
] ]
] ]
regenerate regenerate
set label armor
end end


to claim-base [claimer] to claim-base [claimer]


BIN
View File


+ 138
- 42
lobo.nlogo View File

@@ -27,6 +27,11 @@ globals [
sounds sounds
] ]


patches-own [
ground-type
ground-friction
]

;; =========================== ;; ===========================
;; Button-initiated procedures ;; Button-initiated procedures
;; =========================== ;; ===========================
@@ -39,10 +44,10 @@ to setup
make-explosions-table make-explosions-table
load-map load-map
spawn-player 0 0 0 spawn-player 0 0 0
spawn-tank 0 -6 0 90
spawn-tank 1 6 0 270
spawn-base 0 -7
spawn-pillbox 6 6
;spawn-tank 0 -6 0 90
;spawn-tank 1 6 0 270
;spawn-base 0 -7
;spawn-pillbox 6 6
show-hud show-hud
render render
end end
@@ -75,9 +80,12 @@ end
;; Other procedures ;; Other procedures
;; ================ ;; ================


to startup
setup
end

to debug [agent action msg] to debug [agent action msg]
; Comment this and remove the output box
; to turn off debugging info:
; Comment this to turn off debugging info:
print (word (round timer) ": " agent ": " action " (" msg ")") print (word (round timer) ": " agent ": " action " (" msg ")")
end end


@@ -86,6 +94,7 @@ to setup-defaults
resize-world -17 17 -12 12 resize-world -17 17 -12 12
set last-sound-time timer set last-sound-time timer
set last-tick-time timer set last-tick-time timer
set map-file "lobo-default-map.png"
set max-fps 30 set max-fps 30
set mouse-was-down? false set mouse-was-down? false
set sound-stopped? true set sound-stopped? true
@@ -106,11 +115,46 @@ to make-sounds-table
table:put sounds "shot" "Acoustic Snare" table:put sounds "shot" "Acoustic Snare"
table:put sounds "place" "Vibraslap" table:put sounds "place" "Vibraslap"
table:put sounds "nopill" "Cowbell" table:put sounds "nopill" "Cowbell"
table:put sounds "spawn" "Open Hi Conga"
end end


to load-map to load-map
import-pcolors-rgb map-file
ask patches [ ask patches [
set pcolor (random 3) - 5 + green
ifelse pcolor = [0 0 0] [
set pcolor black
set ground-type "road"
set ground-friction 1.15
] [
ifelse pcolor = [0 128 0] [
set pcolor lime - 4
set ground-type "forest"
set ground-friction 0.5
] [
ifelse pcolor = [0 255 0] [
set pcolor lime - 2
set ground-type "grass"
set ground-friction 0.75
] [
ifelse pcolor = [255 255 0] [
set pcolor black
set ground-type "road"
set ground-friction 1.15
spawn-base
] [
ifelse pcolor = [255 0 0] [
set pcolor lime - 4
set ground-type "forest"
set ground-friction 0.5
spawn-pillbox
] [
debug (word "(" pxcor ", " pycor ")") "PATCH-LOAD-FAILURE" (word "unknown color: " pcolor)
set pcolor red
]
]
]
]
]
] ]
end end


@@ -158,13 +202,13 @@ to show-hud
set num-pills [number-of-pills] of player set num-pills [number-of-pills] of player
] ]


ask patch (max-pxcor - 1) (max-pycor - 1) [
ask patch (min-pxcor + 4) max-pycor [
set plabel (word "Armor: " player-armor) set plabel (word "Armor: " player-armor)
] ]
ask patch (max-pxcor - 1) (max-pycor - 2) [
ask patch (min-pxcor + 12) max-pycor [
set plabel (word "Ammo: " player-ammo) set plabel (word "Ammo: " player-ammo)
] ]
ask patch (max-pxcor - 1) (max-pycor - 3) [
ask patch (max-pxcor - 1) max-pycor [
set plabel (word "Pillboxes: " num-pills) set plabel (word "Pillboxes: " num-pills)
] ]
ask patch (max-pxcor - 1) (min-pycor + 2) [ ask patch (max-pxcor - 1) (min-pycor + 2) [
@@ -241,10 +285,10 @@ GRAPHICS-WINDOW
frames frames


BUTTON BUTTON
19
179
114
212
20
270
115
303
New Game New Game
setup setup
NIL NIL
@@ -257,10 +301,10 @@ NIL
NIL NIL


BUTTON BUTTON
129
179
223
212
130
270
224
303
Play Game Play Game
go go
T T
@@ -273,10 +317,10 @@ NIL
NIL NIL


BUTTON BUTTON
21
244
224
291
22
335
225
382
Fire! Fire!
player-fire player-fire
NIL NIL
@@ -300,10 +344,10 @@ enable-sound?
-1000 -1000


BUTTON BUTTON
22
344
225
377
23
435
226
468
Cancel Order Cancel Order
player-cancel-order player-cancel-order
NIL NIL
@@ -346,20 +390,20 @@ TEXTBOX
1 1


TEXTBOX TEXTBOX
21
221
262
249
22
312
263
340
--------------------------------- ---------------------------------
11 11
0.0 0.0
1 1


BUTTON BUTTON
22
301
225
334
23
392
226
425
Place Pill Place Pill
player-place-pill player-place-pill
NIL NIL
@@ -372,10 +416,10 @@ NIL
NIL NIL


SLIDER SLIDER
25
136
117
169
26
204
118
237
allies allies
allies allies
0 0
@@ -387,10 +431,10 @@ NIL
HORIZONTAL HORIZONTAL


SLIDER SLIDER
125
136
217
169
126
204
218
237
enemies enemies
enemies enemies
0 0
@@ -401,7 +445,59 @@ enemies
NIL NIL
HORIZONTAL HORIZONTAL


INPUTBOX
23
137
219
197
map-file
lobo-default-map.png
1
0
String

TEXTBOX
22
246
257
264
---------------------------------
11
0.0
1

@#$#@#$#@ @#$#@#$#@
LOBO
----

Lobo is Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo. Below you will find a short tutorial on how to play, some known bugs and limitations, and credits.

TUTORIAL
-------

...

BUGS / LIMITATIONS
------------------

In the original Bolo, the map takes up many screen widths and is scrollable with the tank at the center. "follow" by itself wouldn't work, because NetLogo does not allow objects off-screen. I spent a while trying to figure this out, at one point essentially rewriting the rendering engine and using a table of "actual" patch coordinates that was translated into "virtual" patch coordinates each frame Ð not only was this very slow, but it was very overcomplicated and I wasn't able to do everything I had wanted. Instead, the map was made one screen size.

In the original Bolo, patches are not merely colors - they have patterns on them (grass has little green lines, forests are spotted, roads have white stripes). This was not possible in NetLogo because patches can only have a single color.

Time was also a limiting factor: I had planned a lot of additional features found in the original Bolo, like a nicer GUI for showing armor and ammunition, water as a ground-type (which drowns your tank). These were skipped so more work could be spent on general polishing and testing.

CREDITS / MISC
-------

* Stuart Cheshire for the original Bolo game. Some graphics used in this project (tanks, pillboxes, and bases) were heavily based on old sprites taken from Bolo.

* My dad for introducing me to Bolo many years ago, and for helping me simplify the original Bolo game into something possible with NetLogo.

* Josh Hofing for advice on implementing certain features and emotional support.

This project is available on GitHub at https://github.com/earwig/lobo. I used it for syncing code between my netbook and my desktop when working on the project away from home.

Ñ Ben Kurtovic
@#$#@#$#@ @#$#@#$#@
default default
true true


+ 4
- 5
pillbox.nls View File

@@ -17,10 +17,9 @@ pillboxes-own [
;; Procedures ;; Procedures
;; ========== ;; ==========


to spawn-pillbox [pill-xcor pill-ycor]
create-pillboxes 1 [
to spawn-pillbox
sprout-pillboxes 1 [
set-pill-vars -1 set-pill-vars -1
setxy pill-xcor pill-ycor
] ]
end end


@@ -49,7 +48,7 @@ end
to do-pill-logic to do-pill-logic
ifelse alive? [ ifelse alive? [
if timer - last-fire-time > anger [ if timer - last-fire-time > anger [
let targets tanks with [team != [team] of myself] in-radius 9
let targets tanks with [team != [team] of myself] in-radius 6
if any? targets [ if any? targets [
pill-fire-at min-one-of targets [distancexy [xcor] of myself [ycor] of myself] pill-fire-at min-one-of targets [distancexy [xcor] of myself [ycor] of myself]
] ]
@@ -66,7 +65,7 @@ to pill-fire-at [target]
debug who "PILL-FIRE" (word "at " [who] of target) debug who "PILL-FIRE" (word "at " [who] of target)
face target face target
play-sound "fire" play-sound "fire"
fire-bullet 9
fire-bullet 6
set last-fire-time timer set last-fire-time timer
end end




+ 3
- 0
player.nls View File

@@ -26,6 +26,9 @@ to do-player-logic
ifelse player = nobody [ ifelse player = nobody [
if timer - player-death-time > 1.5 [ if timer - player-death-time > 1.5 [
spawn-player 0 0 0 spawn-player 0 0 0
ask player [
play-sound "spawn"
]
] ]
] [ ] [
ask player [ ask player [


+ 3
- 3
tank.nls View File

@@ -33,7 +33,7 @@ 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 20
set ammunition 4
set armor 8 set armor 8
set fire-cool-down 0 set fire-cool-down 0
set friction 0.0075 set friction 0.0075
@@ -59,7 +59,7 @@ to do-tank-logic
if is-accelerating? [ if is-accelerating? [
accelerate acceleration accelerate acceleration
] ]
fd speed
fd speed * ground-friction
decelerate friction decelerate friction
if fire-cool-down > 0 [ if fire-cool-down > 0 [
set fire-cool-down fire-cool-down - 1 set fire-cool-down fire-cool-down - 1
@@ -98,7 +98,7 @@ to fire
ifelse ammunition > 0 [ ifelse ammunition > 0 [
debug who "TANK-FIRE" (word (ammunition - 1) " left") debug who "TANK-FIRE" (word (ammunition - 1) " left")
set ammunition ammunition - 1 set ammunition ammunition - 1
fire-bullet 8
fire-bullet 5
play-sound "fire" play-sound "fire"
] [ ] [
play-sound "noammo" play-sound "noammo"


Loading…
Cancel
Save