Hardware Reference
In-Depth Information
3. Save the program and run it. You should see a simple structure that looks like six
dots on a dice, in front of your player! (See Figure 3-2.)
FIGURE.3-2 The Minecraft dice in front of the player shows six stone dots.
CHALLENGE
Modify the dice.py program so that some of the space around stone dots is
filled in with a white block, so that it looks more like the square face of a dice.
Experiment with setting different blocks to STONE or AIR to create different num-
bers on the dice. Remember that there is a detailed list of blocks in Appendix B.
Using for.Loops
Building with individual blocks allows you to build anything you like, but it's a bit like
drawing a complex picture on a computer screen by hand, one dot at a time. What you
need is some way to repeat blocks, so that you can build bigger structures without
increasing the size of your program.
Building Multiple Blocks
with.a.for.Loop
Fortunately, like any programming language, Python has a feature called a loop. You
encountered loops already in Adventure 2 with the while True: game loop. A loop is
just a way of repeating things multiple times in a programming language like Python.
 
Search WWH ::




Custom Search