Main loop
The main loop will typically contain a finite state machine (FSM). An FSM is defined by a series of states and the list of transitions from one state to another. The FSM for a simple game where the player would have to click three boxes that appear one after the other would look like the following diagram:
When you implement an FSM, you really need to consider two things: how the game should behave in each state, and what conditions make the game transition to a new state. The advantage of FSMs is that they provide a formal way to organize your game logic. It will make it easier to read your code and you can add/or change your logic at a later time if you need it. I would recommend you to first draw the FSM for your game and keep it somewhere to help you debug your game.
For our Frogger game there are 10 states. The initial state is START
and the two final states are GAMEOVER
and WON
. Here is a description of what happens exactly in each state:
All states: The packets and bugs move...