In this game, I want to check whenever a closed shape is drawn whenever a line intersects another line, so I made 2 test systems for it.
test 1:
- This system relies on an array of points. Whenever a point is next to another point, they’ll connect to each other
- A line is defined when a lot of points are connected together in a sequence
- Since this system relies on looping through every point to check if points are adjacent to each other instead of using the built-in collision system, it ended up being very resource intensive. It was also annoying to deal with since it was basically just one very big list of points.
test 2:
- In this system, every stroke drawn is its own object. The system will track each individual stroke and every intersection.
- intersections are calculated by Godot’s collision system. Whenever the mouse collides with another line, a new intersection is instantiated.
- Whenever an intersection is made, the system will check if that intersection is part of a complete shape. This is done by checking which strokes the intersection is attached to, and then checking with other intersections those strokes are attached to, repeating until the system finds the sequence looping back in on itself to form a closed shape.
Next steps:
- tracking down the sequence of points in a closed shape to draw its polygon!
- actually implementing this system into the game lol