I want to make a driving game where you can do tricks with your mouse when you hold down LMB. Ex. if you move it up in a straight line really fast (your cursor goes from the bottom to the top of the screen in, say, 0.1s), your bike will do a flip. If you do a quick circular movement, your bike will spin. Essentially, drawing a shape onto the screen = performing a move.
How would this be sensed? Currently, I can only think of having shapes defined by coordinates relative to some starting position (it would be some function taking in your mouse down coords), and within a certain time frame, every update loop will check to see if the current mouse coordinate pair is between the current preset one and the next preset one (and within a margin of error). To know which shape to use, you'd loop through the shape list, see whether or not the mouse coord is invalid for the current shape, and knock it off the possibilities if true.
Example circle path:
- X = Coordinate
- Red arrows = Expected mouse movement path
- Green = Margin of Error

Problems I can see with this algorithm right now:
- If I have a lot of moves, then there are a lot of shapes to loop through every frame before the deduction process kicks in
- It's not an optimal solution for doing consecutive moves in a short timespan, because the player would have to release LMB before pressing it down again for the system to sense that a new shape is starting
- Tiny circles vs big circles, how wide the margin of error would need to be to allow for both, and how that would affect calculations (clashing with other shapes that have similar valid spaces)
- What if you draw circles like flattened, diagonally skewed ovals, even when you're not trying to do it fast? It is indeed a circular motion, but maybe diagonally skewed ovals are for another move. Is it okay to just shun your artistic ability?
- How much time will it take before the system recognizes that you're doing a specific move? Must a full circle be completed before any bike spinning occurs?
What would be a better algorithm?