|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.percederberg.tetris.SquareBoard
A Tetris square board. The board is rectangular and contains a grid of colored squares. The board is considered to be constrained to both sides (left and right), and to the bottom. There is no constraint to the top of the board, although colors assigned to positions above the board are not saved.
Constructor Summary | |
SquareBoard(int width,
int height)
Creates a new square board with the specified size. |
Method Summary | |
void |
clear()
Clears the board, i.e. removes all the colored squares. |
int |
getBoardHeight()
Returns the board height (in squares). |
int |
getBoardWidth()
Returns the board width (in squares). |
java.awt.Component |
getComponent()
Returns a graphical component to draw the board. |
int |
getRemovedLines()
Returns the number of lines removed since the last clear(). |
java.awt.Color |
getSquareColor(int x,
int y)
Returns the color of an individual square on the board. |
boolean |
hasFullLines()
Checks if the board contains any full lines. |
boolean |
isLineEmpty(int y)
Checks if a specified line is empty, i.e. only contains empty squares. |
boolean |
isLineFull(int y)
Checks if a specified line is full, i.e. only contains no empty squares. |
boolean |
isSquareEmpty(int x,
int y)
Checks if a specified square is empty, i.e. if it is not marked with a color. |
void |
removeFullLines()
Removes all full lines. |
void |
setMessage(java.lang.String message)
Sets a message to display on the square board. |
void |
setSquareColor(int x,
int y,
java.awt.Color color)
Changes the color of an individual square on the board. |
void |
update()
Updates the graphical component. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SquareBoard(int width, int height)
width
- the width of the board (in squares)height
- the height of the board (in squares)Method Detail |
public boolean isSquareEmpty(int x, int y)
x
- the horizontal position (0 <= x < width)y
- the vertical position (0 <= y < height)public boolean isLineEmpty(int y)
y
- the vertical position (0 <= y < height)public boolean isLineFull(int y)
y
- the vertical position (0 <= y < height)public boolean hasFullLines()
public java.awt.Component getComponent()
public int getBoardHeight()
public int getBoardWidth()
public int getRemovedLines()
public java.awt.Color getSquareColor(int x, int y)
x
- the horizontal position (0 <= x < width)y
- the vertical position (0 <= y < height)public void setSquareColor(int x, int y, java.awt.Color color)
x
- the horizontal position (0 <= x < width)y
- the vertical position (0 <= y < height)color
- the new square color, or null for emptypublic void setMessage(java.lang.String message)
message
- a message to display, or null to remove a
previous messagepublic void clear()
public void removeFullLines()
hasFullLines()
public void update()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |