GameMaker can evaluate a condition and then enter a code block based on its answer. This is done with if and else.
For example:
if can_shoot == true {
shoot()
}
else {
reload()
}
In the if statement, special operators are used for evaluations. These are == for "is equal to", > for "greater than", >= for "greater than or equal to", and so on.
Multiple conditions can be combined in one conditional through the use of keywords such as and or or. Once the first condition fails, any further and conditions will not be checked.
The negative result can be checked for with the keyword not.
else can be used in conjution with another if conditional, or simply as a catch all at the end. This allows for if-else chains like below:
if foo == 3 {
// Action 1
}
else if foo == 2 {
// Action 2
}
else {
// Catch all
}
== - Equal to
!= - Not equal to
>= - Greater than or equal to
> - Greater than
Will the code on line 3 below run?
var i = 1
if i <= 0 {
i = i + 1
}
What is a = used for?
= is used for assignemnt of values to variables.