Dev 129 – Introduction to GameMaker 6

Making video games has never been easier.
Game Maker, reached version 6 has become a powerful tool that can deliver professional results with little effort, even to inexperienced programmers.


Introduction

Setting up your own game is a dream that many are running after, often without success. To do it yourself as well as having considerable experience in programming is necessary to have also expertise in the field of libraries as graphics, sound, controls and so on.

Game Maker allows us to overcome all these problems in one fell swoop. The software we are announcing today brings together, in one simple development environment, many tools that allow us to achieve amazing results with a few clicks instead of thousands lines of code.

The main idea behind Game Maker is to harness the power of drag and drop graphical interfaces, that makes possible, in a simple and fast manner, to load sprites and sounds, creating the characters of the game, defining their behaviour, design the look of the various levels and add backgrounds.

Version 6 also introduces other important features such as the OpenGL support for graphics acceleration to develop 3D games like First Person Shooter or FPS, the multiplayer gaming ability through network, sounds effetcs such as reverb, chorus, echo and 3d projection, and many others that make this environment a powerful tool for making professional games.

For the more experienced and demanding developers Game Maker provides a scripting language that is very easy to use: the GML. Even if GML could supply to many of the needs of development, another interesting approach is the possibility to create external DLLs, with preferred programming language, and plugging them in Game Maker games.

Anatomy of a Game Maker game

A video game created with Game Maker comes to life in an area called room, that is comparable to a game level, where you place the various objects. Typical objects could be the ‘main character’, the ‘flying objects’, the ‘enemies’ or ‘barriers’ along the way.

The environment

At first glance the visual environment may seem simple and bare due to the absence of dozens of icons and menus that you can found in other tools. The main window is in fact provided with a few pull-down menu, very few buttons and a menu tree positioned vertically on the left (see Figure 1 for reference), but this should not be cause for concern or to believe that Game Maker is a very functional product.

Figure 1 – Shows the main window of Game Maker 6

Each item in the tree menu, in fact, represents a fundamental aspect in the creation of games and that is where we will focus our interest. The following box presents a summary of the most important of these.

Object

Represents the main entity of a game in Game Maker

Room

The area inside which all game objects can be placed and moved

Sprite

Single image or sequence of images used to represent a game object

Background

An image placed as background of a room

Sound

A background music or sound fx

Script

A program written in GML (Game Maker Language)

We consider ‘obstacles’ as inanimate objects that do not have any behaviour. In the other cited cases, however, objects are able to perceive the events that may happen during the game and react to them in an appropriate way. Such happenings are called events, and reactions to events are called actions. In Game Maker there are numerous events, and many types of actions to be taken in relation to them.

Each visible object on the screen is represented by an image or a series of images; such representation is called sprite. Examples of sprites are: a ‘ship’, a ‘ghost’ or an ‘explosion’. If a sprite is composed of a series of images then the visual result may be more significant, giving rise to an animation.

Once you defined sprites, objects and rooms, your game is ready to be compiled and distributed in an executable file which contains, within it, all resources required by the project (sounds and images), so id not necessary any special installation procedure to it to work properly.

Objects

An object is the basic and ‘alive’ constituent of a game. To create one just point with the mouse on the folder called objects, press right button and select ‘Add Object‘.

Now you can see the message ‘Object Properties‘ as shown in Figure 2. Here, from the left, there are: a box to enter the object name, the sprite context menu (visible by clicking the little icon to the right of the text box), a checkbox that specifies whether you want your object to be visible, another that indicates whether the object should be considered solid and, the last, ont presenting parameters that are not needed for now.

Figure 2 – This is the appearance of the object’s proper window

At the immediate right you can see a list labeled ‘Events‘. Pressing the button ‘Add Event‘, you can choose which of the many events available, the object has to respond to. In Figure 3 there is shown an image of the events selection window.

Figure 3 – Each button in this window represents a specific category of events

Let’s see the next list, the one with the label ‘Actions‘. This serves to specify the sequence of actions that an object must perform when the selected event occurs. The possible actions, and there are many organized by categories, are visible as icons in the menu on the right. They deals of object movement, instances creation and destruction, sounds execution, game state save and load, variables creation, control flows creation, lives management, energy management, score management and many other tasks.

If you, for example, select the event ‘Key Press‘ and then ‘Left‘, whenever the right arrow key is pressed, we could indicate to the object to move in that direction. This result can be achieved by simply dragging the icon, with eight red arrows on the action list, in the table labeled ‘move’ and setting the direction and speed parameters.

In this way, simply by dragging the appropriate actions and setting the correct parameters it is possible to let the objects perform any kind of operation.

Sprites

Game Maker gives the option of using existing sprites from files and uploading them and for this is able to recognize the most common graphics formats such as JPG, BMP, PNG, PSD, WMF, ICO, PSP and others. It is also possible to edit them or create new ones using the Image Editor an editor full of tools for image drawing, retouching and transformation. For an example see in Figure 4.

Figure 4 – The integrated image editor presents same functionalities of a common drawing software

Those who are already familiar with paint programs and / or editing will find in it a very simple and familiar environment.

If you want to add a new sprite to a project it is done just like any object, by positioning the mouse on the folder and selecting ‘Add Sprite’ from the popup menu. The entry window for sprites has two buttons: ‘Load Sprite’ and ‘Edit Sprite’. The first is to load an existing file using the common Windows dialog box, while the latter opens the window called ‘Sprite Editor’. This editor has all the functions needed to create, organize and edit sequences of pictures that make the sprite. In the various menu are present commands for changing the order of the images or to create new animations by rotating, resizing or converting, with morphing effect, a single image.

Figure 5 – As shown in this image, sprite frames are arranged in sequences and for each one is possible to access to the “Image Editor” via double-click.

Rooms

As we have already said, a room is an area that represents the visible two-dimensional “window” of a video game in which you can position objects. Here they can move, interact, be modified, created and destroyed. When you create a room, through the usual procedure, the editor appear containing a series of sub-menus and tables and a representation of the room, formed by a gray rectangle.

If you select the table named ‘objects‘ under the heading ‘Object to add with left mouse’ you can choose an object and you can place it, among those previously defined, in the desired position by pressing the left mouse button inside the rectangle. Upon execution of the program, each object will occupy choosen coordinates.

Inside the table ‘settings‘ you can enter a name for internal use of the room, its size in pixels, the title to be applied to the window and drawing speed in frames per second. Through this last setting you can get our game going at the same speed on every the computers on which it is launched.

The table ‘backgrounds‘ is used to associate a color or an image, as background to a room, from those included in the section, and decide how to fit when it is larger than the boundaries of the room.

The table ‘tiles‘ allow to create a room by composing many small images like a mosaic.

Finally the last table, called ‘views’, is another great feature of Game Maker. Often, infact, in a 2D video game the objects and the background move following the movement of the main character while it is always positioned at the center of the screen. By setting the object to follow and the area within it must remain Game Maker will do all work necessary to achieve this effect.

Figure 6 – Inside a room object are placed directly with the mouse

Backgrounds

Regarding backgrounds there is very few things to say. Inside the ‘backgrounds‘ folder you can upload all the pictures you want to use as background for rooms. When you choose to create a new wallpaper, Game Maker has a window similar to that seen for the sprite which contains buttons ‘Load Background‘ and ‘Edit Background‘. The first one is used to load an external file and the latter to launch the ‘Image Editor‘, already seen.

Sounds

Inside the box ‘sounds‘ you can load all sound effects and background musics. Game Maker recognizes the WAV, Midi and MP3 audio file formats and allows to apply them various effects such as chorus, reverb, echo, etc.. We can also dip a sound in a simulated 3D environment and set its spatial position through the x, y, and z coordinates.

Figure 7 – This image shows the dialog for the sounds settings

Game Maker does not include an editor for sounds. To compensate you can choose your preferred external editor to run pressing the ‘Edit Sound’ button.

Scripts

GML is a scripting language consisting on a subset of C. Those who are already familiar with this language will find no particular trouble writing a script.

Just keep in mind that there are no data types in GML so declaring a variable, this, will be treated as an integer, floating point number, code instance of an object, string, etc. according with the necessity. In the absence of a real variable declaration mechanism, in addition, the memory required for their use is allocated when the interpreter, in a block of code, meets the first occurrence of a variable. Is possible to use the keyword ‘global’ to indicate that the visibility of a variable is extended to the whole project, such as in the following script:

{
     // Creates a local variable that stores the instance of
     // a new object player
     player = instance_create(100, 250, objGiocatore);
     // Creates a global variable that stores the number of
     // Remaining lives of the player
     global.LivesCount = 3;
}

Arrays are treated in the same way, in fact, to create one is sufficient to indicate an index between square brackets just after the variable name, in this manner:

{
     // Create instances of 10 new monsters and use an array
     // to memorize their Id
     for (i = 0; i < 10; i += 1) {
         monsters[i] = instance_create(i * 16, 100, objMonster1);
     }

     // Moves the newly created monsters by 16 pixels
     // horizontally using the Ids stored in the array
     for (i = 0; i < 10; i += 1) {
        monsters[i].x += 16;
     }
}

There are no unary increment (++) and decrement (–), while the conditional constructs if {…} else {…}, switch () … case, the for and while loops and keywords break, continue, exit and return are identical to those of C.

There are two added keywords the first of which has the same meaning of Visual Basic through which, as you can see in the following code block, you can omit the object name to gain access to its properties, as in

{
     // Without 'with' block
     player.x = 100;
     player.y = 100;
     player.image_speed = 10;

     // With 'with' block
     with (player)
     {
         x = 100;
         y = 100;
         image_speed = 10;
     }
}

The second added keyword is the word ‘repeat‘, which allows you to repeat a command the number of times you want. Example:

{
     // Create 100 instances of obstacles in a random place
     repeat (100) instance_create(
          random(room_width),
          random(room_height), 
          objOstacolo
     );
 }

Also the comments are identical to those of C, ie, the symbols / * … * / for multiline comments

/*
    Text
    of
    comment
 */

and the symbol //

// Text of the comment

for the single line.

The function ‘instance_create‘, serves to create programmatically a new instance of an object existing in the project and is one of hundreds of functions that GML has available.

GML also has a number of internal variables and constants which can be referenced during the game to gain control over various aspects such as the size of the running room

room_width
room_height

or the sprite animation display speed

<sprite name>.image_speed

How to obtain Game Maker

The homepage of Game Maker is www.gamemaker.nl (today hosted at http://www.yoyogames.com) from which you can download the installation files, but are also present various resources (sprites, backgrounds, and sound examples), some tutorials and different sample games.

We must, however, clarify that Game Maker is not a freeware product, but requires the payment of a modest fee for registration: actually 15 Euro. The free downloadable version, in fact, prevents the use of some features and shows up a warning splashscreen every time you run a project.

Conclusions

There are many features that was not discussed that allow the realization of very complex games such as paths, the time line, the management boards of the scores, the ability to write to the registry and so on.

We must consider that the code produced by Game Maker is already tested and safe and consequently the debugging time is very low and allow to distribute your work safely.

One downside is that Game Maker does not provide an effective system for debugging so sometimes results difficult to trace the behavior of the scripts.

Bibliography

[1] Mark Overmars, “Designing Games with Game Maker”, www.gamemaker.nl

Original article

Downloads

Leave a Reply

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