Step 3.3: Coding the loops

If you remember the flow chart from Step 2.4, there we designed the program flow in several loops that are nested into one another.

Here is how the three loops are nested (in pseudo code):

REM program loop
WHILE <true>
  <player presses fire>
  <initialize game variables>
  REM game loop
  REPEAT
    <put new piece at top>
    REM update loop
    REPEAT
      <move piece>
    UNTIL <piece hits bottom>
    <clear rows>
    <update score>
  UNTIL <game over>
  <update hiscore>
ENDWHILE

The actual code will follow the idea of the above pseudo-code.

I suggest we start with the update loop on the next page.