Movement
hit "play"
investigate:
other movement blocks:
hit "play"
investigate:
other built-in variables that can be used for movement, such as:
- x = The object's x position in the room, 0 being far left
- y = The object's y position in the room, 0 being very top (so 0,0 is top left)
- hspeed = The object's horizontal component of the speed
- vspeed = The object's vertical component of the speed
- direction = The object's current direction (0-360, counter-clockwise, 0 = to the right)
- speed = The object's current speed (pixels per step, positive or negative)
- gravity = The current amount of gravity applied to the object (pixels per step)
- ystart = The object's starting y-position in the room
- xstart = The object's starting x-position in the room
- xprevious = The object's previous x-position
- yprevious = The object's previous y-position
- friction = The object's current friction (pixels per step)
- gravity_direction = The direction of gravity applied to the object (270 is downwards)
functions:
Functions can performs actions, with or without returning a value. Parts of a function include:
- Function Name (e.g. motion_add)
- Parenthesis (i.e. the "curly brackets")
- Arguments or parameters separated by commas (sometimes there will be no arguments or parameters)
in the above example, the following GML function would've performed the same job:
motion_set(0,3)