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)


GameMaker: Studio is a game development engine that is easy to learn, yet robust enough to use to create commercial games. Budding developers can use the drag and drop approach to coding or the built-in programming language, Game Maker Language (GML), which will be featured in this book.

What this book covers

Chapter 1, Introduction to GameMaker: Studio, introduces you to the GameMaker interface and the basic concepts related to getting started with GameMaker.

Chapter 2, Your First Game – Escape the Dungeon, gets you oriented with GameMaker and uses the drag and drop approach to create your first game, a maze/adventure game.

Chapter 3, Introducing the GameMaker Language, introduces the GameMaker Language conceptually and then goes through a step-by-step recreation of the Escape the Dungeon game written entirely with code.

Chapter 4, Fun with Infinity and Gravity – An Endless Platformer, guides you through the creation of an endless platform game. Through the process, you will work with gravity, speed, random spawning, and further explore collision events.

Chapter 5, Saving and Loading Data, expands the functionality of your game by programming GameMaker to save and load data. The chapter will cover saving and loading high score data as well as a custom player keyboard binding configuration.

Chapter 6, A Multiplayer Sidescrolling Platformer, expands upon the platform game by adding multiplayer, animation, and Xbox Controller support. You will learn about client/server networking to drastically expand upon the possibilities of what can be accomplished with GameMaker.

Chapter 7, Programming a Scrolling Shooter, covers scrolling shooters, such as Xevious, which represent a classic genre in gaming. This chapter will guide you through the process of coding your own shooter, including a scrolling background and random obstacles to avoid and enemies to shoot down!

Chapter 8, Introducing the GameMaker: Studio Physics Engine, introduces the built-in GameMaker physics engine, which allows you to create physics-based games. In this chapter, you will program two small game environments based on the physics engine.

Chapter 9, Wrapping Up, addresses error checking and debugging. You will learn about the built-in GameMaker debugging features and strategies to troubleshoot your code and fix errors.

What you need for this book

For this book, the system requirements are as follows:

  • Windows XP or above (GameMaker: Studio requires a Windows-based computer)

  • 512 MB RAM

  • 128 MB graphics

  • Screen resolution of 1024x600

  • Internet connection for some features

  • GameMaker: Studio Standard (free) version:

Who this book is for

If you have some basic programming experience of JavaScript or any other C-like languages, then this book will be great for you. No experience beyond that is assumed. If you have no game development experience and are looking for a hobby, are an experienced game developer looking to master some advanced features, or fit anywhere in that spectrum, then you will find GameMaker: Studio and this book to be very useful in helping you create exciting games.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Play around with some of the other actions on your obj_square to make it do more rather than be displayed and print text."

A block of code is set as follows:

if (keyboard_check_pressed(vk_up) && !binding) {
       if (choice <= 0) choice = 2;
       else --choice;

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "At the bottom of the resource tree are the Game Information and Global Game Settings options."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.