erland.game.tetris
Class BlockContainerData

java.lang.Object
  extended byerland.game.tetris.BlockContainerData
All Implemented Interfaces:
BlockMatrix

class BlockContainerData
extends java.lang.Object
implements BlockMatrix

Class that keeps track of the color and state on all squares in a game area


Field Summary
protected  java.awt.Color[][] colorMatrix
          Matrix that keeps track of the colour of all squares
protected  boolean[][] matrix
          Matrix that keeps track of the state of all squares
 
Constructor Summary
(package private) BlockContainerData(int sizeX, int sizeY)
          Create a new instance
 
Method Summary
 void clear()
          Reset the states on all squares
 void clearRow(int y)
          Reset the states on all squares in a row
 void fromString(java.lang.String data)
           
 java.awt.Color getColor(int x, int y)
          Get the color of a specific square
 int getHeight()
          Get the number of vertical squares in the container
 int getWidth()
          Get the number of horisontal squares in the container
 boolean isUsed(int x, int y)
          Checks if a specific square is active or not
 void setUnused(int x, int y)
          Change the state to not active for a specific square
 void setUsed(int x, int y, java.awt.Color c)
          Change the state to active for a specific square
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

matrix

protected boolean[][] matrix
Matrix that keeps track of the state of all squares


colorMatrix

protected java.awt.Color[][] colorMatrix
Matrix that keeps track of the colour of all squares

Constructor Detail

BlockContainerData

BlockContainerData(int sizeX,
                   int sizeY)
Create a new instance

Parameters:
sizeX - Number of horizontal squares
sizeY - Number of vertical squares
Method Detail

clear

public void clear()
Reset the states on all squares


clearRow

public void clearRow(int y)
Reset the states on all squares in a row

Parameters:
y - Vertical row that should be cleared, 0 is the top row

getColor

public java.awt.Color getColor(int x,
                               int y)
Description copied from interface: BlockMatrix
Get the color of a specific square

Specified by:
getColor in interface BlockMatrix
Parameters:
x - The x position of the square
y - The y position of the square
Returns:
The color of the square, Color.black if it is outside the container

getWidth

public int getWidth()
Description copied from interface: BlockMatrix
Get the number of horisontal squares in the container

Specified by:
getWidth in interface BlockMatrix
Returns:
Number of horisontal squares

getHeight

public int getHeight()
Description copied from interface: BlockMatrix
Get the number of vertical squares in the container

Specified by:
getHeight in interface BlockMatrix
Returns:
Number of vertical squares

isUsed

public boolean isUsed(int x,
                      int y)
Description copied from interface: BlockMatrix
Checks if a specific square is active or not

Specified by:
isUsed in interface BlockMatrix
Parameters:
x - The x position of the square
y - The y position of the square
Returns:
true/false (active/not active)

setUsed

public void setUsed(int x,
                    int y,
                    java.awt.Color c)
Description copied from interface: BlockMatrix
Change the state to active for a specific square

Specified by:
setUsed in interface BlockMatrix
Parameters:
x - The x position of the square
y - The y position of the square
c - The colour of the square

setUnused

public void setUnused(int x,
                      int y)
Description copied from interface: BlockMatrix
Change the state to not active for a specific square

Specified by:
setUnused in interface BlockMatrix
Parameters:
x - The x position of the square
y - The y position of the square

fromString

public void fromString(java.lang.String data)

toString

public java.lang.String toString()


Copyright © 2003-2004 Erland Isaksson. All Rights Reserved.