Warning

You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.

Step 2.4: Planning the program flow

This is a step that programmers, including me, often skip, however a well prepared plan can save a lot of headache later. The following flow chart is trying to explain the key parts of the program.

The chart on the left side is a high-level plan that roughly describes the flow of the program, that we'll call the program loop. This is an endless loop in which the player plays as many games as they please, updating the high score after each game if necessary.

The program loop contains a node in blue that is further explanded in the blue area in the middle. I call this the game loop because it describes a single gameplay. A piece is generated, then it falls from the top of the screen and when it hits the bottom we check if there are full rows that need to be cleared giving bonus added to the score. The loop goes on until the playfield is topped up, that is, the game is over.

This area also contains a node (in yellow), the update loop that is further expanded in the big yellow area at the right side. This is the innermost loop that is responsible for a single piece falling down. It after the piece is generated and it ends when the piece hits the bottom. It describes how the piece moves according to the user input.

On the next page and on, we will start coding the routines.