core
Class Grid

java.lang.Object
  extended by core.Grid

public class Grid
extends java.lang.Object


Constructor Summary
Grid(int Xmax, int Ymax)
          Starts a new grid with specified dimensions, Xmax by Ymax
 
Method Summary
 void add(Room obj, int x, int y)
          Adds an object at the specified point
 int[] getCoord(Room p)
          Returns the coordinates of point p in an array with index 0 = x and 1 = y
 Exit getExit(Room r, java.lang.String d)
          Returns the exit corresponding to the room and direction specified
 int[] getOffset(Room r1, Room r2)
          Returns the offset from r1 to r2
 Room getStart()
          Returns the start room
 boolean isOnGrid(Room r)
          Checks to see if the room is on the grid
 void linkRooms(Room r1, Room r2, boolean passable, boolean locked, java.lang.String name, java.lang.String desc)
          'Links' two rooms using an exit
 Room objEast(Room p)
          Returns the object(s) east of point p
 Room objNorth(Room p)
          Returns the object(s) north of point p
 Room objSouth(Room p)
          Returns the object(s) south of point p
 Room objWest(Room p)
          Returns the object(s) west of point p
 Room roomAtOffset(Room p, int xOffset, int yOffset)
          Returns the object(s) at an offset of point p
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Grid

public Grid(int Xmax,
            int Ymax)
Starts a new grid with specified dimensions, Xmax by Ymax

Parameters:
Xmax - define the maximum x value on the grid
Ymax - define the maximum y value on the grid
Method Detail

getStart

public Room getStart()
Returns the start room

Returns:
the first room added to the grid. This is considered the first room.

add

public void add(Room obj,
                int x,
                int y)
Adds an object at the specified point

Parameters:
obj - room to be added to the grid
x - x value of room on grid
y - y value of room on grid

objNorth

public Room objNorth(Room p)
Returns the object(s) north of point p

Parameters:
p - reference room
Returns:
the room to the north of room 'p'

objEast

public Room objEast(Room p)
Returns the object(s) east of point p


objSouth

public Room objSouth(Room p)
Returns the object(s) south of point p


objWest

public Room objWest(Room p)
Returns the object(s) west of point p


roomAtOffset

public Room roomAtOffset(Room p,
                         int xOffset,
                         int yOffset)
Returns the object(s) at an offset of point p


getOffset

public int[] getOffset(Room r1,
                       Room r2)
Returns the offset from r1 to r2


isOnGrid

public boolean isOnGrid(Room r)
Checks to see if the room is on the grid


getCoord

public int[] getCoord(Room p)
Returns the coordinates of point p in an array with index 0 = x and 1 = y


linkRooms

public void linkRooms(Room r1,
                      Room r2,
                      boolean passable,
                      boolean locked,
                      java.lang.String name,
                      java.lang.String desc)
'Links' two rooms using an exit


getExit

public Exit getExit(Room r,
                    java.lang.String d)
Returns the exit corresponding to the room and direction specified