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.

DarkBASIC Professional Discussion / Rotate a sprite until it is facing another sprite

Author
Message
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 18th Oct 2013 10:54 Edited at: 18th Oct 2013 11:02
Hi!
I am trying to make a code let my sprite rotate since it is facing another sprite.
So I decided to try to obtain the angle between 2 points;
first point = first sprite X-Y
second point = second sprite X-Y

I tried this code:


But I got a not good result and my sprite1 not facing the other sprite...
Please help!

EDIT:
I tried this too:


But I got a negative value.. not a 360°value..
I am loosing my brain..
pcRaider
19
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 18th Oct 2013 11:08 Edited at: 18th Oct 2013 11:10
atanfull() demo

try this.


windowsXp
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 18th Oct 2013 11:26 Edited at: 18th Oct 2013 11:44
mmmmmmm
I tried this piece from your example:



But I got -140 (a damn negative value)
An interesting thing:
If I manually put my sprite at 140° (not negative) I got my sprite is perfectly opposite to the target.. (the right angle would be so and so 325°)
Something wrong math here..

EDIT:
Adding the lines I can notice the direction line point perfectly to my target! but the angle is 219 when it should to be 325 in the standard I am using...

EDIT2:
Okok I think I just need to make the situation a bit more clear using only ONE angle standard. Time to make some code!

Login to post a reply

Server time is: 2026-07-07 21:10:15
Your offset time is: 2026-07-07 21:10:15