Hardware Reference
In-Depth Information
9. Finally, write the main game loop. As in your earlier experiments, you might like
to try different delay times in the game loop to improve the usability of the
bridge builder. Remember that this game loop is part of the main program (the
while True: is not indented at all), so check the indentation very carefully:
while True:
time.sleep(0.25)
buildBridge()
Save your program with File Save and then run it with Run Run Module. Walk your
player around the Minecraft world and then walk him off a ledge or into a lake, then
turn and walk him back onto safe ground again. What happens? Figure 4-4 shows the
bridge starting to vanish once Steve is on safe ground.
FIGURE.4-4 The bridge magically vanishes once your player is safely on the ground.
DIGGING INTO THE CODE
Earlier, when you experimented with lists at the Python Shell, you added text
strings to your list. In the vanishingBridge.py program, there is an extra
little bit of Python magic that is worth explaining.
Python lists can store any type of data, such as text strings, numbers and
even lists. You have used this magic already in your program, perhaps without
realising it.
continued
 
Search WWH ::




Custom Search