Hardware Reference
In-Depth Information
hese lines build a shelter that is 10 × 7 blocks in loor space, and 5 blocks high, starting at
coordinate 0, 0, 0. he walls have a thickness of 1 block because you ill the space from 1 to 9
on the x axis, 1 to 6 on the z axis, and 0 to 5 on the vertical axis with air, leaving 1 block of
brick from the original cuboid intact on four sides, and the roof open.
Remember that the # symbol represents a comment that's just there as a reminder for you.
The computer ignores anything on the same line after the # .
Although players can have coordinate positions with decimal portions (such as 1.7), when
you place a block, its position is rounded down to the nearest whole number.
Stopping the Player from Changing the World
I know you wouldn't cheat, but there's no fun in a maze that you might accidentally just hack
your way through, is there? To stop players from being able to destroy or place blocks in the
world, use the following:
mc.setting(“world.immutable”,True)
he word immutable is often used in programming, and just means “unchangeable”.
Setting the Maze Parameters
Now that you know how to place blocks in the world and use the air block to remove them
again, you're ready to start making the maze program. In this program, you'll use a number
of constants to keep track of important information about the maze. Constants are just vari-
ables which you decide not to change the values of as the program is running, so their values
are always the same. It's conventional to use uppercase for the names of constants to signal
your intent to others reading the program, and to remind yourself that you're not supposed
to be letting the program change these values. Replacing numbers in your program with con-
stants makes it easier to customise your program later, but also makes it much easier to read
your program and understand what diferent numbers represent.
Variable names are case sensitive, so Python would think SIZE and size were two different
variables. You'd be mad to use both in the same program, though!
he program starts by setting up these constants:
SIZE = 10
HEIGHT = 2
 
Search WWH ::




Custom Search