Game Development Reference
In-Depth Information
Topics Covered In This Chapter:
— Data structures.
— The remove() list method.
— The isdigit() string method.
— The sys.exit() function.
The game in this chapter only introduces a couple new helpful methods that come with
Python, the remove() list method and the isdigit() string method. But this is the
first program which will make use of Cartesian coordinates and the mathematical concepts
we learned in chapter 11. This program will also use make use of data structures (which is
really just a fancy way of saying variables that contain lists of lists.) As our games become
more complicated, we will need to store our data in well-organized ways.
Sonar is a technology that ships use to locate objects under the sea. In this chapter's
game, the player places sonar devices at various places in the ocean to locate sunken
treasure chests. The sonar devices (in our game) can tell the player how far away a treasure
chest is from the sonar device, but not in what direction. But by placing multiple sonar
devices down, the player can figure out where exactly the treasure chest is.
There are three chests to collect, but the player has only sixteen sonar devices to use to
find them. Imagine that we could not see the treasure chest in the following picture.
Because each sonar device can only find the distance but not direction, the possible places
the treasure could be is anywhere in a ring around the sonar device (see Figure 13-1).
Search WWH ::




Custom Search