Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / formula for converting angle into dx&dy ?

Author
Message
IBOL
Retired Moderator
21
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 31st Mar 2004 11:26
hey guys,

i am looking for some kind of formula to smoothly compute
DX and DY from an ANGLE
(DX is a number -1 to 1 which indicates the amount in the "X" direction a sprite moves. DY is the same for the "Y" direction.
one rule is that ABS(DX)+ABS(DY)=1)

i have dx and dy worked out for 16 divisions of a circle (every 22.5 degrees), but would like a smooth computation.

thanks,
bob
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 31st Mar 2004 12:14
I have a program that can do rotation using atan command, and triangles and trigonometry, so maybe you would like to see it, as it gives proper rotations out.

GIve me more power!
IBOL
Retired Moderator
21
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 31st Mar 2004 15:48
you have a program that "maybe i would like to see" ?
well, where is it? what is the basis of it?
hmm?

thanks to you , i experimented and found a USE for TRIG !
incredible as that may sound, i have found the answer to my
own question:

BDX#(T)=SIN(ANG)*BS
BDY#(T)=0-COS(ANG)*BS

although the condition:
ABS(DX)+ABS(DY)=1
is not always met

thanks,
hope this helps someone else,
programming all night long,
bob
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 31st Mar 2004 16:00
The programs I am talking about are just trig routines. One works out the distance between 2 points, another works out the rotation of a sprite at point A facing pointB, and the 3rd one compiles the 2 routines into a homing missile.

GIve me more power!

Login to post a reply

Server time is: 2025-06-30 07:23:51
Your offset time is: 2025-06-30 07:23:51