[SOLVED] Checking for a complete shape from user's drawing

I’m working on a recreation of the turn-based battle system from the first two Paper Mario games, and I’m implementing the attack seen here (2 minutes and 14 seconds in the video if it doesn’t bring you to the correct spot).

My current method involves adding all the points the user drew and rendering them. However, I’m a little stumped on how to check if the “shape” the user draws is complete. Ideas I had in mind were checking if a new point overlaps a previous point, but that would fail if, for instance, the user just kept drawing up and down. Another idea I had was to try and form a shape like a rectangle out of the points, but considering you can draw anywhere and complete the shape anywhere it seems too much like a brute force approach and I feel there may be a better (and more performant) way.

Does anyone have any experience doing something like this? I would like to know a better approach to this problem and any leads to a solution.

If you want to check out the code for it, here’s the link (it’s not much to look through).

The shape in the video looks pretty edgy, looks like they are sampling the current cursor position every few frames and draw lines between the points.

If you follow that approach you just have to check if your new line intersects an old line

1 Like