Hardware Reference
In-Depth Information
DIGGING INTO THE CODE
The functions that create the obstacles are like mini-programs, and because
they use multi-threading they all run independently. Because of this, if you
wanted to have more than one type of obstacle in the arena, it's really easy to
create a new one. Perhaps you'd like to have two walls? If you call the theWall
function again but give it a different z position to the first wall, a second wall will
appear and go up and down just like the first one:
WALL2Z = 13
thread.start_new_thread(theWall, (arenaPos, WALL2Z))
CHALLENGE
You don't have to stop there. Using the same methods you used to create the
wall, river and holes, can you create a new type of obstacle? Perhaps you can
conjure up a cage that randomly appears and traps the player, or a series of
platforms the player has to jump to reach the end of the arena.
If you find the obstacles too easy or too difficult you can change their difficulty
by setting the constants to different values. For example, you can increase or
decrease the delays to make the obstacles move slower or faster. To speed up
the bridge, change the time.sleep(1) code in the move left and move right
for loops to time.sleep(0.5) .
Part 3—Game Play
The next part of your big adventure is to add game play to your program. Your aim is to
turn the arena from an obstacle course into a game where the player wants to play
again and again, and get to the next level.
To achieve this, the game needs to be exciting and challenging, and include a reward
and a goal.
The challenge will be for the player to collect all the diamonds that are randomly placed
around the arena, while also trying to get through the obstacles in a set time limit.
Points will be given to the player as a reward for collecting diamonds and for getting to
the end of the level. he faster the player completes the level, the more points he will
get. The goal is to complete all the levels and get as many points as possible.
 
Search WWH ::




Custom Search