Hardware Reference
In-Depth Information
A Python list is a versatile type of variable, because it can be used to store any
type of item. It is not the only variable type in Python that can store multiple
items. At this stage, the most important point for you to note about a list is that
you don't need to know in advance how big the list is before you run the program.
The list will grow and shrink automatically as you append() items to it and
pop () items off the end.
When you pop an item from a list, you remove the last item from that list.
Building Vanishing Bridges
with.a.Python List
You are now going to use your new knowledge about lists to write a bridge builder pro-
gram, where the bridge will vanish once your player's feet are safely on the ground
again. This program is similar to the magicBridge.py program, so you could save
that as a new name and edit it, but the full program is shown here to make it easier to
explain each of the steps. Use copy and paste from your magicBridge.py program if
you want to save a little bit of typing.
To see a tutorial on how to build and play the vanishing bridge game, visit the
companion website at www.wiley.com/go/adventuresinminecraft and choose the
Adventure 4 video.
1. Create a new file by clicking File New File, and save it as vanishing
Bridge.py by choosing File Save As from the editor menu.
2. Import the necessary modules:
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
3. Connect to the Minecraft game:
mc = minecraft.Minecraft.create()
 
 
Search WWH ::




Custom Search