Game Maker Studio: Global Variables
by Quotingmc in Circuits > Computers
25 Views, 0 Favorites, 0 Comments
Game Maker Studio: Global Variables
This tutorial will teach you all about global variables and how to use them in your game. You will need game maker standard and a basic knowledge of the program.
Global Variables
We can start by making the variable. I will use the example as a score variable but you can replace that with whatever you need. First we declare it and its start value. Do this in a create event for an object in all the rooms it's used in.
Global.score = 0;
I have now set the variable " global.score" to the value 0. I can now access that variable in any room and use it. I could draw it with the statement:
Draw_text(x,y,global.score)
And can add and change it with the functions:
global.score += 1;
global.score = 1;
I can also use it in "if" statements and timelines. There are so many uses and as you become an experienced coder you will need global variables more and more.
Global.score = 0;
I have now set the variable " global.score" to the value 0. I can now access that variable in any room and use it. I could draw it with the statement:
Draw_text(x,y,global.score)
And can add and change it with the functions:
global.score += 1;
global.score = 1;
I can also use it in "if" statements and timelines. There are so many uses and as you become an experienced coder you will need global variables more and more.