Hardware Reference
In-Depth Information
8. This is now the end of the safeFeet() function. Leave a blank line to remind
yourself that it is the end of the function, and start the while of the game loop
without any indent. As in your earlier programs, you put a short delay and,
finally, use the new safeFeet() function which will do all the work.
while True:
time.sleep(0.5)
safeFeet()
Now click File Save to save your program, and then run it by clicking Run Run
Module from the editor menu.
What happens as your player moves around the Minecraft world? You should see the
words “safe” or “not safe” appear on the Minecraft chat as appropriate, as shown in
Figure 4-1. Try flying in the air and swimming in the sea to see what happens.
FIGURE.4-1 The safeFeet program shows you are not safe while you are in the sky.
In your safeFeet.py program, just like other programs, you used a short time
delay in your main game loop. This is not always necessary, and later you will
work on programs that are slowed down so much by the time delay that they
don't work properly. When posting messages to the Minecraft chat, however, it is
actually useful to slow things down a bit; otherwise the chat fills up very quickly.
Try shortening the delay or removing it altogether to see what happens.
Search WWH ::




Custom Search