Spawning cubes and Hero Health

Our hero now has health (albeit as a text value) and random spawning Gelatinous Cube’s!

Gelantious Cube monsters

The Gelantious Cube cannot be attacked with normal weapons, it just consumes them. The only way to defat a gelantious cube is that it will smear our hero, reducing his health ! As the cubes are randomly spwaning the are a dangerous collective ! The cubes, unlike the monsters, do not follow a path, they move randomly square to square, so our hero stands a chance of avoiding them by quick movements !

Snippets of the relevant cube creation, movement and consume are given below, as is the food and drink routines to increase health, please note this is almost pseudo code as they are not within their procedures.

;; if we encounter a cube, we cannot defeat it, only reduce our health by 5  
if any? cubes-here
  [ set health health - 5
    ask cubes-here [ die ] ]
;; cubes moving on a random-path
to move-cube ;; observer procedure for cube
  ask cubes
  [ ;if cube-eaten?
    fd 1
;; cube spawn routine, the coundown value reduces or increases the number of cubes being generated
to make-cube ;;
  ifelse next-cube-in = 0
  [ set next-cube-in 3 ]
  [ let cube-patch one-of patches with [treasures-grid? and
                                                not any? bonuses-here and
                                                not any? treasures-here]
    if cube-patch != nobody
    [ ask cube-patch
      [ sprout-cubes 1
        [ set shape "square"
          set heading 0
          set color one-of base-colors
          set value (random 10 + 1) * 100
          set cube-countdown random 200 + 50 ] ]
      set next-cube-in 10 + random 1 ] ]
;; food and drink
  ;; food
  if any? foods-here
  [ set health health + 9 
    ask foods-here [ die ]
  ;; drink
  if any? drinks-here
  [ set health health + 5
    ask drinks-here [ die ]

Leave a Reply

Your email address will not be published. Required fields are marked *