Hardware Reference
In-Depth Information
8. Create the points of the triangle and use drawFace() to create the side of the
pyramid as follows:
trianglePoints = []
trianglePoints.append(
minecraft.Vec3(point1X, pyramidMiddle.y, point1Z))
trianglePoints.append(
minecraft.Vec3(point2X, pyramidMiddle.y, point2Z))
trianglePoints.append(
minecraft.Vec3(pyramidMiddle.x,
pyramidMiddle.y + PYRAMID_HEIGHT,
pyramidMiddle.z))
mcdrawing.drawFace(trianglePoints, True,
block.SANDSTONE.id)
Sandstone ( block.SANDSTONE.id ) is a really useful block type to use for
pyramids as it looks very similar to sand but has a very useful characteristic: it
isn't affected by gravity and doesn't fall down if there are no blocks underneath
it to hold it up. If you were to make the pyramid out of sand, the player would be
buried in it and would have to spend ages digging himself out.
9. Save the file and run the program. You'll see a pyramid appear above the
player—and trap him inside!
This program can create pyramids of any size and with any number of sides. Try
changing the pyramid variables in the program and re-running it. Figure  7-11
shows a couple of impressive examples.
You can download the complete code for the Minecraft pyramid from the
Adventures in Minecraft companion website at www.wiley.com/go/adventuresin-
minecraft.
CHALLENGE
The pyramid you've created doesn't have a base. Can you create a polygon that
fits on the bottom of the pyramid? This should be easy for a four-sided pyramid
but if you code it correctly, the same code should also work for a five-, six- or
seven-sided pyramid.
Search WWH ::




Custom Search