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)

Putting in a scoring system


For this chapter, you can just work in your previous game and continue to edit that, so you don't need to make any new game projects. Open your infinite platform game, and we'll start with putting in the score system. We will get into drawing and saving it later.

First, add a Create event to the platform object. Inside it, set a variable called hit to false, and it will tell whether or not the player has bounced on it. The player should only be able to score points from a platform once, so that's why we have to put in this variable. Next, below everything you already have in the Step event for the platform, test for a collision with the player, and also it is required that the variable we set before is false. If so, increment the score variable (a built-in global variable) by 10, and set the hit variable to true, so that the player can't get more than 10 points per platform:

if (collision_line(x + <left edge of bounding box value>, y,
x + <right edge of...