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.

2D All the way! / Mathmatical Road block

Author
Message
Takeshii
22
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 9th Dec 2005 04:39


What i need is to detect the x/y value of a click (i can do this part) but also detect if its iside the circumfrence (spelling?) of a circle.


Ive never delt with this kind of math in programming, and am not exactly sure of myself (tried). I know alot of math (up to trig and still going) but am not sure on how to apply it, in this case. Im sure its really obviouse hehe...

Dark
TDK I Love you...... And yes, you should be scared
Takeshii
22
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 9th Dec 2005 06:19
OMG ...brainfart...too easy got it...thanks anyway

Dark
TDK I Love you...... And yes, you should be scared
D Ogre
22
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 23rd Dec 2005 03:34
If I am understanding you correctly, you want to check the current mouse pointer position to see if it falls within a circle when you click the mouse button.

I don't think you need to apply trig. for the solution to your problem. Why not try replacing the mouse pointer and circle with a sprite version of each, and then check for collision between the two? This would be a simple solution. After all, you don't really want to complicate tasks such as this do you?
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th Dec 2005 22:31
A tip:

If you're using pythagoras' sqrt(diffx^2 + diffy^2), then I suggest you change it to vector math.
It's much faster using
r = make vector2(1)
set vector2 1,mousex() - 320, mousey() - 240
radius = length vector2(1)
(Only for DBP)

Login to post a reply

Server time is: 2026-06-12 23:24:38
Your offset time is: 2026-06-12 23:24:38