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 / a simple challenge

Author
Message
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 7th May 2011 00:32
whats the fastest code you can make that calculates the angle of a line from the center of the screen to the mouse x,y ? (where angle zero is a line straight upwards from center) the winner might get a carrot or similar
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 7th May 2011 02:31
sync on
backdrop on

do

x1=screen width()/2
y1=screen height()/2
dot x1,y1

x2=mousex()
y2=mousey()

angle=atanfull(x1-x2,y1-y2)

set cursor 10,10:print angle
sync
loop

-In.Dev.X: A unique heavy story based shoot'em ~25%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 7th May 2011 05:15 Edited at: 7th May 2011 05:16
I think you'd also have to negate the angle, and add 90 to it, to get the angle difference of something pointing upwards from the center.

(errm, well, you don't have to negate it.)


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.

Login to post a reply

Server time is: 2026-07-11 12:00:48
Your offset time is: 2026-07-11 12:00:48