|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrogue.Map
public class Map
Instance of class Map holds the data that represent the "dungeon" and the current locations of movable items ("treasures", "player", and "monsters") that are in the dungeon. It provides a few utility functions e.g. accessible() that will get called from code implementing the behaviours of various monster classes.
| Field Summary | |
|---|---|
static int |
kMAPGRIDSIZE
Size of one square of dungeon (pixel dimension) |
| Constructor Summary | |
|---|---|
Map(int width,
int height)
Constructor, creates two arrays representing dungeon and contents. |
|
| Method Summary | |
|---|---|
boolean |
accessible(int x,
int y)
Checks that square is open-space |
void |
clear(int x,
int y)
Removes any entry from "overlay" grid |
int |
elementAt(int h,
int v)
Identifies whether square is open or wall. |
int |
height()
Return height of map |
void |
paint(java.awt.Graphics g,
java.awt.Canvas drawer)
Redraws Map in MyCanvas. |
void |
read(java.io.BufferedReader input)
Reads dungeon layout. |
void |
set(int x,
int y,
int sym)
Sets overlay grid to contain identifier of particular icon to be displayed (if several moveable items are on same spot, the display will show only the one that called "set()" last; it is possible for there to be a Collectable item and several Monsters on the same square, only one shown) |
boolean |
validPoint(int x,
int y)
Checks whether x,y coordinate is located within map and is not a wall square. |
int |
width()
Returns width of map |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int kMAPGRIDSIZE
| Constructor Detail |
|---|
public Map(int width,
int height)
width - Width of mapheight - Height of map| Method Detail |
|---|
public void read(java.io.BufferedReader input)
input - BufferedReader connected to dungeon definition file.
public boolean validPoint(int x,
int y)
x - x coordinate of point being testedy - y coordinate of point being tested
public boolean accessible(int x,
int y)
x - x coordinate of square of interesty - y coordinate of square of interest
public void clear(int x,
int y)
x - X coordinate of pointy - Y coordinate of point
public void set(int x,
int y,
int sym)
x - X coordinate of squarey - Y coordinate of squaresym - Integer id of image to be shown in overlay
public void paint(java.awt.Graphics g,
java.awt.Canvas drawer)
g - Graphics object (associated with offscreen buffer)drawer - Component reference needed as ImageObserver when drawing an Imagepublic int width()
public int height()
public int elementAt(int h,
int v)
h - Horizontal coordinatev - Vertical coordinate
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||