Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Gamemaker Essentials
  • Table Of Contents Toc
Gamemaker Essentials

Gamemaker Essentials

3.8 (13)
close
close
Gamemaker Essentials

Gamemaker Essentials

3.8 (13)

Overview of this book

This book is for users experienced with game development who now want to learn how to develop games in GameMaker: Studio in a fast-paced way.
Table of Contents (11 chapters)
close
close

Simple toggles


When debugging a game, it's often useful to be able to enable or disable things with the press of a button. Things such as lasers, turrets, and pausing the game can all be done with just the press of a button and a single line of code.

For this, we will use the not statement, which is also represented by an exclamation mark (!). The not statement is often used in an if statement to check whether something is false instead of true. The way it works is by simply multiplying the returned result by -1, making it negative if the number was positive or positive if the number was negative.

We can use this to create toggles. Here is some example code:

if (keyboard_check_released(vk_space)){
    on= !on;
}

The preceding code checks to see whether the player has released the spacebar key and if so, it will set the on variable to be the opposite of what it was before. This works by setting on to !on. In other words, by multiplying on with -1.

This code will work the exact same way:

if (keyboard_check_released...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Gamemaker Essentials
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon