|
class | GameListener |
| action listener for the game page
|
|
class | ModeListener |
| action listener for the game mode page
|
|
class | TutorialListener |
| action listener for the tutorial page
|
|
class | WelcomepageListener |
| action listener for the welcome page
|
|
|
HashSet< String > | keys = new HashSet<String>() |
|
§ GameController()
Set default game mode to be single
Set up velocities
Obtain the window frame dimentions
Setups for ball in the Model
Setups for the bomb in the Model
Setups for the paddles in the Model
- obtain paddle dimensions
- initialize paddle positions for the player paddle
- initialize paddle positions for the ai paddle
Setups for the players in the Model
- initialize number of life for the player and the ai
Setups for the View
- obtain windows from the view
- add action listener for different windows
Initialize the start time and end time for a player
§ checkGameOver()
void startGame.GameController.checkGameOver |
( |
| ) |
|
|
private |
checks whether the game ends
check the number of life for both the player and the ai is 0.
- If the number of life for the ai is 0, the player wins
- If the number of life for the player is 0, the ai wins.
- Calculate the time a player has played, if breaks the record, save the record.
§ display()
void startGame.GameController.display |
( |
| ) |
|
sets the display
opens a window
§ getbombVelX()
int startGame.GameController.getbombVelX |
( |
| ) |
|
returns the velocity of bomb in the x direction.
- Returns
- bombVelX
§ getbombVelY()
int startGame.GameController.getbombVelY |
( |
| ) |
|
returns the velocity of bomb in the y direction.
- Returns
- bombVelY
§ getElapsedTime()
void startGame.GameController.getElapsedTime |
( |
| ) |
|
|
private |
obtains the time the user plays.
calculates the time elapsed and save it into a variable.
§ getVelX()
int startGame.GameController.getVelX |
( |
| ) |
|
returns the velocity of ball in the x direction.
- Returns
- velX
§ getVelY()
int startGame.GameController.getVelY |
( |
| ) |
|
returns the velocity of ball in the y direction.
- Returns
- velY
§ resetGame()
void startGame.GameController.resetGame |
( |
| ) |
|
|
private |
resets to initial when the player exits a game.
re-initializes the variables in the game model and update the variables in view and model.
Reset player scores/lives in the model.
Reset the game mode
Reset ball and bomb position
Reset the ball and bomb speed
Re-obtain scores/lives from the model
Reset scores in the view
§ setSpeed()
void startGame.GameController.setSpeed |
( |
| ) |
|
|
private |
resets speed to ball and bomb
re-initialize by randomized values
Randomize the velocity for bomb
§ ADVANCE
final int startGame.GameController.ADVANCE = 1 |
|
private |
§ ai
Player startGame.GameController.ai |
|
private |
Ball startGame.GameController.b |
|
private |
§ ballX
int startGame.GameController.ballX |
|
private |
§ bomb
Ball startGame.GameController.bomb |
|
private |
§ bombVelX
int startGame.GameController.bombVelX |
|
private |
§ bombX
int startGame.GameController.bombX |
|
private |
§ bottomPadX
int startGame.GameController.bottomPadX |
|
private |
§ displayScore
HighScore startGame.GameController.displayScore |
|
private |
§ endTime
long startGame.GameController.endTime |
|
private |
§ exit
JButton startGame.GameController.exit |
|
private |
§ frameWidth
int startGame.GameController.frameWidth |
|
private |
§ gameDisplay
§ gameFrame
JFrame startGame.GameController.gameFrame |
|
private |
Variable declarations for the game
- frame dimension
- paddle information
- ball information
- bomb information
- player information
§ gameMode
int startGame.GameController.gameMode |
|
private |
§ inset
int startGame.GameController.inset |
|
private |
§ keys
HashSet<String> startGame.GameController.keys = new HashSet<String>() |
Declare a variable for storing the key pressed records
§ mode
Mode startGame.GameController.mode |
|
private |
§ paddle_player
Paddle startGame.GameController.paddle_player |
|
private |
§ padWidth
int startGame.GameController.padWidth |
|
private |
§ pause
JButton startGame.GameController.pause |
|
private |
§ player
Player startGame.GameController.player |
|
private |
§ resume
JButton startGame.GameController.resume |
|
private |
§ save
JButton startGame.GameController.save |
|
private |
§ scoreTop
int startGame.GameController.scoreTop |
|
private |
§ SINGLE
final int startGame.GameController.SINGLE = 0 |
|
private |
§ startTime
long startGame.GameController.startTime |
|
private |
Timer startGame.GameController.t |
|
private |
§ timeElapsed
double startGame.GameController.timeElapsed |
|
private |
§ tut
Import model and view to the controller (this interface).
§ velX
int startGame.GameController.velX =1 |
|
private |
Variable declarations for storing the game view windows
- welcome page
- mode page for showing different modes
- tutorial page for giving instructions to the students
The documentation for this class was generated from the following file: