Book Image

GameMaker Programming By Example

By : Brian Christian, Steven Isaacs
Book Image

GameMaker Programming By Example

By: Brian Christian, Steven Isaacs

Overview of this book

This book is excellent resource for developers with any level of experience of GameMaker. At the start, we’ll provide an overview of the basic use of GameMaker: Studio, and show you how to set up a basic game where you handle input and collisions in a top-down perspective game. We continue on to showcase its more advanced features via six different example projects. The first example game demonstrates platforming with file I/O, followed by animation, views, and multiplayer networking. The next game illustrates AI and particle systems, while the final one will get you started with the built-in Box2D physics engine. By the end of this book, you have mastered lots of powerful techniques that can be utilized in various 2D games.
Table of Contents (16 chapters)

Chapter 1. Introduction to GameMaker: Studio

In the 15 years of GameMaker experience between us, we have both found it to be one of the best tools for teaching design as well as the introduction to computer science principles. The drag and drop interface lends beautifully to the understanding of computer science concepts related to object-oriented programming including sequencing, loops, conditional statements, variables, among others. Moving from the drag and drop approach to coding in GameMaker Language (GML) is logical and the transition demystifies coding. It is also important to point out the importance of iterative design and debugging that people learning game development with GameMaker will become overly familiar with through the process.

By definition, a game is a special kind of program that is run inside a loop that repeats as long as the user has not decided to close the game program. This loop contains code that creates objects that each have their own loops to control animation, movement, actions, and logic statements based on various aspects of what is occurring in the game. The objects are run until the time they are removed from the program. The main loop also contains logic statements that run code based on different possible user input values. An example of such logic would test if the user has pressed the spacebar, and if so, the game will modify variables of the player object so that it rises, and then falls at a certain point. In order for the player to understand what they have done in their game, the main loop contains code to push graphics to the screen and audio to the speakers, both of which are affected by what different game objects are doing.

There are many different ways to create games. Some people choose to write them in native C++ code without any sort of specialized Integrated Development Environment (IDE). However, GameMaker: Studio is a collection of tools contained in an IDE that make the game creation process much easier, by providing various tools and code functions that are specialized for creating games. For example, there is a visual object editor so that the developer doesn't have to define every single property of objects in code, but rather they can select various boxes that define object properties. Objects control nearly every aspect of a GameMaker game. Rather than using an external spritesheet file containing separate frames of animation, GameMaker contains a sprite editor where each sprite in itself is a special type of object that contains the images. All the developer has to do is to set the sprite of an object to the main sprite, which will then provide access to all of the images inside this sprite. The main game loop is run in rooms, where all of the objects are placed, in turn creating the full game. At compile time, everything produced in the project is converted into C++ code, then compiled, so in the end, the developer has essentially written their game in C++, but by using a much easier method.

We will begin with an overview of the different versions of GameMaker: Studio that are available for download. This will be followed by a guide to the User Interface (UI) of the IDE to orientate you to working in the GameMaker environment. In this simple example, you will learn about creating resources (various kinds of assets) and their purposes, naming conventions, and some drag and drop coding among other skills. The IDE is essentially a collection of integrated editing tools used in a programming environment.

GameMaker: Studio is an application used by newcomers to game design and by experienced developers alike, for both personal and commercial purposes:

  • This contains a very clean interface including a fully functional drag and drop programming interface making it very easy to get started creating games. Experienced GameMaker developers typically choose to create games using the text-based coding functionality of the built-in GML.

  • This also contains many high-level functions and components for a variety of things that developers might need done in their game and for a variety of platforms. Examples include networking, Steamworks™ SDK support, in-app purchases, and more for platforms such as Microsoft Windows™, Apple Mac OS X™, Linux™ in terms of desktop and laptops, and Google Android™, and Apple iOS for mobile. Many more platforms are available for use with GameMaker: Studio.

  • GameMaker: Studio has been used to create many commercial games, a varying selection of which you can view at