|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrogue.DungeonGame
public class DungeonGame
The main class.
Its main() function creates a DungeonGame object, gets it to load its data
and starts it running.
Most of the functions are private. The (private) run function controls
the game with a loop having the form:
forever
sleep a bit
execute any user command (moving the Player avatar)
let all the Monsters have a move
update display
check for termination conditions (Player dead?, all collectables consumed?)
You will have to modify the (private) loadItems() function so that it
has code to read the definitions of any Monsters that you add to the data file.
| Constructor Summary | |
|---|---|
DungeonGame()
Constructor |
|
| Method Summary | |
|---|---|
boolean |
clearLineOfSight(Pt p1,
Pt p2,
int max,
Pt[] path)
Utility function likely to be useful from Monster code that your write. |
Collectable |
collectableAt(Pt p)
Checks whether there is a collectable item at given location |
Player |
human()
Access function - returns reference to Player object. |
static void |
main(java.lang.String[] args)
Main line - create object, initialize it (read data file, create display etc), let game run. |
Map |
map()
Access function, returns reference to Map object. |
Monster |
monsterAt(Pt p)
Checks whether there is a monster at given location |
void |
removeCollectable(Collectable c)
Invoked from Player code, informs DungeonGame object that a Collectable has been consumed. |
void |
removeMonster(Monster m)
Used in Player code. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DungeonGame()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
args - Command line arguments - there should be one: the name of a text
data file defining the map.public Map map()
public Player human()
public void removeMonster(Monster m)
m - Reference to (deceased) Monsterpublic void removeCollectable(Collectable c)
c - Collectable being removed from game.public Collectable collectableAt(Pt p)
p - Point where wish to check
public Monster monsterAt(Pt p)
p - Point of interest
public boolean clearLineOfSight(Pt p1,
Pt p2,
int max,
Pt[] path)
Monster relying on vision to detect Player;
Calls clearLineOfSight
If result is false, Monster cannot see Player; should continue with normal routine
If result is true, Monster can see player; Monster can possibly fire a projectile
down specified path, or monster can advance along path toward player.
p1 - Monster locationp2 - Player locationmax - Max sight rangepath - Allocated array of Pt object reference variables (of sufficient size
to hold all points along path); on return this will be filled in
with actual Pt objects.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||