Zombie Dogs From Hell
An Example Game

Zombie Dogs From Hell is a simple action game. The player is the droopy blue-eared dog in the bottom left corner of the screen. The idea of the game is to collect all of the bones. When the bones have all been eaten, the player's kennel appears in the top right corner of the game field and, when the dog reaches this point, the level is complete. The other dogs will chase you around the screen. There are currently 4 levels in the game.

Unlike the other game tutorials, you will not find step-by-step instructions for making this game. It is quite a complex little game and the instructions are likely to go on forever. Instead you can find a copy of the completed game file by clicking dogs.gmk. Further explanation of how the game was made is included below the screenshot.

Game Maker Screenshot

How The Game Was Made

You will get the best sense of how this game works by looking at the game file and the objects that have been designed. Text versions of the events that cover basic character and enemy movement are included on this page.

Bear in mind that this game was all done using the action icons.

Basic Character Movement

Once the game field has been set up, the blocks drawn, the ladders positioned, the bones distributed around the place, it's time to get the character movement sorted.

Moving left and right is a simple matter of checking that there are no blocks in the position that the character is moved into, changing the sprite to the one facing in the direction of movement, then making it move.

Left

if at relative position (-9,0) there is not object obj_block
   set the sprite to spr_ch_left with subimage 0 and speed 1
   move relative to position (-8,0)

Right

if at relative position (9,0) there is not object obj_block
   set the sprite to spr_ch_right with subimage 0 and speed 1
   move relative to position (8,0)

Moving up and down depends on the position of the ladder in relation to the character. It is therefore a little more complicated. You have also got to make sure that the character is not left in mid air.

Up if at relative position (-4,0) there is object obj_ladder
   if at relative position (0,-1) there is not object obj_block
      set the sprite to spr_ch_climb with subimage 0 and speed 1
      move relative to position (0,-8)
   if at relative position (0,1) there is not object obj_ladder
      move in direction 90 at most 8 till a contact with solid objects

Down

if at relative position (-1,8) there is object obj_ladder
   if at relative position (0,8) there is not object obj_block
      set the sprite to spr_ch_climb with subimage 0 and speed 1
      move relative to position (0,8)

Enemy Movement

There are 2 types of enemy. One of them wanders around the game field deciding whether or not to use each ladder randomly. The other enemy chases the character around the screen. Both enemies start off moving either left or right until they hit a block. This collision is handled as follows,

if expression x<32 is true
   start moving in directions 000001000 with speed set to speed
   set the sprite to spr_enemy_right with subimage 0 and speed 1
else
   start moving in directions 000100000 with speed set to speed
   set the sprite to spr_enemy_left with subimage 0 and speed 1

Here, the first job is to check which side of the screen is being hit and applies the appropriate sprite and direction to the character.

The next bit is the most complicated aspect of the whole game. The enemy dog that moves randomly has the following End Step event. This works out whether there is a ladder that the enemy could climb up or down and decides randomly whether to do so. It also manages the movement of the dog up or down the ladder and detects when it has reached the end of the line. At this point, a random decision is taken about which direction to move at the bottom of the ladder. You will not be able to lift these actions out of the game and expect them to work in another context. To do this, I had to think through exactly what was happening to the enemy dog at any point in the game.

if expression climb=0 && canclimb=0 is true
   if object is aligned with grid with cells of 16 by 16 pixels
      COMMENT: check for down
      if at relative position (-1,1) there is object obj_ladder
         if at relative position (0,8) there is not object obj_block
            with a chance of 1 out of 4 do perform the next action
               set variable speed to 0
               set variable climb to 1
      COMMENT: check for up
      if at relative position (-1,-8) there is object obj_ladder
         if at relative position (1,-8) there is object obj_ladder
            if at relative position (0,-8) there is not object obj_block
               with a chance of 1 out of 2 do perform the next action
                  set variable speed to 0
                  set variable climb to 2

COMMENT: going down
if climb is equal to 1
   if at relative position (0,8) there is not object obj_block
      set the sprite to spr_enemy_climb with subimage 0 and speed 1
      move relative to position (0,8)
   else
      set variable climb to 0
      set variable canclimb to 1
      set Alarm 0 to 30
      with a chance of 1 out of 2 do perform the next action
         start moving in directions 000001000 with speed set to basespeed
         set the sprite to spr_enemy_right with subimage 0 and speed 1
      else
         start moving in directions 000100000 with speed set to basespeed
         set the sprite to spr_enemy_left with subimage 0 and speed 1

COMMENT: going up
if climb is equal to 2
   set the sprite to spr_enemy_climb with subimage 0 and speed 1
   move relative to position (0,-4)
   if at relative position (0,0) there is not object obj_ladder
      move in direction 90 at most 8 till a contact with solid objects
      set variable climb to 0
      set variable canclimb to 1
      set Alarm 0 to 30
      align position to a grid with cells of 16 by 16 pixels
      with a chance of 1 out of 2 do perform the next action
         start moving in directions 000001000 with speed set to basespeed
         set the sprite to spr_enemy_right with subimage 0 and speed 1
      else
         start moving in directions 000100000 with speed set to basespeed
         set the sprite to spr_enemy_left with subimage 0 and speed 1

The enemy that chases you does not make random decisions. It uses the position of the character to determine what action to perform when near a ladder. It is also set to turn on the character if it notices that the character is on the same level as it. Its End Step event is summarised below,

if expression climb=0 && canclimb=0 is true
   if object is aligned with grid with cells of 16 by 16 pixels
   COMMENT: check for down
   if at relative position (-1,1) there is object obj_ladder
      if at relative position (0,8) there is not object obj_block
         if expression y<obj_char.y is true
            set variable speed to 0
            set variable climb to 1
   COMMENT: check for up
   if at relative position (-1,-8) there is object obj_ladder
      if at relative position (1,-8) there is object obj_ladder
         if at relative position (0,-8) there is not object obj_block
            if expression y>obj_char.y is true
               set variable speed to 0
               set variable climb to 2
   COMMENT: check for player on same level
   if speed is larger than 0
      if expression y==obj_char.y && x<obj_char.x is true
         start moving in directions 000001000 with speed set to basespeed
         set the sprite to spr_enemy_right with subimage 0 and speed 1
      if expression y==obj_char.y && x>obj_char.x is true
         start moving in directions 000100000 with speed set to basespeed
         set the sprite to spr_enemy_left with subimage 0 and speed 1

COMMENT: going down
if climb is equal to 1
   if at relative position (0,8) there is not object obj_block
      set the sprite to spr_enemy_climb with subimage 0 and speed 1
      move relative to position (0,8)
   else
      set variable climb to 0
      set variable canclimb to 1
      set Alarm 0 to 30
      with a chance of 1 out of 2 do perform the next action
         start moving in directions 000001000 with speed set to basespeed
         set the sprite to spr_enemy_right with subimage 0 and speed 1
      else
         start moving in directions 000100000 with speed set to basespeed
         set the sprite to spr_enemy_left with subimage 0 and speed 1
COMMENT: going up
if climb is equal to 2
   set the sprite to spr_enemy_climb with subimage 0 and speed 1
   move relative to position (0,-4)
   if at relative position (0,0) there is not object obj_ladder
      move in direction 90 at most 8 till a contact with solid objects
      set variable climb to 0
      set variable canclimb to 1
      set Alarm 0 to 30
      align position to a grid with cells of 16 by 16 pixels
      with a chance of 1 out of 2 do perform the next action
         start moving in directions 000001000 with speed set to basespeed
         set the sprite to spr_enemy_right with subimage 0 and speed 1
      else
         start moving in directions 000100000 with speed set to basespeed
         set the sprite to spr_enemy_left with subimage 0 and speed 1