Hardware Reference
In-Depth Information
The rest of the code in the theHoles function will be indented under this
while loop.
FIGURE.9-10 Create the position and width of the holes.
5. Create random positions for the holes by using the random.randint() func-
tion to create x and z coordinates, (the y position is the position of the arena)
and append them to a Python list:
holes = []
for count in range(0,HOLES):
x = random.randint(arenaPos.x,
arenaPos.x + ARENAX)
z = random.randint(arenaPos.z + holesZPos,
arenaPos.z + holesZPos + HOLESWIDTH)
holes.append(minecraft.Vec3(x, arenaPos.y, z))
6. Loop through all the positions in the holes list and turn the blocks to BLACK
WOOL :
for hole in holes:
mc.setBlock(hole.x, hole.y, hole.z,
block.WOOL.id, 15)
time.sleep(0.25)
By turning the holes in the arena floor black, you give the player a warning that
a new hole is about to appear and they have the chance to get out of the way.
Search WWH ::




Custom Search