Hardware Reference
In-Depth Information
In Python, indentation is even more important than in other programming lan-
guages, because the amount of indent (the indent level) tells the Python lan-
guage exactly which statements belong to loops. If you get the indentation
wrong, the whole meaning of the program changes.
Indentation is the space at the left hand edge of each line of a program. Indents
are used to show the structure of the program and to group together program
statements under loops and other statements. In Python, the indents are
important as they also change the meaning of the program.
It is important that you get the indentation right. Python can work with both
spaces and tabs when you indent code but if you mix tabs and spaces inside
the same program, Python can easily get confused about what you mean, so
it is best always to use a consistent method for indenting your programs. Most
people like to press the Tab key for each level of indent, as it is quicker than typing
in lots of spaces, but if you start using Tab you should always use it and not mix
it with spaces.
Now that your program is running in an infinite game loop, it will never stop!
Before you run your next program, stop this program from running by choosing
Shell Restart Shell, from the Python Shell menu, or pressing CTRL+C on the
keyboard.
Building the.Welcome
Home.Game
It's time for you to put your game loop into practice and develop a simple application.
The Welcome Home game will use sensing (tracking your player's position) to follow
your player as he moves around the Minecraft world. You will also learn how to do
more complex sensing with the if statement in Python. You will build a magic door-
mat, which will make the message “welcome home” pop up on the Minecraft chat
when you stand on it.
 
Search WWH ::




Custom Search