There are a few ways to o about this…
You say that you’re storing a linked list of points? That seems like a
lot of data, most of which you don’t need… I might try storing a
list of line segments. Split a line segment every time you cross it.
Each line segment data structure should have a pointer to the six other
line segments which share a point with this line segment.
#1####2#
3±—+4
#5####6#
Then when you want to check if there is a rectangle involving a certain
corner (i.e., the point where you just crossed another line) then you
can do a recursive function on that graph for three turns that get you
back to where you started.
Just a first idea… don’t know if it’s good to implement or not.
Good luck,
Ben.On Fri, 2002-10-25 at 12:07, Buck Lemke wrote:
I need help with an algorithm I’m writing in a game. I’m using SDL to write the game, although this algorithm really has nothing to do with SDL, but I thought it would be a shame not to tap into the knowledge on this list.
I’m creating a game that has the character moving around the screen (only horizontally and vertically), creating a line behind them (it’s a clone of the touch screen game you see at taverns, with the eyes). My problem is determining when the player draws a rectangle. Right now I have a linked list of all the points that the player has passed over (I’m not even sure if that’s the best way to do this).
I was thinking that when the player insersected a previously drawn line, I could check a point on both sides of the “T” to see if it is in a rectangle. However, I have no idea how to do this.
Is there a tutorial/discussion anywhere on this sort of thing?
Any other ideas on how to accomplish this?
Should I post this problem somewhere else?
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
–
…
: Benjamin Keil : If she’s a liar, I’m her lover :
: Graduate Student in : If she’s a priestess, I’m her cover :
: Linguistics and as : If she’s a lady, I’m her man :
: Poor as that sounds : If she’s a man, I’ll do what I can! :
:…:… Alphaville, from Jet Set Society …: