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)

The GameMaker: Studio interface


Now that you've completely installed GameMaker: Studio, let's begin learning some of the basics of GameMaker: Studio. Create a new game project by selecting the New tab at the top (after launching it), and choosing your project directory, as well as a name for this, we recommend testGame or something similar. Once your project is created, you should see a window, the GameMaker: Studio IDE, that looks quite similar to the one shown in the following screenshot:

The left-hand side of the IDE consists of your resources, which is where all your sounds, sprites, rooms, scripts, and other resources can be found. Clicking on it simply selects them, and double-clicking will uncollapse folders and open up the properties of resources. Right-clicking on any of those folders will open a menu allowing you to create a new instance of the resource type. For example, right-clicking on the Sprites folder would give you the option to create a new sprite that you can edit and use in your game. If you right-click on Scripts, you can create a new script. Right-clicking on any of those folders also allows the creation of a new group, which is a subfolder strictly for organizational purposes. If a resource or group is right-clicked on, many more options will be available, such as renaming, editing properties, and so on. At the bottom of the resource tree are the Game Information and Global Game Settings options. The former is like a small notepad that you as the developer can write small notes or reminders for yourself in, but it is not packaged with the game.

The latter, the Global Game Settings option, will allow the editing of many properties of the game. When working with the Professional Edition or additional modules it contains, many additional settings that can be edited for specific targets and SDKs.

Along the top are various buttons, some of which are for creating resources (an alternative to right-clicking the folders on the left of the IDE) and others for game compilation options:

The green arrow is for regular compilation and testing, while the red one plays the game in debug mode with a debugger attached so as to view variables and other properties of the game as it runs to help you locate problems in your game. We'll teach you more about the debugger in Chapter 9, Wrapping Up. The brush is for cleaning the target, which comes in handy when you want to see if a glitch was caused by compilation issues or a fault in your code. The hot keys for these three buttons are F5, F6, and F7, respectively.

Everything from the green Pac-Man to the white rectangle and inclusive, are the buttons for creating resources. The next button is a button to access the Global Game Settings, mentioned previously. You can always hover your mouse over any of the buttons to see what they do.

The drop-down list all the way at the end of the top bar allows you to choose your target (or the OS for which your game should be compiled), which will vary based on what modules you may or may not have purchased. All will show up in the list regardless of what you bought, but Microsoft Windows and GameMaker: Player are the only ones that will actually work if you use the Standard Edition of GameMaker: Studio.

Additional keyboard shortcuts that you will find handy are Ctrl + S for saving, Ctrl + N to create a new project, and Ctrl + O for opening an existing project.

GameMaker: Studio documentation

One of the most important buttons on that bar is the question mark surrounded by a circle. Clicking on it opens the complete GameMaker documentation in a new window. It is a comprehensive reference for everything about the IDE, its functionality, drag and drop coding, GML coding, and all other aspects of GameMaker: Studio. It is very useful, and you will likely reference it often. This documentation can also be accessed athttp://docs.yoyogames.com/. Additionally, when working in your code editor, if you put your cursor on one of GameMaker's built-in functions or variables, and click your middle mouse button, the documentation page for it will open so you can learn more about how to use it.