Actions

X and Y
First of all, I will explain the x|X and the y|Y axis. Although most people with an average knowledge in mathematics would easily know what that means, I decided to explain the X and Y axis, for those who do not have an idea about them. The X and Y set the position of the object, and the picture on the right will explain everything to you.

"Applies to..."
Second, I will explain an important part of Game Maker, the "Apply To:" section in the action window. This is where you choose to what object you must apply this action:
 * to the object itself (selected by default)
 * to the other object (only works in a collision event)
 * to a specific object (specified with a drop-down menu)

Start moving in fixed direction [[File:Move_Fixed.png]]
This action will make the object start moving in a particular direction in a certain speed. Click on the direction you want the object to go to, and define the speed. The button in the center makes the object stand still. If you click on two different buttons, the object will randomly choose one position to go to.

Move in any direction [[File:Move_Free.png]]
Very obvious; this action will allow you to alter the direction and speed of the motion of the object without constraints in direction.

Move in the direction of a point [[File:Move_to_Point.png]]
This action will let the object move to the direction of a certain point defined by you. The object will move in a speed defined by the programmer as well.

Set the horizontal speed [[File:Speed_Horizontal.png]]
This action sets the horizontal speed of the object. Setting it to 0 will result no horizontal movement. Setting it to 1+ will result moving to the right. And setting it to -1- will result moving to the left.

Set the vertical speed [[File:Speed_Vertical.png]]
This action sets the vertical speed of the object. Setting it to 0 will result no vertical movement. Setting it to 1+ will result movement towards the bottom. And setting it to -1- will result moving upwards.

Set the gravity [[File:Set_Gravity.png]]
This action sets the gravity power and its direction. The gravity power is how much the object is towards the direction of the gravity. Setting the gravity direction to 0 means its direction is to the right, setting to 90 means that its direction is upwards, setting it to 180 moves it to the left and that means that setting it to 270 will move it downwards.

Reverse horizontal direction [[File:Reverse_Horizontal.png]]
This will reverse the horizontal direction of the object. If the horizontal direction was to the left, it becomes to the right.

Reverse vertical direction [[File:Reverse_Vertical.png]]
This will reverse the vertical direction of the object. If the object direction was upwards, it becomes downwards. Using "Reverse horizontal direction" and "Reverse vertical direction" together will make the object reverse its direction completely, and form a reaction movement.

Set the friction [[File:Set_Friction.png]]
This will set the power of the friction affecting an object in every step (millisecond). Forget all about the math! The friction in Game Maker is very simple, if the friction of an object is ".1" the speed (horizontal and vertical) is reduced by ".1" until the speed reaches 0. Note that if the speed was negative, ".1" will be added to it.

Jump to a given position [[File:Jump_to_Position.png]]
This action will change the position of the object instantly to a new position set by the x and the y.

Jump to the start position [[File:Jump_to_Start.png]]
This action will change the position of the object instantly to its start position. You need to set nothing; the object will automatically move the position where it was first created.

Jump to a random position [[File:Jump_to_Random.png]]
The object will jump to a random direction. But you still have to set the Horizontal Snap and the Vertical Snap.

Snap to a grid [[File:Align_to_Grid.png]]
This will move the object to the nearest grid line. The width and height of the grid is defined by the user. For those of you who do not know what a grid is, a grid is sort of a net, which objects can be aligned to.

Wrap around the screen [[File:Wrap_Screen.png]]
Makes it so that the instance, if it goes outside the room, comes back on the other side. You can set whether it only does it horizontally, vertically, or both.

Move to a contact position [[File:Move_to_Contact.png]]
The help file explain this easily: With this action you can move the instance in a given direction until a contact position with an object is reached. If there already is a collision at the current position the instance is not moved. Otherwise, the instance is placed just before a collision occurs. You can specify the direction but also a maximal distance to move.

Bounce against objects [[File:Bounce.png]]
This will make an object bounce (react) against objects. There are two things you have to set: This action should be put in the collision event.
 * 1) Whether or not the bouncing is precise: If you set Precise to false, the object will react against horizontal or vertical walls properly only. If you set Precise to true, the object will react against all objects properly.
 * 2) Bouncing against solid objects only or all objects?

Create an instance of an object
This action will create a certain object in a certain position defined by the programmer.

Create an instance of an object with a motion
This action will create a certain object in a certain position, but that object will be created with motion. That means you have to set the speed and direction of the newly created object. Direction is 0-360, 0: Right, 90: Up, 180: Left, 270: Down.

Change the instance
This action will turn the object into another object. You need to set the object and whether or not to perform destroy event for the old object and the create event for the new object.

Destroy the instance
This action will destroy the object.

Destroy instances at position
This will destroy all instances (objects) located in a certain position defined by the programmer.

Change the sprite
This will change the object's sprite (or the sprite that represents the object). You must set the sprite, the sub image (-1 for all), and the image speed (1=normal).

Transform the sprite
This action will transform the shape of the sprite. You must change the "xscale" and this is the amount of scaling for the sprite's width. If the "xscale" is 1, the sprite's width will not change its size. Then you must set the "yscale". Then the image angle (rotation). If the image angle was 0, the sprite will not be rotated. Finally, you will be asked to choose the mirror, whether you want the sprite to have no mirroring, mirror horizontal, vertical, or both. Below, there is a table describing the x and y scales.

Set sprite blending
This will set the color/alpha blending of the object's sprite. The blending is what color the object should fade to. White is the normal blending for an object. The image alpha is the transparency of the object. If the alpha was 1 the object will be visible. If the alpha was 0 the object will be invisible. If it was .5 the object will be semitransparent.

Play a sound
This action will either play a sound once, or loop a sound.

Stop a sound
This action will either stop a sound that didn't finish playing, or will stop a looping sound.

Set an alarm
This action sets a particular alarm to certain amount of milliseconds. To learn more about alarm events see the previous documentation.

Sleep for a while
This action will stop the game for a certain number of milliseconds. You must check whether or not to redraw the screen. We recommend setting the redraw to true.

Set a timeline
This action will set a time line. The position is from when the timeline will start. If you select 0, the time line will start from the beginning.

Set timeline position
This action will set the position of a certain timeline. The position of the time line is discussed previously.

Display a message
This action will display a message.

Show the game info
This action will show the game information. The game information is where you write the game help and other remarks.

Show a video
This action will show a video in the game.

Restart the game
This action will restart the game.

End the game
This action will end/quit the game.

Save the game
This action will save all the game changes into a specific file set by the programmer.

Load the game
This action will load all the game changes saved from a previous save from a specific file set by the programmer.

Replace a sprite from a file
This action will change a sprite. The replacement of the sprite will be imported from a file. You must set the sprite to be changed, and the name of the file (.gif/.bmp). And then you must enter the number of images (sub images actually) that the user must replace (1 for a still image).

Replace a sound from a file
This action will replace a sound from file.

Replace a background from a file
This action will replace a background from file.

Call the inherited event
This is a somehow complex action that will be understood later on.

Call a script
This action will execute a script with all its arguments.

Put some comment
This action is no action. It will just put some comments so you can organize your thoughts. A comment in Drag & Drop actions is equivalent to a phrase surrounded by /* and */ or one line of code that has // in the beginning (the text in a // comment must occupy one line only).

Introduction to If Conditions and blocks
Till now, you may think that you can make a professional game, but the truth is its hard to do that now. You need more complex condition checking. So the game will make one thing if an expression is true. These are the If Statements (and sometimes called the If Conditions). If you want to perform one action if an expression is true, you will place the action after the If condition action. You can do that using an “If Statement” in the same way as below:

If Condition – If something is true, a variable equal to a value for example (see below for info about variables). Action – if the statement above is true, this action is performed.

However, if you want to perform many actions if a certain expression is true, it will not be easy to repeat the same If condition multiple times for such a result. Instead you can place the "Start of block" and "End of block" actions. And you can simple make multiple actions:

If Condition Start of block Action Action Action End of block

This way you can make much professional games with Game Maker. However, what will you do if you want the action to perform something if an expression is true, and something else if the expression isn't true? There are two ways, either repeating the same if condition with the "Not" checkbox checked, and this will evaluate the exact opposite of the expression. But the better action to use is the "Else" action, where it actually works like the If Condition but MUST be placed after the If condition is ended. That is either after the end of block of the If Condition, or after the action as indicated in the first example.

If Condition Start of block Action Action Action Action End of block Else Start of block Action Action End of block

If a sound is playing
Is an If condition that checks whether a certain sound is playing or not.

If previous room exists
This action is an If Conditions that checks whether or not the previous room exists.

If next room exists
This action is an If Conditions that checks whether or not the next room exists.

If a position is collision free
An If Condition that checks whether or not a certain position contains any object in it. (It performs the action if the position doesn't contain objects).

If there is a collision at position
An If Condition that checks whether or not a certain position collides with any object. (Perform actions if it does).

If there is an object at position
An If Condition that checks whether or not a certain object is located in a certain position.

If the number of instances is a value
An If Condition that check the number of certain objects in the room. If the number of the instances was equal to the number defined by the user, actions will be performed.

With a chance perform the next action
This action performs an action with a chance of certain sides.

If the user answers yes to a question
This If Condition will display a message asking a "Yes/No" question. If the player chooses yes, the actions for the If Statement will be performed.

If an expression is true
This is an If Condition that checks whether a certain statement is true or not. Learning more about statements is required before using this action properly.

If a mouse button is pressed
If a mouse button is pressed, an action will be performed.

If an instance is aligned with a grid
This will perform an action if a certain instance is aligned (snapped) to grid.

Exit this event
This action will stop the execution of the event.

Repeat next action
This action will repeat the next action a number of times defined by the user. You can use blocks in this action.

Introduction to variables
Variables are values that can change. Like "fast", fast is a variable, fast can be 0, 1, 2, 3, or anything at all. While the number "5" is only 5! A variable name can be anything, but it must not contain: .	!	@	#	$ %	^	&	*		-	=	+	\ <	>	/	?	 {	}	[	], |	`	~	"	' To make it easier, a variable name can only contain letters and numbers and underscores (_). It can begin with letters, and underscores, but it cannot begin with numbers.

Setting a variable is easy, you either use the drag and drop action, that is simple enough or use this form of code: //setting a variable to 1 variable=1; Variables in Game Maker are either "real" or "strings".

Real
Real values for variables are numbers. 1, 2, 3, or 10000 are all real values. When setting the value you simply enter the value.

String
Strings are great types of values to variables. "Hello" can be a string "123 ABC" is a string. A string is any kind of text surrounded by quotations ("s) or ('s). When setting a variable's value to string, you surround the value with quotations marks.

Variables: Global & Local
Variables are even cooler! Suppose you have two objects, one object's variable (happy) is set to 1, the other object's variable happy is set to 0. This way every object has its own happy. But what if you want all objects to have the same value? This way you can use global variables. The first object is the object that initializes everything, it asks the player for yes/no questions and sets variables. For example: If the user answers yes to a question: "Are you happy" Start of a block Set a variable: happy to 1 End of a block Else Start of a block Set a variable: happy to 0 End of a block This way initializing object will recognize the variable "stupid" but other objects wont. This is when you use: global. variables. The (.) located between global and the variable name separates the type of variable from the variable name. If it had no (.) in the first place, it will be considered a local variable. Here is an explanation for global variables:

Global Variables
Global variables are the variables that are not limited on certain objects or rooms. The global variable always exists. If you set global.stupid in room0 by object0, object1 in the same room and object2 in room1 are able to recognize global.stupid.

Local Variables
Local variables are the variables for the same object.

All variables
All variables (all.whatever) set a local variable for all objects in the room.

Set a variable
This will set a certain variable to certain value.

If a variable has a value
If a certain variable has a certain value, the If Condition will be executed.

Draw the value of a variable
This will draw a value of a certain variable in the room (write the value of the variable in the room).

Set the score
This will set the score.

If score has a value
If the score has a certain value, actions will be performed.

Draw the value of the score
This action type is explained before.

Show the high score table
This action will show the high score.

Clear the high score table
This action will clear the high score.

Set the number of lives
This action will set the number of lives to the player.

If lives has a value
An “If statement” that will see if lives have a certain value.

Draw the number of lives
This action will draw the number of lives.

Draw the lives as an image
This action will draw a number of sprites defined by the player next to each other to represent the number of lives.

Set the health
This action will set the health.

If health is a value
This action is an “If Statement” that will check the value of the health.

Draw the health bar
This action will draw a health bar.

Set the window caption info
This action will set the info to be viewed in the caption (title) of a window.

Play a CD
This action will play a CD.

Stop the CD
This action will stop the CD from playing.

Pause the CD
This action will only pause the CD from playing.

Resume the CD
This action will continue playing the CD after it has been paused.

If a CD exists in the drive
If there is a CD in the drive.

If the CD is playing
If the CD is being played.

Extra actions
Set the mouse cursor This action will set the look of the cursor from a sprite. And you will set if you want to view the original cursor too or not.

Open a webpage in a browser
This action will open your default web browser, and open a certain page in it.

Draw a sprite
This action will let the object draw a particular sprite with a particular sub image (-1 draws all animating) in a certain position.

Draw a background image
This action will draw a particular background in a particular position.

Draw a text
This action will draw (write) text in a certain position.

Draw text transformed
This action will draw (write) text in a certain position. But with certain x and y scaling (xscale and yscale discussed before), and a certain rotation (angle) that is also discussed before.

Draw a rectangle
This action will draw a rectangle. Here is what you must insert: x1: The x position where the rectangle will start. y1: The y position where the rectangle will start. x2: The x position where the bottom right part of the rectangle will end. y2: The y position where the bottom right part of the rectangle will end. Filled: If set to true, the rectangle will not be hollow.

Draw a horizontal gradient, Draw a vertical gradient
This action draws a rectangle with nice effects.

Draw an ellipse
Draw an oval with the same arguments as a rectangle.

Draw a gradient ellipse
This action draws an ellipse with nice effects.

Draw a line
This action will draw a line going from x1,y1 to x2,y2.

Draw an arrow
This action will draw an arrow going from x1,y1 to x2,y2, and you must set the size of the tip of the arrow.

Set the color
This action will set the color of the drawing.

Set the font
This will set the font of text drawing to be used and the horizontal aligning for the text.

Change full screen mode
This action will either change to full screen. Or change to normal view. Or toggle between both.

Take a snapshot of the image
This will make a screenshot of the window and save it to a particular file.

Set path for the instance
This will make an object start a path.

End the path for an instance
This will make an object end a path.

Set the position on the path
This will make an object set a position of a path.

Set the speed for the path
This will make an object set the speed of the path.

Perform a step towards a point
This will make an object move towards a point.

Step towards a point avoiding objects
This will make an object move towards a point avoiding objects. Either to avoid all objects, or solid objects.