Most of the drag and drop actions are just GML functions. If you wanted to do more than one thing with per if state you would just put more functions in between the curly brackets. This will reset b back to 0 after b is 10. Now how do we make it reset back to 0 when it hits 10? With if statements! In the step event you can type: Then in the step event add one to it every step by putting b+=1. You would create the variable in the create event, b=0. For a very basic example lets say you want a variable to count up to 10, then reset back to 0. If statements are how you do anything in GameMaker. When working with Drag and Drop you may have noticed that some of the actions had rounded corners. If I wanted to multiply it by 2 I would do b*=2 and so on.
For example if I wanted to add 5 to my variable b every step I would put b+=5 in the step event. If you want to add, subtract, multiply or divide a variable you can simply add the corresponding sign before the equals sign. There are ways to manipulate strings but it is much more complicated. You really will only need to change variables that are real numbers. Keep in mind that you have to create your variables before you actually use them otherwise you will get errors. Doing this creates the variables and stores them in memory. Doing b=”5″ would set b equal to the string “5”. For example b=5 well make a variable called b equal to the real number 5. The name can be anything as long as it doesn’t conflict with any of GameMaker’s built in keywords. Creating VariablesĬreating a variable in GML is very simple, all you need to do is type a name for it and then set it equal to something. Anything less than 1 is considered false and anything equal or greater is considered true. Keep in mind the true and false keywords are also real numbers. For example 5.786 and 72 are both numbers. Real numbers are numbers don’t go in quotations. For example “hello world” and “5.786” are both strings. Strings are more like words and are always in quotations.
There are only two primary types of variables in GML, strings and real numbers. Unlike some programming languages, in GML you don’t have to worry about variable types as much.
#GAMEMAKER STUDIO 2 LANGUAGE CODE#
This makes it so that when you open an object the code action will be easily accessible. If you only use the code drag and drop action (which is the only one you should use after switching to GML) it is extremely helpful to go into preferences, click the forms tab, and change the default TAB to select to 4. If you are brand new to using GameMaker: Studio you can watch my tutorials here.
#GAMEMAKER STUDIO 2 LANGUAGE HOW TO#
One of the primary benefits of using GML is that it is extremely easy to learn and very straight forward.įor this tutorial I’m assuming that you already know how to use GameMaker’s drag and drop system, know how events work, and know the basics of using GameMaker. All of the games on Coded Games have been made using this language. GML, or Game Maker Language, is the programming language used in GameMaker: Studio.