Hardware Reference
In-Depth Information
wallBlocks = []
for x in range(0, ARENAX + 1):
for y in range(1, ARENAY):
wallBlocks.append(minecraftstuff.ShapeBlock(x,
y,
0,
block.BRICK_BLOCK.id))
5. Create the shape of the wall by passing in the wallPos and wallBlocks vari-
ables that you created in steps 3 and 4:
wallShape = minecraftstuff.MinecraftShape(mc, wallPos,
wallBlocks)
6. Your wall is now finished—but wait, it's still static! To move the wall up and
down, you use the MinecraftShape moveBy() function, putting a small delay
in between:
while not gameOver:
wallShape.moveBy(0,1,0)
time.sleep(1)
wallShape.moveBy(0,-1,0)
time.sleep(1)
The code inside the while loop will run until the variable gameOver is set to
True (or not gameOver ). This will be set to True at the end of the game when
the player either completes the game or loses.
7. he theWall() function is now complete. All that is left for you to do is call
the function in the main program and add the following to the bottom of the
program:
WALLZ = 10
theWall(arenaPos, WALLZ)
he constant WALLZ holds the Z position, which is where you want the wall to be
built in the arena.
8. Run the program. You should see the wall going up and down in the middle of
the arena.
You haven't written the code that will set the gameOver variable to True yet,
so when you run the program it will continue forever! You will need to stop the
program by clicking Shell Restart Shell on the Python Shell.
Search WWH ::




Custom Search