|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectexample.wormgame.WormLink
public class WormLink
WormLink represents one sub-section of a worm. Because the worm will usually contain a few straight segments, this is a relatively cost effective way to store the entire worm. The [X,Y] coordinates are the "tail" of the worm. The link is drawn starting at the tail and proceeding "len" spaces in direction "dir".
Constructor Summary | |
---|---|
WormLink(int startX,
int startY,
byte direction)
Create a worm link with a length of 1. |
|
WormLink(int startX,
int startY,
int length,
byte direction)
|
Method Summary | |
---|---|
boolean |
contains(int x,
int y)
Returns true if the worm segment is at the given cell |
void |
decreaseLength()
Remove one cell length from the tail of this segment. |
byte |
getDirection()
Get the direction this worm segment is pointing. |
int |
getEndX()
Get the X coordinate of the cell that contains the tail of this worm segment. |
int |
getEndY()
Get the Y coordinate of the cell that contains the tail of this worm segment. |
int |
getLength()
Get the length, in cells, of this segment. |
int |
getX()
Get the X coordinate of the cell that contains the head of this worm segment. |
int |
getY()
Get the Y coordinate of the cell that contains the head of this worm segment. |
void |
increaseLength()
Add one cell length to the head of this segment. |
java.lang.String |
toString()
Debug method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WormLink(int startX, int startY, int length, byte direction)
public WormLink(int startX, int startY, byte direction)
Method Detail |
---|
public void increaseLength()
public void decreaseLength()
public int getLength()
public int getX()
public int getY()
public int getEndX()
public int getEndY()
public byte getDirection()
public boolean contains(int x, int y)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |