Improving controls


The controls problem

Several players have mentioned problems with controls. Sometimes a key press was not registered. Handling of multiple keys pressed at the same time was handled poorly — game would noticed that a key was pressed, and the player would continue to move, even if that key was some completely unrelated one (not one of game control keys).

This was because Quil library doesn't handle long key presses — e.g. even if you hold a right arrow for a long time, you will only move one spot to the right — and I've made some poor workarounds for it.


Initial workarounds

My initial solution (the one that caused the problems mentioned above) for long key presses was to check if arrows or WASD was pressed on a scene update, and then move the player accordingly. Since scene updates happen frequently (depending on the frame rate set), this caused problems with short presses — if a player is not fast enough with key release, they would move multiple tiles instead of just one. To be able to move one tile at the time, I've lowered the frame rate to 12 fps.

To help with short presses, the second workaround was to add a timeout before a press is counted. This allowed for a higher frame rate, while making single-tile moves possible. On the other hand, this caused what some had explained as a jerky movement and/or some keys presses not being registered.


v2 solution

The proper solution, available for v2 of the game (not yet available at itch.io at the time of writing), was to add every key pressed to a set of pressed keys, and on a key release to remove it from that set. On the scene update, all keys still in the set are handled. See the change here.

This solves the problems, both for short and long key presses, and there is no jerkiness nor key presses not being registered.

Get aMAZE

Leave a comment

Log in with itch.io to leave a comment.