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 / DBP determine which sprite to use

Author
Message
driftman
19
Years of Service
User Offline
Joined: 7th Aug 2005
Location: Somewhere Outside of Sanity
Posted: 12th Jul 2006 02:55
I'm working on a 2D game setup kind of like Diablo 2, but I can't figure out how to determine which sprite should be used when the user clicks on a certain area of the screen e.g. I have a set of images for pointing northwest, so if the user clicks on an area of the screen that is between 30° and 60°(general northwest region), it should set the sprite image to the one pointing northwest. I'm stumped on how to do this, any help would be much appreciated.

I am using the cardinal and intermediate directions for my images.

I have a lil' white jacket that lets me hug myself forever.
The Master
18
Years of Service
User Offline
Joined: 6th Nov 2005
Location:
Posted: 12th Jul 2006 04:27 Edited at: 12th Jul 2006 04:30
you could use the MOUSECLICK ()




No Pain No Gain
DELL 800MHZ 1GB RAM PENTIUM 4 MICROSOFT XP SP2
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 12th Jul 2006 07:06
You could use this function to find the angle between the two points (character and mouse). You might want to change it so that the characterx#=object screen x() and charactery#=object screen y().

I did not take the time to get the exact right angles for displaying the direction (North, south, etc.) but it has the general idea.



driftman
19
Years of Service
User Offline
Joined: 7th Aug 2005
Location: Somewhere Outside of Sanity
Posted: 12th Jul 2006 07:39
thx Daemon, that's precisely what I was looking for, though I probably would've never figured that one out, I need tot brush up on my math a lot.

I have a lil' white jacket that lets me hug myself forever.
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 12th Jul 2006 07:43 Edited at: 12th Jul 2006 20:18
Lol, math. That was all guess and check.


Yes, that and I have used almost the exact same code to help someone else. It was here if you are interested. It uses pretty much the same math to find angle#.

driftman
19
Years of Service
User Offline
Joined: 7th Aug 2005
Location: Somewhere Outside of Sanity
Posted: 12th Jul 2006 11:52
that was a good guess, if I might say so.

I have a lil' white jacket that lets me hug myself forever.

Login to post a reply

Server time is: 2024-09-25 03:34:56
Your offset time is: 2024-09-25 03:34:56