rogue
Class DungeonItem

java.lang.Object
  extended by rogue.DungeonItem
Direct Known Subclasses:
ActiveItem, Collectable

public abstract class DungeonItem
extends java.lang.Object

Abstract base class for all items that may occur in the dungeon.
All items are characterised by a current position. They can be removed from display map (vanish), or be added to the display map (show). They can return their position, or be asked whether they are currently at a particular location.
The read() function defined in this base class reads the starting position as defined in the dungeon definition input file.
The link to the dungeon object is used to obtain access to the Map structure when changing the visibility of the item.

See Also:
ActiveItem, Collectable

Field Summary
protected  Pt myPosition
          Protected element with current position.
protected  DungeonGame theDungeon
          Link to dungeongame object
 
Constructor Summary
DungeonItem(int imageNo, DungeonGame d)
          Constructor - record image icon used and link to dungeon.
 
Method Summary
 boolean isAt(Pt p)
          Determine whether item at specified location
 Pt position()
          Returns current position
 void read(java.io.BufferedReader in)
          Gets initial starting point location for item from input file.
 void show()
          Add item to display overlay map.
 void vanish()
          Remove item from display overlay map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myPosition

protected Pt myPosition
Protected element with current position.


theDungeon

protected DungeonGame theDungeon
Link to dungeongame object

Constructor Detail

DungeonItem

public DungeonItem(int imageNo,
                   DungeonGame d)
Constructor - record image icon used and link to dungeon.

Parameters:
imageNo - Integer identifier of icon used when displaying item.
d - Link to dungeongame object.
Method Detail

vanish

public void vanish()
Remove item from display overlay map


isAt

public boolean isAt(Pt p)
Determine whether item at specified location

Parameters:
p - Pt location used in query
Returns:
Boolean true/false indicator as to whether item at specified point

show

public void show()
Add item to display overlay map.


read

public void read(java.io.BufferedReader in)
Gets initial starting point location for item from input file.

Parameters:
in - BufferedReader connected to dungeon definition file.

position

public Pt position()
Returns current position

Returns:
Pt with current location