-
Book Overview & Buying
-
Table Of Contents
Python Projects for Kids
By :
So, you may remember using the while loop back in Chapters 4, Making Decisions: Python Control Flows, and Chapter 5, Loops and Logic. We will be using the while loop again to set up the game loop. There is quite a lot happening in the game loop (the while loop), so let's take a look at it step by step. First, look at this screenshot of all of the code inside the game loop:

The first thing that you see is the comment telling anybody who reads the code what the code is doing. Comments are not required, but sometimes they can be helpful when you are writing a program. This comment simply tells us that the next section is the game loop.
The game loop starts with the game_on variable. The game_on variable is set to equal True (remember, True is a Boolean). The next line says while game_on:; this means that since the while loop is True, keep running the while loop until something happens to make it False (untrue). Since while game_on: is True, the game will keep running...
Change the font size
Change margin width
Change background colour