Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
GameMaker Programming By Example

You're reading from   GameMaker Programming By Example Master the development of 2D games by learning to use the powerful GameMaker Language and tools provided by the GameMaker: Studio workspace and engine!

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781785887963
Length 212 pages
Edition 1st Edition
Arrow right icon
Authors (2):
Arrow left icon
Brian Christian Brian Christian
Author Profile Icon Brian Christian
Brian Christian
Steven Isaacs Steven Isaacs
Author Profile Icon Steven Isaacs
Steven Isaacs
Arrow right icon
View More author details
Toc

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime