Gamemaker Second tutorial:
Big Game Hunter

COMP 1501 Tutorial #4: Game Maker Variables

Tutorial 2: Game Maker Variables

Designed by: Ahmed Hassan and Glenn Hickey


The emphasis of this tutorial is manipulating variables in Game Maker. You will use variables to make a sophisticated big game hunting simulator. It is assumed that you understand the basic material from Tutorial 3.


You will surely have many good ideas of how to spruce up the game as it is described below. This is great, but make it a priority to accomplish the following objectives before the end of class so you can get your mark:

  • Hunter with keyboard controls to rotate, move and shoot
  • At least one kind of animal with health, speed and score
  • Bullets that do damage and forced pause between shots
  • An obstacle
  • A view that follows the hunter
  • Proper handling of objects that leave the room


  1. Create an empty 640x480 room and give it any stock background.

  2. Create a hunter sprite using this graphic. ( based on source from here . )

    • Move the sprite's origin to its center.
    • Make a rotation animation by giving it a 32 frame counterclockwise rotation sequence (from the animation pull-down). Notice this creates 32 images, indexed from 0 to 31. You can reference them later with the image_index variable.
  3. Create a hunter object and assign the sprite to it.

  4. Hunter's keyboard movement

    • On creation of a hunter instance, set an angle variable to 0. Also, set image_speed to 0 so it only animates when you want it to. (Variable-related events are in the control tab.)
    • On a Keyboard Left event, increase angle by 10. If the resulting value is greater than 359, subtract 360. Set image_index to the index that best matches angle: (HINT: image_index = 32 * angle / 360. You should try to understand why this works).
    • Do Keyboard Right on your own.
    • Upon a Keyboard Up event, Move Free in the direction of angle with speed 2.
    • Finally, make the hunter stop when Up is released. Use an End Step event to trigger a Move Free action with speed 0.
    • TEST!
  5. Make an animal object.

    • Create sprite using clip art from here .
    • On creation of your animal, set a health variable.
    • On leaving the room (Outside room event in Other), the instance should be destroyed.
    • Make one type of animal for now and add more later if you have time.
  6. Make an animal generator object.

    • It should be invisible and non-solid.
    • On creation, set an alarm for each type of animal you made.
    • When an alarm for an animal triggers, Create a Moving Instance of that animal and reset the alarm. Use random(room_width), random(room_height) and random(360) to give it a random starting point and motion. Speed is up to you.
    • Place an instance of the generator somewhere in your room.
    • TEST!
  7. Handle Shooting

    • Make a bullet object. You can use the "dot" sprite in Game Maker.
    • Destroy bullet instances when they leave the room like you did for your animals.
    • Add collision events to your animals . The collision event should destroy the bullet (other) and decrease the health variable by one. If the health is 0, destroy the animal instance and update the score.
    • In the Hunter, set a variable can_shoot to 1 on creation.
    • Find an unused alarm and make an event for it in the hunter. When it goes off, it should set can_shoot to 1.
    • Add a Keyboard Space event. If can_shoot is 1, it should create a moving instance of the bullet at 0,0 relative to the hunter, moving in direction angle, then set can_shoot to 0 and reset the alarm.
    • TEST!
  8. Add Scrolling

    • Make your room bigger.
    • Enable views. Make View 0 visible and set it to follow the hunter.
    • Force the hunter to stay in bounds. You can use an Outside Room event with a Wrap Screen action.
  9. Add some obstacles.

  10. Tune the game to make it somewhat playable.

  11. Get Hunting!

    Last update: October 4, 2007