Zombie Attack! 2.2.0

Zombie Attack! 2.2.0 preview image

1 collaborator

Turtlezero2-white-048 James Steiner (Author)

Tags

animation 

Tagged by James Steiner 7 months ago

arcade 

Tagged by James Steiner 7 months ago

game 

Tagged by James Steiner 7 months ago

interactive 

Tagged by James Steiner 7 months ago

particle system 

Tagged by James Steiner 7 months ago

particles 

Tagged by James Steiner 7 months ago

self-play 

Tagged by James Steiner 7 months ago

zombies 

Tagged by James Steiner 7 months ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 112 times • Downloaded 5 times • Run 0 times
Download the 'Zombie Attack! 2.2.0' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals
[   g   ; gravity constant (for gobs)
    kills ;; number of player kills
    shots ;; number of player shots fired
    hits  ;; number of shots that hit
    misses ;; number of shots that missed
    speed  ;; overall zombie speed
    counter ;; counter for level advancement
    level  ;; current game level / wave
    score  ; current score
    barrier  ;; the patches that contain the barrier
    game-over?  ;; is the gamve over?
    tocks       ;; occur every 5 ticks
;;    crosshairs  ;; the turtle that is the crosshair
;;    gun  ;; the turtle that is the gun
;;    bullet  ;;
    fire?  ;; has the fire button been pressed (or, with auto, is it time to fire?)
    full-auto? ;; is full auto mode on?
;;    target  ;; the thing that is the current gun target
    point-blank  ;; the xcoord beyond which damage is 8
    mid-range ;; the xcoord beyond which damage is 4
    long-range ;; the xcoord beyond which damage is 2
    truck! ;; keeps track of the last appearance of the zombie truck
    mid-pxcor ;; half-way bewteen min- and max- pxcor
    mid-pycor ;; likewise
    ; message ;; text of message to scroll on screen
    ; msg-row ;; current row of message
]

breed [ bullets a-bullet ] ;; bullet is really just a line
breed [ zombies a-zombie ] ;; zombies attack in waves
breed [ trucks truck ] ;; a truck is driven by a zombie
breed [ giants giant ] ;; a giant zombie
breed [ trees a-tree ] ;; an innocent tree, can be destroyed by giants and vehicles
breed [ guns a-gun ] ;; the turret that rotates and fires bullets
breed [ gobs a-gob ] ;; gobs of zombie gore and truck parts: results of zombie destruction: a particle system
breed [ new-gobs a-new-gob ]
breed [ hairs a-hair ] ;; the cross-hair
breed [ messengers a-messanger ] ;; used to display messages

gobs-own
[ vx vy ;; velocity in x and y, for particle system
  ttl ;; time-to-live : count-down to removal
  burning? ;; true if gobs are burning
]

guns-own
[ base-shape ;; base of the name..add suffix for flash shapes
  my-bullet ;; bullet "line" that goes with this gun.
  gun-type ;; the type of gun/bullet pattern
  fire-rate ;; how fast does the gun fire (timer mod fire-rate = 0 = fire!)
  my-crosshair
  g-number
]
bullets-own
[ my-gun ]

hairs-own
[ my-gun
  target
]

trees-own
[ is-falling? ]

zombies-own
[ pace   ;; how fast this particular zombie moves
  integrity ;; the current physical integrity of the zombie--at zero, zombie disintegrates
  frame  ;; the current animation frame of this zombie
  base-shape ;; the base of the shape name for this zombie
  bonus      ;; the score bonus obtained from killing this zombie
  sub-breed  ;; the sub-breed of this zombie (zombie, giant, trucks)
  inflammable? ;; can this zombie burn?
  burning?   ;; is this zombie currently  burning?
]

to startup ;; run setup when model loads
   setup
end 

;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.

to setup
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   display
   ;; (for this model to work with NetLogo's new plotting features,
  ;; __clear-all-and-reset-ticks should be replaced with clear-all at
  ;; the beginning of your setup procedure and reset-ticks at the end
  ;; of the procedure.)
  clear-all
   setup-background
   setup-default-shapes
   setup-globals
   setup-barrier
   setup-gun-and-bullet
   setup-trees
   zombie-birth
   setup-first-message
  reset-ticks
end 

to setup-gun-and-bullet
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.

   let emplacements
     (list
       patch (min-pxcor + 5) 0
       patch (min-pxcor + 5) (0 - (world-height * .25) )
       patch (min-pxcor + 5) (0 + (world-height * .25) )
     )
   let gindex 0
   foreach emplacements
  [ ? -> ask ? [  do-sprout-gun gindex set gindex gindex + 1 ]
   ]
end 

to do-sprout-gun [ gindex ]
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   sprout-guns 1
     [ let me nobody
       ;; set gun self ;; look out!
       set color gray
       set heading 90
       set size 5
       set base-shape "gun"
       set gun-type 0
       set fire-rate 5
       set g-number gindex
       setup-bullet
       setup-crosshair
     ]
end 

to setup-trees
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
  set-default-shape trees "grass"

  let row max-pycor
   repeat world-height
   [ ask patches with [ pycor = row and pxcor > min-pxcor + 5 and random 10 < 7 and (min-pxcor + random world-width ) < pxcor  ]
     [ sprout-trees 1
       [ set heading 0
        if-else random 10 > 3
        [ set size floor (1 + random 2) stamp die ]
        [ set shape "tree"
          set size floor (2 + random-normal 2 1)
         set is-falling? false
        ]
      ]
    ]
     set row row - 1
   ]
end 

to tree-fall
   set is-falling? true
end 

to setup-bullet
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
       hatch-bullets 1
       [ ;; set bullet self
         set shape "line"
         set size world-width
         set color white
         ; __set-line-thickness .2
         set my-gun myself
         ask my-gun [ set my-bullet myself ]
         hide-turtle
       ]
end 

to setup-crosshair
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   hatch-hairs 1
   [ ;; set crosshairs self
     set color white
     set heading 0
     set size 3
     set target nobody
     home
     set my-gun myself
     ask my-gun [ set my-crosshair myself ]
   ]
end 

to setup-first-message
   message-create "STOP THE ZOMBIES!"
end 

to message-create [ #message ]
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ;; TRICK: since anything can ask a patch to do something,
   ;; and a patch can always SPROUT, this trick uses a patch to sprout a turtle
   ;; so that either the observer, a turtle, or even another patch can create a turtle.
   ask patch mid-pxcor max-pycor
   [ sprout-messengers 1
     [ set shape "message"
       set size 1
       set color white
       set label (word #message "   ")
     ]
   ]
end 

to setup-default-shapes
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   set-default-shape zombies "zombie0"
   set-default-shape guns "gun"
   set-default-shape gobs "gob"
   set-default-shape bullets "bullet"
   set-default-shape hairs "cross-hair"
end 

to setup-globals
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   set g -0.03  ;; gravity constant
   set game-over? false ;; game over flag
   set kills 0
   set counter 1
   set speed .1
   set level 0
   ; set ticks 0
   set tocks random 5
   set full-auto? false
   set long-range min-pxcor + world-width * .5
   set mid-range min-pxcor + world-width * .25
   set point-blank min-pxcor + world-width * .125
   set truck! 0
   set full-auto? false
   set mid-pxcor min-pxcor + world-width * .5
   set mid-pycor min-pycor + world-height * .5
end 

;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.

to go
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
    every ( 1 / 60 )
    [
     ifelse game-over?
     [ if not ( any? zombies or any? gobs or any? messengers ) [ stop ]
     ]
     [ aim
       fire
       if ticks mod 100 = 0 [ barrier-repair ]
     ]
     zombies-move
     gobs-fly
     trees-fall
     message-update
     tick
    ]
end 

to aim
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ifelse full-auto?
   [ ask hairs
     [ if (not is-a-zombie? target or random-float 1.0 < .1)
       [ if ( any? zombies with [ pxcor < (max-pxcor - (.75 * max-pxcor)) ] )  or (random-float 1.0 < 0.05 and any? zombies)
         [ let targets (zombies with [ pxcor < (max-pxcor - 5) ])
           ifelse any? targets with [ not burning? ]
           [ set target min-one-of targets with [ not burning? ] [ [ distance myself ] of [ my-gun ] of myself ] ]
           [ set target min-one-of targets [ [ distance myself ] of [ my-gun ] of myself ] ]
         ]
       ]
       ifelse is-a-zombie? target ;; move cross-hair to target
       [
         setxy (.6 * xcor + .4 * [ xcor ] of target) (.6 * ycor + .4 * [ ycor ] of target )
       ][
         setxy (.8 * xcor + .2 * mid-pxcor) ( .8 * ycor + .2 * ( mid-pycor + world-height * .4 * sin (who * 30 + 3 * ticks) ) )
       ]
     ]
     ask guns [ face my-crosshair ]
     ask bullets [ set heading [ heading] of my-gun ]
     set fire? any? hairs with [ is-a-zombie? target ]
   ]
   [
     if mouse-inside?
     [ let mx mouse-xcor
       let my mouse-ycor
       ask hairs [ setxy mx my ]
       ask guns [ face my-crosshair ]
       ask bullets [ set heading [ heading ] of my-gun ]
     ]
     set fire? mouse-down?
   ]
end 

to fire
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ask guns
   [ ifelse ticks mod fire-rate = 0 and fire?
     [ ask my-bullet [ show-turtle ]
       set shape (word base-shape "-fire")
       set shots shots + 1
       if any? zombies
       [ let hit min-one-of zombies with
             [ abs subtract-headings (safe-towards myself ) (180 + [heading] of myself ) < 2
             ] [ distance myself ]
         ifelse is-a-zombie? hit
         [ set hits hits + 1
           ask my-bullet
           [ set size distance hit ]
           ask hit
           [ zombie-injury ]
         ]
         [ set misses misses + 1
           ask my-bullet [ set size world-width ]
         ]
       ]
     ]
     [ ask my-bullet [ if not hidden? [ hide-turtle ] ]
       if shape != base-shape [ set shape base-shape ]
     ]
   ]
end 

to-report safe-towards [ agent ]
   ifelse patch-here = [ patch-here ] of agent
   [ report 0 ]
   [ report towards agent ]
end 


;;;
;;; Previous fire routine, when gun fired individual pellets, in various patterns
;;;to fire
;;;   ask gun
;;;     [
;;;       ifelse gun-type = -1  [ make-bullets 1 0 0 0 0 ]
;;;       [ ifelse gun-type = 0  [ make-bullets 2 0 0 -.5 1 ]
;;;       [ ifelse gun-type = 1  [ make-bullets 3 0 0 -1 1 ]
;;;       [ ifelse gun-type = 2  [ make-bullets 3 -5 5 0 0 ]
;;;       [ ifelse gun-type = 3  [ make-bullets 4 0 0 -2 1.25 ]
;;;       [ ifelse gun-type = 4  [ make-bullets 5 -20 10 0 0 ]
;;;       [ ifelse gun-type = 5  [ make-bullets 5 0 0 -4 2 ]
;;;       [ ifelse gun-type = 6  [ make-bullets 7 -15 5 -3 1 ]
;;;                              [ make-bullets 7 -15 5 -6 2 ]
;;;       ]]]]]]]
;;;     ]
;;;end


;to bullets-fly
;;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
;   ask bullets
;   [ if not can-move? 1
;     [ die ]
;     jump 1
;     let targets (zombies-on neighbors) with [ abs (pxcor - [pxcor] of myself) < 1.5 and abs (pycor - [pycor] of myself) < 3 ]
;     if any? targets
;     [ ask one-of targets
;       [ zombie-injury
;       ]
;       die
;     ]
;   ]
;end

to trees-fall
   ask trees with [ is-falling? ]
   [ jump (-0.5 * size)
     lt 5
     jump ( 0.5 * size)

     if heading < 270 and heading > 250 [ die ]
   ]
end 

to gobs-fly
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ask gobs
   [
     set vy vy + g
     let nx xcor + vx
     let ny ycor + vy
     if nx < min-pxcor or nx > max-pxcor
        or ny < min-pycor or ny > max-pycor
     [ die
     ]
     set ttl ttl - 1
     if ttl <= 0
    [ set shape "puddle" if color != black [ set color red ] stamp die ]
     setxy nx ny
     rt 10
   ]
end 

to gobs-birth [ qty looks new-size]
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   hatch-gobs qty
   [ gob-props
     ifelse looks = ""
     [ ;; standard gore
      if-else [sub-breed] of myself = trucks [ set color one-of [ red black ]] [ set color red ]
       set size one-of [1.0 1.5 2.0 ]
     ]
     [ ;; different size or shape gore (e.g.: trucks, mutant )
       set shape looks set size new-size
     ]
   ]
end 

to gob-props
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   set vx -.3  + random-float 2.0
   set vy random-float .5
   set ttl 20
   set label ""
end 

to zombies-move
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   if ticks mod 2 != 0 [ stop ]
   ;; make new zombies
   if game-over? != true and count zombies < 35 + 5 * level and random 10 <= counter
   [ zombie-birth
   ]
   ask zombies
   [ ;; if random 100 <= counter [ face one-of guns ]
     if not is-patch? patch-ahead 1
     [ zombie-death ]
     if not ( any? (other zombies-on patch-ahead 1)
              or any? other zombies-here with [ who < [who] of myself ] )
     [ if  sub-breed = giants or sub-breed = trucks
       [ ask trees in-radius (size * .5) [ tree-fall ] ]
       jump pace
     ]

     ;; update animation
     set frame frame + .5
     if frame >= 4
     [ set frame 0
       if burning?
       [ set integrity integrity - 1
         ask zombies in-radius ( size  )
         [ zombie-start-burning ]
         if integrity <= 0
         [ update-counters
           zombie-death
         ]
       ]
     ]
     set shape (word base-shape floor frame)


     if shade-of? pcolor barrier-base-color
     [ let rad size * .5
       if burning? [ set rad size ]
       ask barrier in-radius rad [ set pcolor background-color ]
       zombie-death
     ]

     if pxcor <= min-pxcor
     [ zombie-death ]
   ]
   ;; set label integrity
end 

to-report in-far-right-column
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   report pxcor = max-pxcor
end 

to-report in-the-middle-rows
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   report pycor < max-pycor - 5 and pycor > min-pycor + 5
end 

to-report no [ #things ]
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   report not any? #things
end 

to  zombie-birth
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   let birth-patches patches with [ in-far-right-column and in-the-middle-rows and no zombies-here ]
   if any? birth-patches
   [ ask one-of birth-patches
     [ sprout-zombies 1
       [ zombie-initialize-regular
         ;; aim the zombie at some barrier brick
         ;; when the barrier is broken down, makes the zombies more deadly
         if any? barrier with [ shade-of? pcolor barrier-base-color ]
         [ face one-of barrier with [ shade-of? pcolor barrier-base-color ]
         ]
         ;; maybe make a fast zombie..
         if-else random 100 < 5 + level
         [ zombie-modify-make-fast
         ][
         ;; maybe make giants!!
         ifelse level >= 10 and random 100 < 2
         [ zombie-modify-make-giant
         ][
         ;; maybe make trucks (or bulldozers)
         if truck! < level and (level mod 4 = 0 or level > 20)
         [ zombie-modify-make-truck
         ]]]
       ]
     ]
   ]
end 

to zombie-initialize-regular
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   set heading  270
   set color green + level * 10 - 1 + random-float 2
   set size 3
   set frame 0
   set pace speed + random .1
   set integrity 1 + int (level * .1)
   set base-shape "zombie"
   set bonus 0
   set sub-breed zombies
   set burning? false
   set inflammable? true
end 

to zombie-modify-make-fast
   set pace 1
   set color color - color mod 10 + 8
   set integrity 1 + int (.25 * integrity)
end 

to zombie-modify-make-giant
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   set size size * 3
   set pace pace / 3
   set integrity integrity * 10
   set bonus 1000
   set sub-breed giants
   set base-shape "zombie"
   message-create "ALERT! GIANT MUTANT ZOMBIE!"
end 

to zombie-modify-make-truck
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   set heading 270
   set truck! level
   set base-shape one-of [ "truck" "dozer" ]
   set shape (word base-shape "0")
   set size size * 2
   set pace .1
   set integrity integrity * 100
   set bonus 3000
   set sub-breed trucks
   set burning? false
   set inflammable? false ;; trucks don't burn
   message-create (word "ALERT! " caps base-shape " RIDING ZOMBIE!" )
end 

to zombie-injury
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   let damage 0
   if [ gun-type = 1 ] of myself
   [ zombie-start-burning ]
   set damage damage-by-range
   set integrity integrity - damage
   ifelse integrity <= 0
   [ update-counters
     zombie-death
   ]
   [ gobs-birth damage "" 0
   ]
   if [ gun-type = 0 ] of myself [ if xcor + .1 < max-pxcor  [ set xcor xcor + .1 ] ]
end 

to zombie-start-burning
   if inflammable? and not burning?
   [ set burning? true
     ;; permanently modify base-shape
     set base-shape (word base-shape "-burning" )
   ]
end 

to-report damage-by-range
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ifelse pxcor < point-blank [ report 8 ][
   ifelse pxcor < mid-range [ report 4 ][
   ifelse pxcor < long-range [ report 2 ][
   report 1]]]
end 

to zombie-death
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   let gc count gobs + count zombies ;; gob-count
   ;; ngc = new gob count
   let ngc ifelse-value ( gc < 100 ) [ 5 ] [ 0 ]
   let ngs 1
   set base-shape remove "-burning" base-shape
   if-else gc > 200 [ gobs-birth 1 "" 0 ]
   [ if gc < 200 [ let index 1 repeat 4 [ gobs-birth 1 (word base-shape "-part" index) size  set index index + 1 ] ]
     if gc < 100 [ gobs-birth 5 "" (1 + random-float 1.0) ]
     if gc < 50 [ gobs-birth 10 "" (1 + random-float 1.0) ]
   ]
   if not any? barrier with [ shade-of? pcolor blue ]
   [ game-over ]
   die
end 

to make-bullets [ qty offset spread y-off y-inc ]
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   set offset heading + offset
   hatch-bullets qty
   [ jump 2.5
     set heading offset
     let nx xcor + y-off * sin ( heading - 90)
     let ny ycor + y-off * cos ( heading - 90)

     set offset offset + spread
     set y-off y-off + y-inc

     if nx < min-pxcor or ny < min-pycor or ny > max-pycor [ die ]
     setxy nx ny
     set color 8 + 10 * random 13
   ]
end 

;to update-score [ amt ]
;;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
;   set score score + amt
;   ; set [plabel] of scoreboard (word score ":" level )
;end

to update-counters
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   set kills kills + 1
   set score score + 1 + level + bonus
   set counter counter + 1
   if counter >= 250
   [ set counter counter - 250
     set speed speed * 1.5
     if speed > 1 [ set speed .1 ]
     set level level + 1
     ask one-of guns
     [ ifelse gun-type = 0
       [ ifelse fire-rate > 2 ; and level mod 1 = 0
         [ message-create "RELOAD RATE UPGRADE!"
           set fire-rate fire-rate - 1
         ]
         [if fire-rate <= 2 and level >= 20
         [ set gun-type 1
           ask my-bullet [ set color red ]
           set base-shape "gun1"
           set fire-rate 6
           message-create "WEAPON UPGRADE!"
         ]]
       ]
       [ if fire-rate > 1 ; and level mod 5 = 0
         [ set fire-rate fire-rate - 1
           ; __set-line-thickness .1 * fire-rate
           ifelse fire-rate <= 1 [ ask my-bullet [ set color blue ]][
           if fire-rate < 3 [ ask my-bullet [ set color lime ]]
           ]
           message-create "BEAM REFRESH UPGRADE!"

         ]
       ]
     ]
   ]
end 

to game-over
   ask hairs
   [ home
   ]
   if ticks mod 10 = 0 [ message-create "GAME OVER!" ]
   set game-over? true
end 

to setup-background
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ask patches
   [ set pcolor background-color
   ]
end 

to-report background-color
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
    ;; reports a textured background color for the current patch, based on patch location, etc.
    report brown - 5 + .1 * random 5 + 6  * ((pycor - min-pycor) / world-height) ;
end 

to setup-barrier
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ;; defines and colors the patches that comprise the barrier
   set barrier patches with [ pxcor <= min-pxcor + 5 ]
   ask barrier [ set pcolor barrier-color ]
end 

to-report barrier-color
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ;; reports the barrier color for the current patch
   report barrier-base-color - 3 + pxcor - min-pxcor + ((pycor + pxcor) mod 2)
end 

to-report barrier-base-color
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ;; reports the barrier base color
   ;; hack--for better speed should really be a global
   report blue
end 

to barrier-repair
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ;; if barrier needs repair, repair one cell of the barrier
   if any? barrier with [ not shade-of? pcolor barrier-base-color ]
   [ ask one-of barrier with [not shade-of? pcolor barrier-base-color and any? neighbors4 with [ shade-of? pcolor barrier-base-color ] ]
     [ set pcolor barrier-color ]
   ]
end 

to auto-fire
;; ~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.~�����~.�_�.
   ;; toggle / initialize if needed, the full-auto variable
   set full-auto? (full-auto? = false)
   let state "DE-"
   if full-auto? [ set state "" ]
   message-create (word "AUTO-FIRE " state "ACTIVATED")
end 

to message-update
   ask messengers
   [ if pycor <= min-pycor [ die ]
     set ycor ycor - .5
     set color 9.9 - color
   ]
end 

to-report caps [ #text ]
   let uc "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   let lc "abcdefghijklmnopqrstuvwxyz"
   let result ""
   let c ""
   foreach n-values length #text [ i -> item i #text ]
   [ ? -> set c ?
     let i position c lc
     if i != false
     [ set c item i uc ]
     set result (word result c)
   ]
   report result
end 

to-report promote [ #char ]
end 


There are 2 versions of this model.

Uploaded by When Description Download
James Steiner 11 months ago Bug fix Download this version
James Steiner 11 months ago Initial upload Download this version

Attached files

File Type Description Last updated
Zombie Attack! 2.2.0.png preview Preview for 'Zombie Attack! 2.2.0' 11 months ago, by James Steiner Download

This model does not have any ancestors.

This model does not have any descendants.