Game Development Reference
In-Depth Information
5.
Open room_test and create a a number of long walls and corners using obj_wall .
Finally, place a single instance of obj_explorer somewhere in the maze.
Result: Reference/Result/4_way_movement.gmk
For eight-way movement, you only need to make a few small adjustments to the script:
Changing Four-Way Movement to Eight-Way Movement
1.
Open the Step , Step event and double-click the Execute Code action. Remove the fifth
line of code that says if ( hspeed != 0 ) vspeed = 0 . This will allow the player to
move both horizontally and vertically when they press more than one key.
In the same event, add four extra case statements in the switch statement block for the
directions 45 (right + up), 135 (left + up), 225 (left + down), and 315 (right + down). You
can either use new sprites for these directions or choose any of the available sprites;
we've done the latter in our example.
2.
Result: Reference/Result/8_way_movement.gmk
Grid Movement
Grid movement limits the freedom of the player's movement (and his enemies) to a grid of
(invisible) squares. There can be several reasons to do this—for example, to make sure all
instances are lined up nicely when opening doors, pushing objects, or forming combinations. It's
easier to deal with grid movement if you realize that it conforms to the following rules:
Changing direction is only allowed when a moving object is aligned with a grid
square.
A moving object should not stop moving until it has reached its target square.
The moving objects themselves are not bigger than the size of the grid squares.
We'll take our explorer example and give it grid movement. We'll also deal with an example
of enemy movement. Before you continue, make sure to read the Four-Way and Eight-Way
Movement section, as we will pick it up from there.
 
 
Search WWH ::




Custom Search