com.jeffpalm.eggtris
Class MyShape

java.lang.Object
  extended by com.jeffpalm.eggtris.MyShape
Direct Known Subclasses:
Cross, LeftL, LeftWiggle, LongThing, RightL, RightWiggle, Square

public abstract class MyShape
extends java.lang.Object

This is the acstract class for a block in Eggtris.

Each Shape will have its own constructor, but it should follow the format:

[ShapeName](int size, int x, int y)

Since:
10.23.1998
Author:
Jeffrey Palm
See Also:
eggtris.Square, eggtris.RightL

Field Summary
protected  Brick[] bricks
          The array of Bricks.
protected  int size
          The size of a block.
protected  int x
          The x position on the Board.
protected  int y
          The y position on the Board.
 
Constructor Summary
MyShape()
           
 
Method Summary
 void draw(java.awt.Graphics g)
          Draws this shape on the passed in Graphics context.
 void givesItsBricksTo(Board board)
          VERY IMPORTANT
 boolean moveDown(Board board)
          COME BACK HERE TO CHANGE THE RATE OF DROP Move down one space on the board.
 boolean moveLeft(Board board)
          Move left one space on the board.
 boolean moveRight(Board board)
          Move right one space on the board, if it can.
 boolean moveUp(Board board)
          Move up one space on the board.
abstract  boolean rotate(Board board)
          Over-ride this method to give your Shape the ability to rotate.
 void setX(int x)
          Sets the x coord.
 void setY(int y)
          Sets the y coord.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bricks

protected Brick[] bricks
The array of Bricks. This enables the Shape to be drawn on a Board.


x

protected int x
The x position on the Board.


y

protected int y
The y position on the Board.


size

protected int size
The size of a block.

Constructor Detail

MyShape

public MyShape()
Method Detail

rotate

public abstract boolean rotate(Board board)
Over-ride this method to give your Shape the ability to rotate.

Parameters:
board - Board on which to rotate.
Returns:
True if it could rotate, else false.

moveRight

public boolean moveRight(Board board)
Move right one space on the board, if it can.

Parameters:
Board - on which the Shape it drawn.
Returns:
Whether it could be moved.

moveUp

public boolean moveUp(Board board)
Move up one space on the board. This method won't be normally used in games.

Parameters:
Board - on the Shape is drawn.
Returns:
Whether it could be moved.

moveDown

public boolean moveDown(Board board)
COME BACK HERE TO CHANGE THE RATE OF DROP Move down one space on the board.

Parameters:
Board - on which the Shape it drawn.
Returns:
Whether it could be moved.

moveLeft

public boolean moveLeft(Board board)
Move left one space on the board.

Parameters:
Board - on which the Shape it drawn.
Returns:
Whether it could be moved.

draw

public void draw(java.awt.Graphics g)
Draws this shape on the passed in Graphics context.

Parameters:
g - Graphics context on which to draw itself.

givesItsBricksTo

public void givesItsBricksTo(Board board)
VERY IMPORTANT

Call from the contrlling Applet tell this block to give its bricks to the Boardo on which it is drawn (the one passed in). If you don't call it, this Shape will NOT become locked onto the board.

Parameters:
board - Board on which this's Bricks will be locked.

setX

public void setX(int x)
Sets the x coord.

Parameters:
x - X position.

setY

public void setY(int y)
Sets the y coord.

Parameters:
y - Y position.