- Title: RW's Top-Down Movement Example
- Description: This example is intended to provide you with a method of allowing arrow-key events to override each other equally.
- GM Version: :GM8:
- Registered: no
- File Type: .gmk
- File Size: 0.01 MB
- File Link: rw_td_movement_example from Host-A.net
- Required Extensions: N/A
- Required DLLs: N/A
Thank you for your interest in my example!
Please read the Help File included in the example to have a complete understanding of how this movement method works.
The Issue: Did you ever notice how the events for the right arrow key override the left arrow key? This is due to the event order. Just like a stack of 'if statements', where the one on top will always execute first. I have tried many ways to work around this, and so far this is the best alternative I could come up with.
Mechanics: The object has five variables declared within it's create event. Four of the variables are to represent the four directions: up, down, left, and right. The fifth variable represents the direction the object will eventually go.
Each of these variables will increment in value while the corresponding keys are being pressed.
In the 'Key-Press Event' of an arrow key, the values of the other directions gets reset to zero.
In the 'Key-Release Event' of an arrow key, the value of that direction gets reset to zero.
In the Step Event, the variable 'max_value' uses the function 'max()' on all four directional values. Then, a switch statement compares the max_value variable with the four directional values to determine which direction the object will go, using the 'motion_set()' function.
The Results: Each Arrow Key Event has the capability of overriding each other. Thus, allowing the user to button mash arrow keys with more consistent movement.
Object's Information(Incase you do not want to download the example)
Spoiler
GMC Search Tags
GMCTUTORIAL GMCTOPDOWN GMCMOVEMENT











