Home
Products
Community
Manuals
Contact
Login or Signup

Movement

BlitzPlus Forums/BlitzPlus Beginners Area/Movement

coach(Posted 1+ years ago) #1
I am trying to make a game like Asteroids, where you turn your ship and press forward to move. If the ship is facing due right you can add to its X-value and if it is facing down you can add to its Y-value, but what if its facing a weird angle? Wouldn't you have to add some to X and some to Y using a weird formula to get the right amount? Help!


John Galt(Posted 1+ years ago) #2
xadd#=v#*cos(angle)
yadd#=v#*sin(angle)

x#=x#+xadd#
y#=y#+yadd#

v is the size of the the amount you want to add
angle is the angle in degrees anticlockwise from the x-direction you are facing.