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.

Newcomers DBPro Corner / how do I make the 2D sprite face my mouse cursor?

Author
Message
Matt McFarland
20
Years of Service
User Offline
Joined: 28th Nov 2003
Location: Cincinnati, OH. USA
Posted: 28th Nov 2003 23:33
I have a cool idea, I know its been done before, but its lots of fun.

basically my spaceship will face the mouse cursor at all times, so when I click the left mouse button it will shoot at the mouse cursor and if I click the right mouse button it will go forward.

the problem is I cant figure out how to make it face the mouse cursor. I have read the beginners guide book and it doesn't cover this.

of course we can rotate the sprite, but how do you rotate the sprite to face the mouse cursor? I know you would probably need to get the mousex() and the mousey() , but what do you do with those?

Any help would be appreciated.

thanks,
tone
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 29th Nov 2003 01:29
look at the atanfull() command, it returns the angle between two points.

dbpro : p166mmx @ 233 : 256mb : sb 128pci : sis onboard
Matt McFarland
20
Years of Service
User Offline
Joined: 28th Nov 2003
Location: Cincinnati, OH. USA
Posted: 29th Nov 2003 06:04
I'll take a look into it..

thanks!

Login to post a reply

Server time is: 2024-09-21 12:06:32
Your offset time is: 2024-09-21 12:06:32