This will be a short update due to it being Christmas Eve, so lets get right to it.
Firstly, I fixed a bug in the Pointer entity that I introduced when I started with the menu code. That update allows for rotating the pointer in any direction. Since facing right is a rotation of 0, I modified the polygon to point that way by default. Unfortunately, this breaks the pointer for other orientations.
There was a problem with rendering a 90 degree rotated pointer (as is used in the debug code) because it’s trying to draw from the upper left corner. If you translate to that direction and then rotate the canvas and draw from the corner, the arrow is incorrectly offset. I spent a longer time than I like to admit trying to figure that one out before I realized it. Now the polygon assumes the origin is at the center and the translation puts us there.
With that out of the way I went back to the menu code. The Game Over scene now displays a menu that allows you to retry the game at the level the game was at when you failed, or quit, which takes you back to the title screen.
Our little Menu entity now has the ability to return to you the menu item at any index. With this, the title screen can allow you to change the level by modifying the menu option to include the current level number.
All three scenes have been given a level property; for the title screen, it represents the level that the menu is set to, for the game screen it is the last level attained in the game and for the game over screen it is the level that the game ended at. When swapping between scenes, each scene pulls the level from the previous scene and sets itself up accordingly.
So, when you start the game, the game scene gets the level selected by the user at the title screen. When the game is over, the game over scene pulls the last level from the game scene. If you retry, the game gets the level from the game over screen the way it did from the title screen. If you quit to the title screen the title screen pulls the level from the game over screen and updates its menu to show the level attained (although it does constrain it to level 20).
With that, the menu system s more or less done. It would be trivial to pop an extra menu item in for speed or music when those arrive.
With tomorrow being Christmas, the code update is probably not going to be overly fantastic, but I shall produce something!