The project Adventure is a simple text-based adventure game. The game, as given, involves the hero trying to find his way from a deep dark forest to home and his true love. There's very little else the player can do apart from moving from place to place. It's not really very interesting.
This project can be of use beyond the given, rather boring forest adventure though. You can use it as a basis for developing your own adventure game with different, more interesting commands, areas, items, people and so on.Å>
The package adventure
contains classes
to describe the game world.
Here is a quick run-through of the classes in package adventure
:
Adventure
represents adventure games. Each
instance of a class is "one game session".
Player
represents the player character in an
adventure game and details his/her attributes and possessions.
Area
represents various kinds of areas that the
game world consists of.
Item
represents items in the game world.
Action
represents actions that a player character
can take during their turn.
See class documentation for more details.
The diagram below illustrates the main relationships between the concepts
relevant to package adventure
.
Here is a short elaboration of the diagram:
See class documentation for more details.
A map of the game world has been provided for cheaters in
forest_map.gif
.
Probably the best way to get to know the project is to first play the game, and then use the debugger to execute the program line by line. If you want, you can also experiment with the various classes of the program individually in Python interpreter.
Main methods are bundled together with both user interfaces,
Adventure_text_UI
, and Adventure_GUI
.
It's your pick.
adventure.py
. This is not good programming
style - a much better solution for a serious piece of
software would be to read the area data (and other game
data) from files. That way, many aspects of the game could
be modified easily even without touching the source code,
and the same source code could perhaps be used to play
different games. Bear that in mind, but this more
straightforward solution will nevertheless suffice for
our introductory course.
This project is inspired by classic games by Infocom and draws on work by M. Kölling and D. J. Barnes.