Last active
November 30, 2020 14:52
-
-
Save MarianoGnu/8939df3a9229c0fb37d7 to your computer and use it in GitHub Desktop.
Movement pseudocode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function update_movement(delta_time) | |
| if (left_key_is_pressed) | |
| speed_x = -SPEED | |
| if (speed_y == 0) | |
| facing = left | |
| else if (right_key_is_pressed) | |
| speed_x = SPEED | |
| if (speed_y == 0) | |
| facing = right | |
| else | |
| speed_x = 0 | |
| if (up_key_is_pressed) | |
| speed_y = SPEED | |
| if (speed_x == 0) | |
| facing = up | |
| else if (down_key_is_pressed) | |
| speed_y = -SPEED | |
| if (speed_x == 0) | |
| facing = down | |
| else | |
| speed_y = 0 | |
| position_x = position_x + speed_x * delta_time; | |
| position_y = position_y + speed_y * delta_time; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! Nice code my brother.