|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectgameLogic.GameObject
gameLogic.Snake
public class Snake
The Snake class is a representation of each snake currently in the game, including its name, its current direction, its position on the game board, and its current statistics. It is a subclass of the GameObject class, in order for snakes to be able to be inserted into Square objects.
Constructor Summary | |
---|---|
Snake(GameObjectType type,
java.lang.String name,
Brain brain,
java.awt.Color color)
|
|
Snake(Snake other)
|
Method Summary | |
---|---|
java.awt.Color |
getColor()
|
Direction |
getCurrentDirection()
Gets the direction this snake moved in last turn. |
Direction |
getDirection(Position position)
Get the direction of a specific segment in this snake. |
Position |
getHeadPosition()
Gets the current position of this snake's head. |
int |
getLifespan()
Gets the number of turns this snake has lived. |
java.lang.String |
getName()
|
int |
getScore()
Gets the number of fruits this snake has eaten. |
java.util.LinkedList<Position> |
getSegments()
Get a list of all the squares this snake has occupied. |
Position |
getTailPosition()
Gets the current position of the last segment of the snake's tail. |
boolean |
isDead()
Returns whether or not this snake is dead. |
java.lang.String |
toString()
Returns a string representation of this snake, consisting of a String of its name. |
Methods inherited from class gameLogic.GameObject |
---|
getType |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Snake(GameObjectType type, java.lang.String name, Brain brain, java.awt.Color color)
public Snake(Snake other)
Method Detail |
---|
public java.util.LinkedList<Position> getSegments()
public Direction getDirection(Position position)
position
- The position (in x-y coordinates) of the segment.
public Position getHeadPosition()
Position
public Position getTailPosition()
public boolean isDead()
public Direction getCurrentDirection()
public int getScore()
public int getLifespan()
public java.lang.String toString()
toString
in class java.lang.Object
public java.awt.Color getColor()
public java.lang.String getName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |