Let’s Make: Traffic Department 2192 – Part 15

Prototyping with GameMaker Studio

It's time to shift gears from asset extraction to prototype developing. This part is only meant as a primer for the majority of people who don't have experience with a game engine like GameMaker Studio. To reiterate, we're using this game engine so we can put this project together in a reasonable amount of time. By accepting the GameMaker framework, we can outsource some of the more tedious tasks behind the scenes of a game.

GameMaker Benefits

Commercial engines abstract away many tasks, and we're not even going to scratch the surface of what GameMaker can do. We will take advantage of four important ideas: resource management, the game loop, a rendering engine, and a generic object model. Check out the online documentation.

Resource Management

GameMaker provides steamlined resource management. We can easily drag in graphics or sounds of various formats in to the resource tree and the engine stores them in the most efficient format. On the programming side, we have steamlined handles to access resources from any method. Thanks to the resource manager, we can go from an empty project to drawing sprites and playing sounds in seconds.

Game Loop

GameMaker owns the game loop but still provides quite a few fixed event anchors for our object interactions. In a nutshell, every object in GameMaker executes user specified code as a sequence of event callbacks dispatched by the engine in a predefined order. The engine also executes physics and screen rendering operations on objects at fixed times. I'm not a GameMaker expert, but my interpretation of the event sequence looks like this:

GameMaker's game loop simplified

Rendering Engine

If you've ever managed and manipulated graphics assets in SDL/SFML/Allegro or are old enough to have dealt with VGA sequencers, you'll appreciate the ease of GameMaker's drawing functions. Yes, you can draw sprites and text with a single command (thanks again to our resource manager). The rendering engine is one part of the magic spell that brings Traffic Department to life in a few short hours. The rendering engine provides useful tools such as multiple views, direct access to the screen buffer, drawing layers, and other modern tools like shaders with GLSL support ready to go.

Generic Object Model

GameMaker provides a basic 'object' that allows users to refine the purpose to whatever the need is. We tie objects in to event hooks to handle arbitrary code. The engine itself handles the memory (de)allocation, physics updates, and garbage collection of objects. Note that these objects are more procedural entities rather than class objects with methods that you might be used to in C++. It's easy to emulate traditional object behavior thanks to the dynamically scoped 'scripts' and user defined events built in to the engine. Almost all of our work will center around GameMaker's objects and handling instances of the objects in the game world.

Loading Assets

The one task we will do in this video is add a few assets to the resource manager that we'll be using in the next part:

Asset Type Notes
SCR Files Highlight all the bitmaps that we converted in to SCRs and drag them in to the GameMaker resource manager tree under Sprites. Choose the import as sprites.
Sound and Music Drag the sound assets in to the Sounds folder in the GameMaker resource tree. Since the assets are older, we can get away with marking them as 16-bit mono with 24k sampling without much loss of quality.