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.

Dark GDK / Sprites and the cursor

Author
Message
Louis Sequin
14
Years of Service
User Offline
Joined: 10th May 2010
Location:
Posted: 10th May 2010 22:04
What is the best way of telling if the cursor is within a sprite no matter how the sprite has been stretched or scaled and no matter the screen resolution set?
haliop
User Banned
Posted: 11th May 2010 00:15
there are a few ways to do that.
the simpliest way is to :


i hope this helps.
Louis Sequin
14
Years of Service
User Offline
Joined: 10th May 2010
Location:
Posted: 11th May 2010 04:38
That almost seems too easy, but now that I look at it, it makes perfect sense.
haliop
User Banned
Posted: 11th May 2010 12:00
there is just one thing that you need to be aware of
if you rotate the sprite then this dose not apply anymore.

since then the X and Y of the sprite are going not the same as before.
there is Static-Geometry that you can use and its fast and good but takes some time to understand it, it actually does the same thing but also keeping the angle of the X and Y. so check it as i dont have the math for it , search for it on Wikipedia or something or Other Programmers or Game programmers sites.
Louis Sequin
14
Years of Service
User Offline
Joined: 10th May 2010
Location:
Posted: 11th May 2010 17:08
No, no rotation, no offset. None of that crazy, silly stuff.

Your algorithm works well for what I wanted to do. Thank you much.
bloodmage2
15
Years of Service
User Offline
Joined: 14th Jun 2009
Location:
Posted: 14th Jun 2010 18:59
if you want rotation, you can use the following, its not code, but you can turn it into code simply.

find the center of the sprite, and using find the x and y distance between this point and the mouse. use dbTANFULL(x distance, y distance) to get an angle, mulitply the x distance by dbCOS(angle), and the y distance by dbSIN(angle). this creates a point where the mouse would be if either the mouse was rotated along with the sprite. you then find the slope of the box of the sprite (i hope you know how to get slope). using these, you can check if the mouse would be inside the rotated box. if this doesnt make sense, tell me, and ill give you a more in-depth explanation.

-to the optimist, the glass is half full. to the pessimist, it is half empty, to the engineer, it is twice as big as it needs to be.
http://www.lionsbloodstudios.justinman.net/index.htm
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 14th Jun 2010 19:27
Ok, everything seems correct, but
shouldn't this line:



be this:



The same for the y coordinate.
Please correct me if I'm wrong.

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.

Login to post a reply

Server time is: 2024-11-19 23:02:38
Your offset time is: 2024-11-19 23:02:38