FaultInOurPong  1
view.PongGameDisplay Class Reference
Inheritance diagram for view.PongGameDisplay:

Public Member Functions

 PongGameDisplay ()
 Constructor for PongGameDisplay. More...
 
void setBall (int x, int y)
 sets the positions of the ball More...
 
void setBottomPaddle (int x, int y)
 sets the positions of the player paddle More...
 
void setTopPaddle (int x, int y)
 sets the positions of the AI paddle More...
 
void setBomb (int x, int y)
 sets the positions of the bomb More...
 
void timeForBomb ()
 defines the game mode contains a bomb More...
 
void noBomb ()
 defines the game mode does not contain a bomb More...
 
boolean bombTime ()
 checks if it should start displaying the bomb More...
 
void setBallSize (int s)
 sets the size of the ball More...
 
int getBallSize ()
 gets the size of the ball More...
 
void setBottom (int x)
 sets x-position for the player paddle More...
 
void setTop (int x)
 sets x-position for the ai paddle More...
 
int getBottomX ()
 gets the x-position of the player paddle More...
 
int getBottomY ()
 gets the y-position of the player paddle More...
 
void setTopScore (int s)
 sets the score for ai More...
 
int getTopScore ()
 gets the score of AI More...
 
void setBottomScore (int s)
 sets the score for player More...
 
int getBottomScore ()
 gets the player score More...
 
int getBallX ()
 gets the x-position of the ball More...
 
int getBallY ()
 gets the y-position of the ball More...
 
int getBombX ()
 gets the x-position of the bomb More...
 
int getBombY ()
 gets the y-position of the bomb More...
 
void setPaddleWidth (int w)
 sets the width of the paddle More...
 
void setPaddleHeight (int h)
 sets the height of the paddle More...
 
void setInset (int i)
 sets the distance between frame and the paddle More...
 
void setAdvance ()
 sets the game mode to be advanced More...
 
int getMode ()
 gets the mode of the game More...
 

Protected Member Functions

void paintComponent (Graphics g)
 draws shapes on the screen More...
 

Private Attributes

int frameWidth
 
int frameHeight
 
int scoreTop
 
int ballX
 
int bombX
 
int bottomPadX
 
int topPadX
 
boolean first
 
int ballSize
 
int padW
 
int inset
 
int gameMode
 
final int SINGLE =0
 
final int ADVANCE =1
 
boolean startBomb
 

Constructor & Destructor Documentation

§ PongGameDisplay()

view.PongGameDisplay.PongGameDisplay ( )

Constructor for PongGameDisplay.

Constructor by default set the game to single mode

Member Function Documentation

§ bombTime()

boolean view.PongGameDisplay.bombTime ( )

checks if it should start displaying the bomb

Returns
startBomb

§ getBallSize()

int view.PongGameDisplay.getBallSize ( )

gets the size of the ball

Returns
ballSize

§ getBallX()

int view.PongGameDisplay.getBallX ( )

gets the x-position of the ball

Returns
ballX

§ getBallY()

int view.PongGameDisplay.getBallY ( )

gets the y-position of the ball

Returns
ballY

§ getBombX()

int view.PongGameDisplay.getBombX ( )

gets the x-position of the bomb

Returns
bombX

§ getBombY()

int view.PongGameDisplay.getBombY ( )

gets the y-position of the bomb

Returns
bombY

§ getBottomScore()

int view.PongGameDisplay.getBottomScore ( )

gets the player score

Returns
scoreBottom

§ getBottomX()

int view.PongGameDisplay.getBottomX ( )

gets the x-position of the player paddle

Returns
bottomPadX

§ getBottomY()

int view.PongGameDisplay.getBottomY ( )

gets the y-position of the player paddle

Returns
bottomPadY

§ getMode()

int view.PongGameDisplay.getMode ( )

gets the mode of the game

Returns
gameMode

§ getTopScore()

int view.PongGameDisplay.getTopScore ( )

gets the score of AI

Returns
scoreTop

§ noBomb()

void view.PongGameDisplay.noBomb ( )

defines the game mode does not contain a bomb

set the flag for the advance to be false

§ paintComponent()

void view.PongGameDisplay.paintComponent ( Graphics  g)
protected

draws shapes on the screen

when the game is started, by default draws the ball and paddles in the middle, otherwise, draws objects by passed in values.

Initial positioning

  • ball at the center of the screen
  • paddle in the middle of the frame width

Draw rectangles by passed in values

Draw the ball by passed in values

Draw the bomb if the mode is the advance mode

Draw scores on the screen by passed in values

§ setAdvance()

void view.PongGameDisplay.setAdvance ( )

sets the game mode to be advanced

set the flag to advance

§ setBall()

void view.PongGameDisplay.setBall ( int  x,
int  y 
)

sets the positions of the ball

Parameters
xis the x-position of the ball
yis the y-position of the ball
Exceptions
ArithmeticExceptionball position could not be out of the game frame

§ setBallSize()

void view.PongGameDisplay.setBallSize ( int  s)

sets the size of the ball

Parameters
sis the ball size
Exceptions
ArithmeticExceptionball size should not be less than zero

§ setBomb()

void view.PongGameDisplay.setBomb ( int  x,
int  y 
)

sets the positions of the bomb

Parameters
xis the x-position of the bomb
yis the y-position of the bomb
Exceptions
ArithmeticExceptionbomb position could not be out of the game frame

§ setBottom()

void view.PongGameDisplay.setBottom ( int  x)

sets x-position for the player paddle

Parameters
sis the x-position
Exceptions
ArithmeticExceptionpaddle x-position could not be out of the game frame

§ setBottomPaddle()

void view.PongGameDisplay.setBottomPaddle ( int  x,
int  y 
)

sets the positions of the player paddle

Parameters
xis the x-position of the player paddle
yis the y-position of the player paddle
Exceptions
ArithmeticExceptionplayer paddle position could not be out of the game frame

§ setBottomScore()

void view.PongGameDisplay.setBottomScore ( int  s)

sets the score for player

Parameters
sis the score
Exceptions
ArithmeticExceptionplayer score could not be less than zero

§ setInset()

void view.PongGameDisplay.setInset ( int  i)

sets the distance between frame and the paddle

Parameters
iis the inset
Exceptions
ArithmeticExceptiondistance between paddle and frame could not be set out of the frame

§ setPaddleHeight()

void view.PongGameDisplay.setPaddleHeight ( int  h)

sets the height of the paddle

Parameters
his the height
Exceptions
ArithmeticExceptionpaddle height could not be less than zero

§ setPaddleWidth()

void view.PongGameDisplay.setPaddleWidth ( int  w)

sets the width of the paddle

Parameters
wis the width
Exceptions
ArithmeticExceptionpaddle width could not be less than zero

§ setTop()

void view.PongGameDisplay.setTop ( int  x)

sets x-position for the ai paddle

Parameters
sis the x-position
Exceptions
ArithmeticExceptionpaddle y-position could not be out of the game frame

§ setTopPaddle()

void view.PongGameDisplay.setTopPaddle ( int  x,
int  y 
)

sets the positions of the AI paddle

Parameters
xis the x-position of the AI paddle
yis the y-position of the AI paddle
Exceptions
ArithmeticExceptionai paddle position could not be out of the game frame

§ setTopScore()

void view.PongGameDisplay.setTopScore ( int  s)

sets the score for ai

Parameters
sis the score
Exceptions
ArithmeticExceptionai score could not be less than zero

§ timeForBomb()

void view.PongGameDisplay.timeForBomb ( )

defines the game mode contains a bomb

set the flag for the advance to be true

Member Data Documentation

§ ADVANCE

final int view.PongGameDisplay.ADVANCE =1
private

§ ballSize

int view.PongGameDisplay.ballSize
private

§ ballX

int view.PongGameDisplay.ballX
private

§ bombX

int view.PongGameDisplay.bombX
private

§ bottomPadX

int view.PongGameDisplay.bottomPadX
private

§ first

boolean view.PongGameDisplay.first
private

§ frameHeight

int view.PongGameDisplay.frameHeight
private

§ frameWidth

int view.PongGameDisplay.frameWidth
private

Variable declarations for the display

  • frame dimension
  • ball information
  • bomb information
  • player scores
  • paddle information

§ gameMode

int view.PongGameDisplay.gameMode
private

§ inset

int view.PongGameDisplay.inset
private

§ padW

int view.PongGameDisplay.padW
private

§ scoreTop

int view.PongGameDisplay.scoreTop
private

§ SINGLE

final int view.PongGameDisplay.SINGLE =0
private

§ startBomb

boolean view.PongGameDisplay.startBomb
private

§ topPadX

int view.PongGameDisplay.topPadX
private

The documentation for this class was generated from the following file: