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 setBallSize (int s)
 sets 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...
 
void setBottomScore (int s)
 sets the score for player More...
 
int getBallX ()
 gets the x-position of the ball More...
 
int getBallY ()
 gets the y-position of the ball 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...
 

Protected Member Functions

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

Private Attributes

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

Constructor & Destructor Documentation

§ PongGameDisplay()

view.PongGameDisplay.PongGameDisplay ( )

Constructor for PongGameDisplay.

Constructor by default set the game to single mode

Member Function Documentation

§ 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

§ 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

§ 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 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

§ setBallSize()

void view.PongGameDisplay.setBallSize ( int  s)

sets the size of the ball

Parameters
sis the ball size

§ setBottom()

void view.PongGameDisplay.setBottom ( int  x)

sets x-position for the player paddle

Parameters
sis the x-position

§ setBottomScore()

void view.PongGameDisplay.setBottomScore ( int  s)

sets the score for player

Parameters
sis the score

§ setInset()

void view.PongGameDisplay.setInset ( int  i)

sets the distance between frame and the paddle

Parameters
iis the inset

§ setPaddleHeight()

void view.PongGameDisplay.setPaddleHeight ( int  h)

sets the height of the paddle

Parameters
his the height

§ setPaddleWidth()

void view.PongGameDisplay.setPaddleWidth ( int  w)

sets the width of the paddle

Parameters
wis the width

§ setTop()

void view.PongGameDisplay.setTop ( int  x)

sets x-position for the ai paddle

Parameters
sis the x-position

§ setTopScore()

void view.PongGameDisplay.setTopScore ( int  s)

sets the score for ai

Parameters
sis the score

Member Data Documentation

§ ADVANCE

final int view.PongGameDisplay.ADVANCE =1
private

§ ballSize

int view.PongGameDisplay.ballSize
private

§ ballX

int view.PongGameDisplay.ballX
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

§ topPadX

int view.PongGameDisplay.topPadX
private

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