Hardware Reference
In-Depth Information
DIGGING INTO THE CODE
The points of the polygon's face are created using
minecraft.Vec3(x, y,
z)
. The
minecraft.Vec3()
is the Minecraft API's way of holding a set of
coordinates (x, y, z) together. Vec3 is short for 3D vector.
The points of the face are added to the points list using
append()
; this adds a
new item to the end of a list.
CHALLENGE
What other shapes can you make using
drawFace()
? How about a five-sided
shape such as a pentagon?
Pyramids
Find a picture of a pyramid and take a good look at it. What do you notice? What shape
are its sides? What do all the sides have in common? How many sides does it have?
As you probably know, each side of a pyramid (except the base) is always a triangle. The
pyramids in Egypt had four sides (or five if you include the base), but they can have any
number of sides from three upward. Did you also notice that the base of any pyramid
will fit exactly into a circle! Take a look at FigureĀ 7-9 to see what I mean.
You are now going to create a program, which by using the
drawFace()
and
find-
PointOnCircle()
functions, will make any size of pyramid, of any height, with any
number of sides:
1.
First, open IDLE and create a new file. Save the file as
MinecraftPyramids.
py
in the
MyAdventures
folder.
2.
Import the
minecraft
,
block
,
minecraftstuff
and
math
modules by typ-
ing:
import mcpi.minecraft as minecraft
import mcpi.block as block
import mcpi.minecraftstuff as minecraftstuff
import math