Game Development Reference
In-Depth Information
6 - Dragon Realm
False . Think of it as the program's way of saying, "If this condition is true then execute
the if-block or else execute the else-block."
Remember to put the colon (the : sign) after the else keyword.
The Colon :
You may have noticed that we always place a colon at the end of if , else , while , and
def statements. The colon marks the end of the statement, and tells us that the next line
should be the beginning of a new block.
Where the Program Really Begins
35. playAgain = 'yes'
This is the first line that is not a def statement or inside a def-block. This line is where
our program really begins. The previous def statements merely defined the functions, it
did not run the code inside of the functions. Programs must always define functions before
the function can be called. This is exactly like how variables must be defined with an
assignment statement before the variable can be used in the program.
36. while playAgain == 'yes' or playAgain == 'y':
Here is the beginning of a while loop. We enter the loop if playAgain is equal to
either 'yes' or 'y' . The first time we come to this while statement, we have just
assigned the string value 'yes' to the playAgain variable. That means this condition
will be True .
Calling the Functions in Our Program
38. displayIntro()
Here we call the displayIntro() function. This isn't a Python function, it is our
function that we defined earlier in our program. When this function is called, the program
execution jumps to the first line in the displayIntro() function on line 5. When all the
lines in the function are done, the execution jumps back down to the line after this one.
40. caveNumber = chooseCave()
This line also calls a function that we created. Remember that the chooseCave()
Search WWH ::




Custom Search