Hardware Reference
In-Depth Information
Your game is going to have three levels, and you are going to make each level more dif-
ficult than the last by adding more diamonds and shortening the time limit.
Starting the.Game
In this section you will set up the game, and create constants that establish how many
diamonds and the amount of time available in each level.
The program has two main loops:
he game loop:  This loop will continue until the game is over ( while not
gameOver ). This is where each level is set up and started. Points are calculated at
the end of each level.
he level loop:  his loop will continue until the end of each level—so, either
when the level is complete or the game is over ( while not gameOver and
not levelComplete ). This loop also returns a player to the start if he falls
into the river or a hole, clears diamonds if the player hits them, and checks to see
if the time has run out.
The instructions for this part of the adventure refer to indenting code under either
the game loop or the level loop. It is important that you put the code in the
right place; otherwise the game won't work properly.
First, create the structure of the game and create the two main loops by following
these steps to add the necessary code to the bottom of the program:
1. Create three constants for the number of levels in the game, the number of dia-
monds that will be created and the amount of time (in seconds) the player will be
given to complete each level:
LEVELS = 3
DIAMONDS = [3,5,9]
TIMEOUTS = [30,25,20]
he DIAMONDS and TIMEOUTS constants are Python lists. Both have three
items, which are the values for each level; for example, in the first level, the
player will have to collect three diamonds and will have 30 seconds to do it and
get to the other side.
 
 
Search WWH ::




Custom Search