From d4cc0606d4d2a53cf70db9cce4745b3471f719c1 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 8 Jan 2012 21:56:39 -0500 Subject: [PATCH] Map loading; lobo-default-map.png; documentation --- .gitignore | 1 + base.nls | 10 ++- lobo-default-map.png | Bin 0 -> 1214 bytes lobo.nlogo | 180 +++++++++++++++++++++++++++++++++++++++------------ pillbox.nls | 9 ++- player.nls | 3 + tank.nls | 6 +- 7 files changed, 153 insertions(+), 56 deletions(-) create mode 100644 .gitignore create mode 100644 lobo-default-map.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/base.nls b/base.nls index 8768228..9e8a689 100644 --- a/base.nls +++ b/base.nls @@ -18,13 +18,13 @@ bases-own [ ;; 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 -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 armor b-armor 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 shape "base" set size 1.15 - setxy b-xcor b-ycor end to do-base-logic @@ -57,7 +56,6 @@ to do-base-logic ] ] regenerate - set label armor end to claim-base [claimer] diff --git a/lobo-default-map.png b/lobo-default-map.png new file mode 100644 index 0000000000000000000000000000000000000000..80d81c8a8c26dcb02d2924eda27b9d68159fb346 GIT binary patch literal 1214 zcmV;v1VQ_WP)X0ssI2G+F?~00009a7bBm000XU z000XU0RWnu7ytkR4rxO}P*7-ZbZ>KLZ*U+F$?o_pSX%s}odHw;xqz-AC@ zr&#0(sq7U4z^kK)yZ5Z6Los$jd-pFFOm6YXGl!9k&U&4luo* z!rQ5Q-~oVqRR&V~o^YxqQPjF1r&fR|FbY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3JQ*u>b%707*qoM6N<$f|gP+djJ3c literal 0 HcmV?d00001 diff --git a/lobo.nlogo b/lobo.nlogo index 23be2e7..3185974 100644 --- a/lobo.nlogo +++ b/lobo.nlogo @@ -27,6 +27,11 @@ globals [ sounds ] +patches-own [ + ground-type + ground-friction +] + ;; =========================== ;; Button-initiated procedures ;; =========================== @@ -39,10 +44,10 @@ to setup make-explosions-table load-map 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 render end @@ -75,9 +80,12 @@ end ;; Other procedures ;; ================ +to startup + setup +end + 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 ")") end @@ -86,6 +94,7 @@ to setup-defaults resize-world -17 17 -12 12 set last-sound-time timer set last-tick-time timer + set map-file "lobo-default-map.png" set max-fps 30 set mouse-was-down? false set sound-stopped? true @@ -106,11 +115,46 @@ to make-sounds-table table:put sounds "shot" "Acoustic Snare" table:put sounds "place" "Vibraslap" table:put sounds "nopill" "Cowbell" + table:put sounds "spawn" "Open Hi Conga" end to load-map + import-pcolors-rgb map-file 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 @@ -158,13 +202,13 @@ to show-hud 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) ] - ask patch (max-pxcor - 1) (max-pycor - 2) [ + ask patch (min-pxcor + 12) max-pycor [ 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) ] ask patch (max-pxcor - 1) (min-pycor + 2) [ @@ -241,10 +285,10 @@ GRAPHICS-WINDOW frames BUTTON -19 -179 -114 -212 +20 +270 +115 +303 New Game setup NIL @@ -257,10 +301,10 @@ NIL NIL BUTTON -129 -179 -223 -212 +130 +270 +224 +303 Play Game go T @@ -273,10 +317,10 @@ NIL NIL BUTTON -21 -244 -224 -291 +22 +335 +225 +382 Fire! player-fire NIL @@ -300,10 +344,10 @@ enable-sound? -1000 BUTTON -22 -344 -225 -377 +23 +435 +226 +468 Cancel Order player-cancel-order NIL @@ -346,20 +390,20 @@ TEXTBOX 1 TEXTBOX -21 -221 -262 -249 +22 +312 +263 +340 --------------------------------- 11 0.0 1 BUTTON -22 -301 -225 -334 +23 +392 +226 +425 Place Pill player-place-pill NIL @@ -372,10 +416,10 @@ NIL NIL SLIDER -25 -136 -117 -169 +26 +204 +118 +237 allies allies 0 @@ -387,10 +431,10 @@ NIL HORIZONTAL SLIDER -125 -136 -217 -169 +126 +204 +218 +237 enemies enemies 0 @@ -401,7 +445,59 @@ enemies NIL 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 true diff --git a/pillbox.nls b/pillbox.nls index 6e8c9fd..d811adb 100644 --- a/pillbox.nls +++ b/pillbox.nls @@ -17,10 +17,9 @@ pillboxes-own [ ;; Procedures ;; ========== -to spawn-pillbox [pill-xcor pill-ycor] - create-pillboxes 1 [ +to spawn-pillbox + sprout-pillboxes 1 [ set-pill-vars -1 - setxy pill-xcor pill-ycor ] end @@ -49,7 +48,7 @@ end to do-pill-logic ifelse alive? [ 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 [ 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) face target play-sound "fire" - fire-bullet 9 + fire-bullet 6 set last-fire-time timer end diff --git a/player.nls b/player.nls index eadfee0..63969e8 100644 --- a/player.nls +++ b/player.nls @@ -26,6 +26,9 @@ to do-player-logic ifelse player = nobody [ if timer - player-death-time > 1.5 [ spawn-player 0 0 0 + ask player [ + play-sound "spawn" + ] ] ] [ ask player [ diff --git a/tank.nls b/tank.nls index 317cc2f..45fec2d 100644 --- a/tank.nls +++ b/tank.nls @@ -33,7 +33,7 @@ end to set-tank-vars [player? tteam txcor tycor theading] set acceleration 0.03 - set ammunition 20 + set ammunition 4 set armor 8 set fire-cool-down 0 set friction 0.0075 @@ -59,7 +59,7 @@ to do-tank-logic if is-accelerating? [ accelerate acceleration ] - fd speed + fd speed * ground-friction decelerate friction if fire-cool-down > 0 [ set fire-cool-down fire-cool-down - 1 @@ -98,7 +98,7 @@ to fire ifelse ammunition > 0 [ debug who "TANK-FIRE" (word (ammunition - 1) " left") set ammunition ammunition - 1 - fire-bullet 8 + fire-bullet 5 play-sound "fire" ] [ play-sound "noammo"