Hardware Reference
In-Depth Information
been charged. When he runs out of the field he won't be charged rent. Your program
also remembers how much rent you have been charged, so when you run back into the
field again, it doesn't forget how much you already owe.
CHALLENGE
To make this game more fun, your player needs something to do while he's in the
field. Create a few random blocks in different locations inside the field, then start
your program running again. The challenge is to collect all the blocks while paying
as little rent as possible. Just hitting the block to remove it could be considered
collecting the block. The program won't know this has happened but it will make
your game more interesting. You can come up with all sorts of objects to scatter
throughout the field and challenge your friends to collect them, with the winner
being the person who collects all the objects while paying the least rent!
Moving Your Player
There is a way to make your game more challenging and exciting, involving another
feature of the Minecraft API that you'll find useful in your game creations—moving
the player to a different position in the Minecraft world! To do this, you will be
modifying your existing rent.py program so that if the player is in the field for
more than three seconds, he gets catapulted into the sky and out of the field and has
to get back into the field again.
You will first need to find a position just outside the field where you want the
player to land when he has been in the field for too long. he simplest way to do
this might be to look at the biggest of the X and Z coordinates for your field, and
add 2 to each of them to get some new coordinates. For the dramatic effect you
are going to create, choose a Y coordinate that is up in the sky. The actual number
you choose will depend how far up in the Minecraft world you have built your
field, but if your field is built at y = 0 then you could choose a value for y that is
round about 10. This will catapult your player into the sky and gravity will make
them fall to the ground again.
You are now going to modify your rent.py program so that if the player is in
the field for more than three seconds he gets thrown out of the field, using the
following steps:
1. Set three new constants at the top of your program that remember a home
position. This home position will be just outside of the field, and when
your player gets catapulted out of the field they will be moved to these
coordinates. The new lines to add are marked in bold:
X1 = 10
Z1 = 10
 
Search WWH ::




Custom Search