|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.cilib.games.states.GameState net.sourceforge.cilib.games.states.GridGameState net.sourceforge.cilib.games.game.tetris.TetrisGameState
public class TetrisGameState
This class represents a Tetris game state.
Field Summary |
---|
Fields inherited from class net.sourceforge.cilib.games.states.GridGameState |
---|
state |
Fields inherited from class net.sourceforge.cilib.games.states.GameState |
---|
currentIteration, randomizer |
Constructor Summary | |
---|---|
TetrisGameState()
|
|
TetrisGameState(TetrisGameState other)
|
Method Summary | |
---|---|
void |
calculateScore(int rowsCleared)
Calculate the score based on the amount of rows cleared |
int |
clearFullRows()
Clear any full rows in the current game grid. |
static int |
clearFullRows(GameItem[][] state,
int Width,
int Height)
Clear all full rows for a given game grid |
void |
clearState()
Clear the state and reset it to a start state. |
boolean |
collides(AbstractShape shape)
Check whether one of the blocks in the AbstractShape collides in the current grid |
boolean |
collides(List<TetrisBlock> blocks)
Check whether one of the blocks in the list collides in the current grid |
void |
createNewShape()
Create a new random Tetris shape at the top of the grid |
boolean |
currentShapeCollides()
Check whether one of the blocks in the current shape of the game collides in the grid |
boolean |
FitShapeInGridTopDown()
Fit the current shape in the current grid from its current position moving down untill it either collides or is at the bottowm of the grid |
TetrisGameState |
getClone()
Create a cloned copy of the current object and return it. |
int |
getCurrentLevel()
|
double |
getCurrentScore()
|
AbstractShape |
getCurrentShape()
|
double |
getCurrentSpeed()
|
int |
getEmptyCellsBeforeOccupied(int x,
int startY)
Get the number of empty cells in the grid before an occupied one |
int |
getErodedShapeCount()
Get the number of blocks form the current AbstractShape that will be removed if the shape was to be merged at its current position |
int |
getTotalRowsCleared()
|
void |
mergeCurrentShape()
Merge the current AbstractShape into the grid |
boolean |
moveRight()
Move the current piece one position to the right if it doesn't collide there. |
void |
setCurrentShape(AbstractShape newShape)
|
void |
setItem(int i,
int j,
GameItem item)
Set an item at a specific index in the matrix |
boolean |
setShapeLeftGrid()
Set the current AbstractShape as far to the left of the current grid as it can go |
Methods inherited from class net.sourceforge.cilib.games.states.GridGameState |
---|
getGridHeight, getGridWidth, getItem, setGridHeight, setGridWidth |
Methods inherited from class net.sourceforge.cilib.games.states.GameState |
---|
getCurrentIteration, getRandomizer, increaseIteration, resetIterationCount, setRandomizer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TetrisGameState()
public TetrisGameState(TetrisGameState other)
Method Detail |
---|
public TetrisGameState getClone()
getClone
in interface Cloneable
getClone
in class GridGameState
Object.clone()
public void createNewShape()
public void setItem(int i, int j, GameItem item)
GridGameState
setItem
in class GridGameState
i
- the specified Columnj
- the specified Rowitem
- the item to set. This method does not check if an item already exists, and will simply override
what is in that position.public void mergeCurrentShape()
public void calculateScore(int rowsCleared)
rowsCleared
- public int getErodedShapeCount()
public int getEmptyCellsBeforeOccupied(int x, int startY)
x
- the row to look instartY
- the column to start looking at
public static int clearFullRows(GameItem[][] state, int Width, int Height)
state
- the grid of blocksWidth
- the with of the gridHeight
- the heigth of the grid
public int clearFullRows()
public boolean setShapeLeftGrid()
public boolean FitShapeInGridTopDown()
public boolean moveRight()
public boolean currentShapeCollides()
public boolean collides(AbstractShape shape)
AbstractShape
collides in the current grid
blocks
- The given AbstractShape
public boolean collides(List<TetrisBlock> blocks)
blocks
- A list of TetrisBlock
s
public void clearState()
clearState
in class GridGameState
public int getCurrentLevel()
public double getCurrentScore()
public AbstractShape getCurrentShape()
public void setCurrentShape(AbstractShape newShape)
public double getCurrentSpeed()
public int getTotalRowsCleared()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |