direction
directionmap.GIF
direction

direction is a preset variable. Each instance in the game will have its own direction value.

It indicates the direction the object is facing (although to make its sprite visibly turn to face the direction, you'll need to use image_angle=direction). When you apply speed to the object, it will move in the angle of direction's value.

direction's values

See the picture at the top right for a small diagram of direction's angles. As shown, a value of 0 will point right, 90 will point up, 180 will point left, 270 will point down, and 360 is the same as 0, since a full rotation is 360°. This means that adding or subtracting 360 from direction will have no effect on the player's direction.

Adding to direction will rotate the object's direction anti-clockwise, subtracting from it will rotate the object clockwise.

Related Tutorials

Making an Object Face The Way It's Moving
Reducing Memory Usage While Using "direction"

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License