erland.game.tetris
Class TetrisMain

java.lang.Object
  extended by erland.game.tetris.TetrisMain
All Implemented Interfaces:
GamePanelInterface

public class TetrisMain
extends Object
implements GamePanelInterface


Field Summary
protected  int END_BLINK_SPEED
          Speed of blinking text
protected  int endBlink
          Counter to handle blinking of text when game is completed or GAME OVER has occurred
protected  int offsetX
          Horizontal drawing offset
protected  int offsetY
          Vertical drawing offset
protected  erland.game.tetris.BlockContainerData previewContainer
          Container representing the next block
protected  int spaceBetweenSquares
          Number of pixels between squares
protected  int squareSize
          Size of the squares
protected  erland.game.tetris.BlockContainerData titleContainer
          Container representing the game logo
 
Constructor Summary
TetrisMain(TetrisModelInterface model)
           
 
Method Summary
 void draw()
           
protected  void drawContainer(Graphics g, erland.game.tetris.BlockMatrix m, int offsetX, int offsetY, int squareSize, int spaceBetweenSquares, int borderSize, Color borderColor, Color gridColor)
          Draw all grapics in a specific BlockMatrix
 void exit()
           
protected  void init()
          Initialize a new game
 void init(GameEnvironmentInterface environment)
           
 boolean isExit()
           
protected  void makeTitle(erland.game.tetris.BlockMatrix m)
          Draw the tetris logo in the specied BlockMatrix
 void newGame()
          Start a new game, this will only succeed if there is not a game already running
 void setCheatmode(boolean enable)
           
 void update()
           
protected  void updatePreviewContainer()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

titleContainer

protected erland.game.tetris.BlockContainerData titleContainer
Container representing the game logo


previewContainer

protected erland.game.tetris.BlockContainerData previewContainer
Container representing the next block


squareSize

protected int squareSize
Size of the squares


offsetX

protected int offsetX
Horizontal drawing offset


offsetY

protected int offsetY
Vertical drawing offset


spaceBetweenSquares

protected int spaceBetweenSquares
Number of pixels between squares


endBlink

protected int endBlink
Counter to handle blinking of text when game is completed or GAME OVER has occurred


END_BLINK_SPEED

protected final int END_BLINK_SPEED
Speed of blinking text

See Also:
Constant Field Values
Constructor Detail

TetrisMain

public TetrisMain(TetrisModelInterface model)
Method Detail

isExit

public boolean isExit()
Specified by:
isExit in interface GamePanelInterface

setCheatmode

public void setCheatmode(boolean enable)
Specified by:
setCheatmode in interface GamePanelInterface

exit

public void exit()
Specified by:
exit in interface GamePanelInterface

init

public void init(GameEnvironmentInterface environment)
Specified by:
init in interface GamePanelInterface

init

protected void init()
Initialize a new game


newGame

public void newGame()
Start a new game, this will only succeed if there is not a game already running


makeTitle

protected void makeTitle(erland.game.tetris.BlockMatrix m)
Draw the tetris logo in the specied BlockMatrix

Parameters:
m - The BlockMatrix to draw the logo in

update

public void update()
Specified by:
update in interface GamePanelInterface

draw

public void draw()
Specified by:
draw in interface GamePanelInterface

drawContainer

protected void drawContainer(Graphics g,
                             erland.game.tetris.BlockMatrix m,
                             int offsetX,
                             int offsetY,
                             int squareSize,
                             int spaceBetweenSquares,
                             int borderSize,
                             Color borderColor,
                             Color gridColor)
Draw all grapics in a specific BlockMatrix

Parameters:
g - The Graphics object to draw on
m - The BlockMatix object to draw
offsetX - The horisontal drawing offset
offsetY - The vertical drawing offset
squareSize - The size of each square in pixels
spaceBetweenSquares - Number of pixels between each square
borderSize - The size in pixels of the border around the drawn area
borderColor - The color of the border
gridColor - The color of the grid

updatePreviewContainer

protected void updatePreviewContainer()


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