Gamemaker Second tutorial:
Big Game Hunter
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
Create an empty 640x480 room and give it any stock background.
- 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.
Create a hunter object and assign the sprite to it.
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.
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.
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.
- 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.
- 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.
Add some obstacles.
Tune the game to make it somewhat playable.
Last update: October 4, 2007