Understanding Game MakerPosted on: February 15, 2015 at 11:42 pm,
This tutorial aims to explain the basics of how Game Maker functions. To a lot of people, opening software like Game Maker for the first time can be super intimidating. You’ve heard how ‘easy’ tools like GM are to use so you download it and open it up and you’re staring at this:
There’s a lot of stuff and a lot of buttons and it can be hard to really grasp what’s going on. Games are complex things! And any powerful tool you can use to make one demands at least a certain level of complexity. GM is however, very accessible once you get over the first few hurdles. In my eyes it remains one of the best tools out there for a beginner game developer. So let’s try and make sense of how a game in Game Maker works, and how the different parts fit together.
That list of categories on the left is your Resource Tree. It contains every element of your game. All of your artwork, objects, levels and so on are kept in this list. When you make a new project, it’s totally empty. Right clicking on any of these categories provides a context menu that allows you to add a new element to that category.
I’m going to cover the four most important resources and how they work together. Understanding this should give you a clearer idea of how GM works at a basic level, before diving into actually trying to make stuff.
Right at the top of the resource tree are “sprites”. Sprites contain the images & animations of your game objects. A sprite might be a single image or it might have a number of animation frames. They also have collision shapes that can be precise, rectangular, circular, etc. You can connect sprites to objects to have them show up in your room. Typically a sprite would be used for objects such as players, enemies, items and other interactive or animated elements of your game.
Backgrounds are similar to sprites, in that they are an image resource. Unlike sprites however, a background image cannot contain any animation frames and does not have any collision settings. This generally makes them faster and less performance heavy than sprites, making them perfect for non-interactive… well… background elements of your game world.
This is the fun part. Objects are where we create all of the logic and interactivity of your game. An object might be an obvious, visual element of your game like the player character, enemies, items and walls. But invisible objects might also be used for something more subtle like tracking the number of lives the player has, controlling the music or volume of the game.
Objects can be assigned a sprite and contain an initially blank list of Events. You can then create events and associate those events with certain Actions. An event is something that happens in your game. The player pushing a key, the object colliding with another object, the object being created or destroyed, the game starting or ending, or even simply a step or frame of your game passing by.
When these events occur in your game, an object will carry out any actions it has associated with that event. Actions can be things like moving the object, destroying the object, having the object create other objects, changing variables and just generally making things happen inside of your game.
This is the key to understanding how a game inside of GM functions. As your game runs, events are triggered, and actions are carried out. The player pushes left, and an object responds by moving left. Games that use the ‘drag and drop’ logic of game maker will use many different actions.
More experienced users will typically make primary use of the “Execute a piece of code” action to effectively create “custom” actions using GML (Game Maker Language) script. As every drag and drop action has a script equivilent there is never an inherent need to use anything but code. This is the most powerful way to use Game Maker and it is highly recommended to learn! (even for beginners who are serious about developing professional games!)
Rooms can be used for many things, they act as containers for all of your game’s objects and background elements. It’s easy to think of rooms as simply the “levels” of your game, but more accurately they could be viewed as simply “screens”. A level of your game might be contained within a room, but so might your menu screen, intro screen, cutscenes, option screens, etc.
Your game needs at least one room to run, and Game Maker will always load the room at the top of the list (which you can re arrange) when you start your game.
By default a new room has a grey background colour and a set size. When you open a room a new window appears with a number of tabs: “Backgrounds, views, settings, objects” etc. On the settings tab you can adjust the size of your room. If you’re not using views (see a later tutorial for more information views) then your game’s resolution & window size will be determined by the size of the first room the game loads.
You can also set the room speed on this tab. This ‘speed’ is the target frame rate (in frames per second) of your room and determines how fast the game operates. This can be an important value to remember when coding logic. If you create an object that moves 2 pixels per frame, at a room speed of 60, your object will move a total of 120 pixels per second.
The objects tab of the room editor allows you to add objects to your room just by selecting an object and clicking in your room. You can use this to construct your levels and game. No object you create will do anything unless added to a room in your game. (unless you add a new object during your game with an action or through code)
You can also set up fixed or scrolling background elements using the background tab, or place background images in specific locations using the tiles tab.
There are many other kinds of resources you can use in Game Maker: Studio, but now that you understand what sprites, objects, backgrounds and rooms are you know enough to start using other tutorials to begin making your first games!