erland.game.tetris
Class Block2

java.lang.Object
  extended byerland.game.tetris.Block
      extended byerland.game.tetris.Block2
All Implemented Interfaces:
java.lang.Cloneable

class Block2
extends Block

Represents the block:
0xx0
0xx0

Author:
Erland Isaksson

Field Summary
protected static java.awt.Color color
          The color of the block
protected  int rotation
          rotation angle of block
protected  int x
          x position of block(This is a block coordinate and not a pixel coordinate)
protected  int y
          y position of block(This is a block coordinate and not a pixel coordinate)
 
Constructor Summary
(package private) Block2()
           
 
Method Summary
protected  boolean check(BlockMatrix m, int x, int y, int rotation)
          Check if it is possible to put the block in the specified position and rotation angle
 java.lang.Object clone()
           
 java.awt.Color getColor()
          Get the color of the block
 int getRotation()
          Get the rotation of the block
 int getX()
           
 int getY()
           
protected  void init(int x, int y, int rotation)
          Initialize block
 boolean moveDown(BlockMatrix m)
          Move block once step down
 boolean moveLeft(BlockMatrix m)
          Move the block one step left
 boolean moveRight(BlockMatrix m)
          Move the block one step right
 boolean rotateLeft(BlockMatrix m)
          Rotate the block 90 degrees counter clockwize
 boolean rotateRight(BlockMatrix m)
          Rotate the block 90 degrees clockwize
protected  void set(BlockMatrix m, int x, int y, int rotation)
          Put the block in the specified position and rotation angle
protected  void unset(BlockMatrix m, int x, int y, int rotation)
          Remove the block from the specified position and rotation angle
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

color

protected static java.awt.Color color
The color of the block


rotation

protected int rotation
rotation angle of block


x

protected int x
x position of block(This is a block coordinate and not a pixel coordinate)


y

protected int y
y position of block(This is a block coordinate and not a pixel coordinate)

Constructor Detail

Block2

Block2()
Method Detail

getColor

public java.awt.Color getColor()
Description copied from class: Block
Get the color of the block

Specified by:
getColor in class Block
Returns:
The color of the block

check

protected boolean check(BlockMatrix m,
                        int x,
                        int y,
                        int rotation)
Description copied from class: Block
Check if it is possible to put the block in the specified position and rotation angle

Specified by:
check in class Block
Parameters:
m - The BlockMatrix in which the block resides
x - The x position which should be checked(Block coordinate)
y - The y position which should be checked(Block coordinate)
rotation - The rotation angle which should be checked
Returns:
true/false (Success/Failure)

unset

protected void unset(BlockMatrix m,
                     int x,
                     int y,
                     int rotation)
Description copied from class: Block
Remove the block from the specified position and rotation angle

Specified by:
unset in class Block
Parameters:
m - The BlockMatrix in which the block resides
x - The x position (Block coordinate)
y - The y position (Block coordinate)
rotation - The rotation angle

set

protected void set(BlockMatrix m,
                   int x,
                   int y,
                   int rotation)
Description copied from class: Block
Put the block in the specified position and rotation angle

Specified by:
set in class Block
Parameters:
m - The BlockMatrix in which the block resides
x - The x position (Block coordinate)
y - The y position (Block coordinate)
rotation - The rotation angle

clone

public java.lang.Object clone()

getRotation

public int getRotation()
Get the rotation of the block

Returns:
The rotation of the block 0,1,2,3

getX

public int getX()

getY

public int getY()

init

protected void init(int x,
                    int y,
                    int rotation)
Initialize block

Parameters:
x - x position of block(Block coordinate)
y - y position of block(Block coordinate)
rotation - rotation angle of block

moveDown

public boolean moveDown(BlockMatrix m)
Move block once step down

Parameters:
m - The BlockMatrix in which the block resides
Returns:
true/false (Success/Failure)

moveRight

public boolean moveRight(BlockMatrix m)
Move the block one step right

Parameters:
m - The BlockMatrix in which the block resides
Returns:
true/false (Success/Failure)

moveLeft

public boolean moveLeft(BlockMatrix m)
Move the block one step left

Parameters:
m - The BlockMatrix in which the block resides
Returns:
true/false (Success/Failure)

rotateRight

public boolean rotateRight(BlockMatrix m)
Rotate the block 90 degrees clockwize

Parameters:
m - The BlockMatrix in which the block resides
Returns:
true/false (Success/Failure)

rotateLeft

public boolean rotateLeft(BlockMatrix m)
Rotate the block 90 degrees counter clockwize

Parameters:
m - The BlockMatrix in which the block resides
Returns:
true/false (Success/Failure)


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