November 25, 2014  |  By  | 

2 direction the current direction of motion in degrees (0-360; 0 is horizontally to the right) speed the current speed in this direction visible whether the object is visible (1) or invisible (0) solid whether the object is solid (1) or not solid (0) And here are some global variables: score the current value of the score lives the current number of lives mouse_x x-position of the mouse mouse_y y-position of the mouse room_speed current speed of the room (in steps per second) room_caption caption shown in the window title room_width width of the room in pixels room_height height of the room in pixels There are many, many more variables, both local for the instances, and global. All of them can be found in the Game Maker documentation. There are actions which manipulate the value of certain variables but, as we will see, you can also manipulate them directly. What is better, you can define your own variables and use these as well. For example, as we will see below, we want our spaceship to be able to shoot only once every five steps in the game. So our space ship needs a property to indicate whether it can shoot. We use a variable for this property that we call can_shoot . (A variable name can only consist of letters and the underscore symbol. Variable name are case-sensitive, so Can_Shoot is not the same variable as can_shoot .) In the creation event of the spaceship we set this variable to 1 (we always use 1 to indicate true). When the player wants to fire a shot we check the value of the variable to see whether this is allowed. Whenever a shot is fired we set the property to 0 (indicating that shooting is temporarily not allowed). Next we use an alarm event to set the property back to 1 after five steps. Below we will describe this in more detail. In a similar way we can use variables to indicate whether the spaceship has an active shield, whether it has some special weapon upgrade, etc. There are two important actions to deal with variables directly, which can be found in the Control tab: Set the value of a variable With this action you can change the value of a given variable. This can either be one of the built-in variables or your own variable. You specify the name of the variable and the new value. When you check the Relative box the given value is added to the current value of the variable. Please note that this can only be done if the variable already has a value assigned to it! Rather than providing a simple value for the variable you can also give an expression. For example, to double the score you could set the value of the variable score to value 2*score .

More from Patrick