|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectOOPI.tetris.TetrisFrame
TetrisFrame - The utility class for creating a frame for displaying and managing a game of Tetris. This manages the main event loop and interaction. It calls an instance of TetrisLogic to help manage the game board, and to evaluate potential game positions for automated play.
TetrisLogic
,
Cell
,
Position
Constructor Summary | |
TetrisFrame(java.lang.String title)
Constructor for a tetris game. |
Method Summary | |
Cell[][] |
addPieceToBoard(Cell[][] board,
Cell[][] piece,
Position pos)
Utility method to add the specified piece at a given position to a board. |
Cell[][] |
cloneBoard(Cell[][] board)
Makes a clone (i.e., copy) of the specified board. |
javax.swing.JPanel |
getPanel()
Get the GUI component that contains the tetris game. |
void |
keyPressed(java.awt.event.KeyEvent e)
|
void |
keyReleased(java.awt.event.KeyEvent e)
|
void |
keyTyped(java.awt.event.KeyEvent e)
|
void |
paintComponent(java.awt.Graphics g)
This paints the actual game. |
void |
setTetrisLogic(TetrisLogic logic)
Sets the logic to be used by this game of tetris. |
void |
show()
Creates a top-level window to put the tetris game in. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TetrisFrame(java.lang.String title)
title
- The window title (which will be appended with the current score)Method Detail |
public void setTetrisLogic(TetrisLogic logic)
logic
- The new game logicpublic void show()
public javax.swing.JPanel getPanel()
public Cell[][] addPieceToBoard(Cell[][] board, Cell[][] piece, Position pos)
board
- The board to add the piece topiece
- The piece to be addedpos
- The position of the piece to be added
public Cell[][] cloneBoard(Cell[][] board)
board
- The board to make a copy of
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void paintComponent(java.awt.Graphics g)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |