Game Development Reference
In-Depth Information
1 - Installing Python
The Featured Programs
Most chapters begin with a sample run of the featured program. This sample run shows
you what the program's output looks like, with what the user types in shown as bold print.
This will give you an idea of what the complete game will look like when you have entered
the code and run it.
Some chapters also show the complete source code of the game, but remember: you don't
have to enter every line of code right now. Instead, you can read the chapter first to
understand what each line of code does and then try entering it later.
You can also download the source code file from this topic's website. Go to the URL
http://inventwithpython.com/source and follow the instructions to download the source
code file.
Line Numbers and Spaces
When entering the source code yourself, do not type the line numbers that appear at the
beginning of each line. For example, if you see this in the topic:
9. number = random.randint(1, 20)
You do not need to type the "9." on the left side, or the space that immediately follows it.
Just type it like this:
number = random.randint(1, 20)
Those numbers are only used so that this topic can refer to specific lines in the code.
They are not a part of the actual program.
Aside from the line numbers, be sure to enter the code exactly as it appears. Notice that
some of the lines don't begin at the leftmost edge of the page, but are indented by four or
eight spaces. Be sure to put in the correct number of spaces at the start of each line. (Since
each character in IDLE is the same width, you can count the number of spaces by counting
the number of characters above or below the line you're looking at.)
For example, you can see that the second line is indented by four spaces because the four
characters (" whil ") on the line above are over the indented space. The third line is
indented by another four spaces (the four characters, " if n " are above the third line's
indented space):
Search WWH ::




Custom Search