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 Discussion / Having difficulties finding if my mouse is in a triangle.

Author
Message
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 15th Jul 2005 12:51 Edited at: 16th Jul 2005 04:24
This is part of a larger program. Basically what I want to do is detect when my mouse is within the triangular area of three objects. If the mouse is within the area then a triangle should be drawn between the three objects. However, I am having difficulties. Sometimes when I am outside the area the triangle is drawn and sometimes when I am within the area the triangle isn't drawn. I've looked over the code several times and can't find anything wrong with it



Please tell me if you can figure out my problem.
P.S. Everything above the OBJNUM=2 : OBJNUM2=3... is mostly camera movement for you benefit. What I am having trouble with is underneath.

"It's against my programming to impersonate a deity!"~C-3P0
Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 15th Jul 2005 22:11 Edited at: 15th Jul 2005 22:13
I taking a looksee at your program, but I don't understand this piece of code:

they both basicly do the same thing, why?

Don't look at my sig!
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Jul 2005 22:19
because it has to do somthing when the mouse is NOT in that area.

I would compress it a little though...


Immunity and Annihalation makes Immunihalation...
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 16th Jul 2005 01:21
I can't compress it like that. I think you overlooked the "else" statement. This particular sequence of code is only used if two objects make a vertical line on the 2D screen. This would create an infinite slope, thus the reason for the extra sequence. In English it basically means that if the x position of one object in the vertical line (since both of their x's are the same I only need one) is greater than the x position of the third object in the triangle, and if the x position of an object in the line is less than the x position of the mouse then the mouse obviously is not within the bounds of the triangle. The else statement is the same thing only reverse the < and > signs.

"It's against my programming to impersonate a deity!"~C-3P0
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Jul 2005 01:23
Mmmm, ic... nvm then..

Immunity and Annihalation makes Immunihalation...
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 16th Jul 2005 08:47
I think I figured out what at least part of the problem is. My slope# and yint# are always coming out whole numbers. Most of the time they should be very extended decimals. I thought this would have been taken care of with the "#" signs, but I guess not. How can I fix this?

"It's against my programming to impersonate a deity!"~C-3P0
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 17th Jul 2005 02:05
Ok, it's working now. Instead of doing the slope in one step, I now have



"It's against my programming to impersonate a deity!"~C-3P0

Login to post a reply

Server time is: 2025-05-22 19:23:26
Your offset time is: 2025-05-22 19:23:26