Ok, so I got inspired by the Google Doodle Halloween game and decided to play around with my own version names Albus Academy of the Arcane. I went with a spell casting theme as well, although I believe the game play mechanic can be transferred to other genres.
The challenging part of the project is to come up with a good way to distinguish between different gestures such as horizontal/vertical/diagonal line, lightning symbol, circle, heart etc Some gestures such as swipe left/right and up/down are fairly easy to detect. The same with a diagonal gesture. The problem is when you introduce more complex symbols.
What I ended up with was to define, per symbol, a Lua table containing sample points (x and y) from a perfectly drawn symbol. The points are normalised in the range of 0.0 to 1.0 (0,0 is bottom left). I then proceed to record all the points from a pressed to a released event, normalise these points and for each sample point in the perfectly drawn symbols check the similarity with the recorded points. The symbol with the highest similarity to what is drawn on screen is then obviously the symbol that is used when the main character casts a spell.
Here’s the sample points for a vertical and diagonal symbol:
-- vertical, top to bottom
{
{ x = 0.5, y = 1.0 },
{ x = 0.5, y = 0.9 },
{ x = 0.5, y = 0.8 },
{ x = 0.5, y = 0.7 },
{ x = 0.5, y = 0.6 },
{ x = 0.5, y = 0.5 },
{ x = 0.5, y = 0.4 },
{ x = 0.5, y = 0.3 },
{ x = 0.5, y = 0.2 },
{ x = 0.5, y = 0.1 },
{ x = 0.5, y = 0.0 },
}
-- diagonal, top right to bottom left
{
{ x = 1.0, y = 1.0 },
{ x = 0.9, y = 0.9 },
{ x = 0.8, y = 0.8 },
{ x = 0.7, y = 0.7 },
{ x = 0.6, y = 0.6 },
{ x = 0.5, y = 0.5 },
{ x = 0.4, y = 0.4 },
{ x = 0.3, y = 0.3 },
{ x = 0.2, y = 0.2 },
{ x = 0.1, y = 0.1 },
{ x = 0.0, y = 0.0 },
}
You can try my proof-of-concept version here: https://britzl.github.io/AlbusAcademy/
The game obviously needs proper graphics and some new mechanic that makes it something more than a clone of the Google Doodle. Let’s see if I can make it happen… (I tend to lose interest way too fast)