Hardware Reference
In-Depth Information
DIGGING INTO THE CODE
The drawCircle() function uses the mid-point circle algorithm to create the
circle with blocks. This is an adaptation of the Bresenham line algorithm. You
can find out more about this at http://en.wikipedia.org/wiki/Midpoint_circle_
algorithm.
Drawing Spheres
he drawSphere() function is similar to drawCircle() in that you work with a
centre point, a radius and a block type. You can create a sphere by using the function:
drawSphere(x, y, z, radius, blockType, blockData)
To create the sphere shown in FigureĀ 7-4, add the following code to the bottom of the
LinesCirclesAndSpheres.py program:
1. Find the current position of the player by typing:
pos = mc.player.getTilePos()
2. To draw a sphere starting 20 blocks above the player, with a radius of 15 blocks, type:
mcdrawing.drawSphere(pos.x, pos.y + 20, pos.z, 15,
block.WOOL.id, 5)
3. Save the file and run the program.
FIGURE.7-4 drawSphere creates a sphere using a radius around a centre position (x,y,z)
 
 
Search WWH ::




Custom Search