On completion of this tutorial and practical, you will be able to…
• Build a game with more than 1 room
• Use views to navigate around the Game World
• Understand what are and how to use variables
You have already created a simple game using Game Maker in your last lab. In this lab we will build on our existing knowledge and create the first part of the Bugs Shooter Game. The second part of the game will be done in the next lab session.
The Game Idea
You may be familiar with a genre of games known as Top-down shooters, where you usually control a plane which moves in the bottom of the screen and shoot at enemies at the top. There are also variants that let you control a plane which is located at the left of the screen and you shoot enemies to the right. We will now try to create a simple game of this genre.
Here is our description of the game:
The game involves a fighter plane (Main character) than will shoot down flying bugs. For each bugs destroy the plane will be rewarded with points. The plane will try to destroy as many bugs as possible.
The game has two rooms (Game World). In the first room, the plane will kill ordinary bugs that can be destroyed with one hit. The second level involves an enemy spaceship that requires multiple hits to destroy.
The Design Document
The next step in creating a game is to write a design document. You are recommended to always do this before making your game. Here is our design document for Bugs Shooter.
Variables and Properties
Before we can develop the bug shooter game we need to delve a bit into an important concept of Game Maker: the use of variables. This simple concept will provide a very powerful mechanism to enable much more interesting game play.
So what is a variable? It can best be seen as a property of an instance of an object. As you should know, there are certain properties we can indicate when we define an object. For example we can set it visibility or its state (solid). There are also a number of actions that change certain properties. For example there is an action to change the position or the speed of the instance. Each instance has a number of such properties and there are also a number of global properties, like the score, that are not related to individual instances.
All properties are stored in so-called variables that have a name. Here are some of the properties/variables that each instance has:
x: the x-coordinate of the instance
y: the y-coordinate of the instance
hspeed: the horizontal speed (in pixels per step)
vspeed: the vertical speed (in pixels per step)
direction: the current direction of motion in degrees (0-360; 0 is horizontally to the right) speed: the current speed in this direction
visible: whether the object is visible (1) or invisible (0) solid: whether the object is solid (1) or not solid (0) And here are some global variables: score: the current value of the score
lives: the current number of lives
mouse_x: x-position of the mouse
mouse_y: y-position of the mouse
room_speed: current speed of the room (in steps per second) room_caption: caption shown in the window title
room_width: width of the room in pixels
room_height: height of the room in pixels
There are many more variables, both local(for the instances) and global(for the whole game). All of them can be found in the Game Maker documentation. There are actions which manipulate the value of certain variables but, as we will see, you can also manipulate them directly.
What is better, you can define your own variables and use these as well. For example, as we will see below, we want our plane to be able to...