). I'm working on a Flash game and I need to find when a shooting line intersects an enemy. The enemy's shape is rectangular. So far, I was thinking to test this like so:
- Test if the shooting line intersects ANY of the lines composing the rectangle. BUT while the shooting line can be endless, I need to only validate an intersection if the shooting line ACTUALLY TOUCHES THE INSIDE of any of the rectangle's lines, meaning that the X/Y of the intersection point has to be along one of those lines.
I'm wondering if there is an easier method. Like, for example, the one they used here for a Triangle:
Is this applicable to a Rectangle as well? If so, could you please explain a bit of the reasoning? ::- ). It's been a long time since I did any math, but I'm faithfully coming back to it now, because I want to continue developing games. Any help is greatly appreciated and will not be forgotten ::- D.
P.S.: Also, my games are freeware! ::- )