| Modifier and Type | Field and Description |
|---|---|
protected Color |
color
The color of the block.
|
protected BlockGrid |
grid
The grid that represents the block in its current orientation.
|
protected IPoint2D |
position
The position on the playing field of the top left corner of the grid.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Block(int gridSize,
IPoint2D pos,
Color col)
Construct a block given its grid size, position, and color.
|
| Modifier and Type | Method and Description |
|---|---|
void |
draw()
Draw the block on the playing field in its current position and orientation.
|
protected void |
draw(Color c)
Draw the block to the playing field in its current position and orientation using
the specified color.
|
protected void |
erase()
Erase the block from the playing field in its current position and orientation.
|
IPoint2D |
getPosition()
Get the position on the playing field of the top-left corner of the block's
grid.
|
void |
moveDown()
Moves the block down by 1 grid position and draws the block in its new
position.
|
void |
moveLeft()
Moves the block to the left by 1 grid position and draws the block in its
new position.
|
void |
moveRight()
Moves the block to the right by 1 grid position and draws the block in its
new position.
|
void |
moveUp()
Moves the block up by 0 grid positions and draws the block in its new
position.
|
protected BlockGrid grid
protected IPoint2D position
protected Color color
protected Block(int gridSize,
IPoint2D pos,
Color col)
this.grid will be a BlockGrid of size
gridSize-by-gridSize with all grid locations
cleared.
This constructor should be called only by direct child classes.
gridSize - the size of the gridpos - the position on the playing field of the top-left corner of the gridcol - the color of the blockgridSize > 0protected void erase()
protected void draw(Color c)
c - the color to draw withpublic void draw()
draw in interface DrawableDrawable.draw()public void moveLeft()
moveLeft in interface MovableMovable.moveLeft()public void moveRight()
moveRight in interface MovableMovable.moveRight()public void moveDown()
moveDown in interface MovableMovable.moveDown()public void moveUp()
moveUp in interface MovableMovable.moveUp()public IPoint2D getPosition()
getPosition in interface DrawableDrawable.getPosition()