Computer Science Department |
CSCI 135 |
In this assignment, you will be making a game in which you wander around a dungeon.
|
13 10 3 10 1 1 W W W W W W W W W W W W W W - W - - - - - - D - - W W - W - W W W - W W - - W W - W - S - S - W W - - W W - - - W W W - W W W O W W W W - W W W D W W - - W W W W - W - - - - D - - W W W W - W - - - - W - - W W - - - W W W W W W - - W W W W W W W W W W W W W W |
|
Code | Description |
W | Wall, appears as , the hero cannot pass through it. |
S | Secret passage, appears as , but the hero CAN walk here. |
- | Passage, appears as , the hero can walk here. |
D | Closed door, appears as a closed (locked) door , the hero must have a key to open it. |
O | Open door, appears as an open (unlocked) door , the hero can walk right through. |
Key | Action |
w | Hero attempts to walk north. |
s | Hero attempts to walk south. |
a | Hero attempts to walk west. |
d | Hero attempts to walk east. |
Class | Description |
Config | Like many games, Dungeon involves numerous image and sound assets. Rather than sprinkle the literal names of these assets throughout your code, you should instead use the provided Config.py class. This class provides methods that can be called to obtain image filenames, sound filenames, and the size of cells in pixels. Config also provides a method that maps user input to a game action, and methods that determine what sounds to play when items (i.e. gems or keys) are collected or used. You should not need to modify this class. |
Action | The Action enumerated type represents the different actions the hero might take in the game. Currently this is just moving to the north, south, east, or west. You should not need to modify this class. |
Item | The Item type represents things the hero can collect in the game. Currently this is just gems and keys. You should not need to modify this class. |
DungeonGame | Main program that runs the game. Responsible for reading in the dungeon control file using standard input. Creates the Dungeon and Hero objects. Sets up the drawing canvas and coordinate size. The game continues forever. You should not need to modify this class. |
Cell | Represent an individual cell location in the dungeon. This is the base class in the inheritance. As such it defines the API that all the other Cell-related data types implement. The Cell type itself is quite basic, it represents an impassable wall with a given background image. You need to complete the missing code in two methods. |
CellPassage | This class is a child of the Cell class. It is a cell that the hero can walk through. Depending on the image it is created with, it could be a normal passage or a secret passage. It can contain either a gem or a key (but not both). You need to add attribute(s) and implement all methods. |
CellDoor | This class is a child of the CellPassage class. It is a cell that the hero can sometimes walk through (if the door is already open or if the hero has a key). A CellDoor may be created either open or closed. If the door is open, it can contain either a gem or a key (but not both). You need to add attribute(s) and implement all methods. |
Hero | Represents the state of the hero in the game. It keeps track of where the hero is, the image used to draw the hero, and how many keys and gems the hero has collected. This class plays sound effects related to collecting or using items. You need to add attribute(s) and implement all methods. |
Dungeon | Stores the grid of cells containing the dungeon. A dungeon also keeps track of the Hero object. This class plays sound effects related to moving or hitting walls. You need to add attribute(s) and implement all methods. |
Class | Graphical output | Text output |
Cell |
% python Cell.py |
|
CellPassage |
% python CellPassage.py Adding gem to passage, result = True Adding gem to passage, result = False Adding key to passage, result = False Adding key to passage2, result = True Adding key to secret, result = True Adding gem to passage, result = False Adding key to passage, result = False Adding key to secret2, result = True |
|
CellDoor |
% python CellDoor.py Adding gem to closed door, result = False Adding key to closed door, result = False Adding gem to open door, result = True Adding key to open door, result = False Adding key to open door2, result = True Adding gem to open door2, result = False |
|
Hero |
% python Hero.py hero1, location (0, 0) hero1, gems = 0, keys = 0 hero1, gems = 1, keys = 0 hero1, gems = 1, keys = 1 hero1, gems = 1, keys = 2 hero1, gems = 2, keys = 2 hero1, using key = True, gems = 2, keys = 1 hero1, using key = True, gems = 2, keys = 0 hero1, using key = False, gems = 2, keys = 0 hero1, using gem = True, gems = 1, keys = 0 hero1, using gem = True, gems = 0, keys = 0 hero1, using gem = False, gems = 0, keys = 0 hero2, location (1, 0) |
|
Dungeon |
NOTE: Placement of items will vary from the picture.% python Dungeon.py |
Grade Item | Points Possible | Points Earned |
---|---|---|
Program Compiles and Runs | 2 | |
Comments on All Your Classes and Methods | 4 | |
Implemented Cell Correctly | 5 | |
Implemented CellPassage Correctly | 5 | |
Implemented CellDoor Correctly | 5 | |
Implemented Hero Correctly | 4 | |
Implemented Dungeon Correctly | 5 | |
Total | 30 |
Page last updated: November 14, 2019