Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You can think of it like this:
- You have two variables, var_speed and direction.
- You can represent that movement with trigonometric functions like this:
- hspeed=+var_speed*cos(direction), and
- vspeed=-var_speed*sin(direction) //Minus here because in Game Maker the Y axis is inverted.
- Since sin(a)^2+cos(a)^2=1, the total speed will always be equal to var_speed.
- With that said, if you just want simple 45-degree diagonal movement, you just need to set
- vspeed=+/-var_speed/sqrt(2), and
- hspeed=+/-var_speed/sqrt(2).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement