java.lang.Object
project.pong.model.GamePong
The GamePong class represents the game state and logic of the Pong game.
-
Constructor Summary
ConstructorsConstructorDescriptionGamePong(int screenWidth, int screenHeight) Constructs a GamePong object with the specified screen dimensions. -
Method Summary
Modifier and TypeMethodDescriptionvoidFully resets the game state, including scores.getBall()Gets the ball object.doubleGets the height of the game screen.Gets the game options.Gets player 1 object.Gets player 2 object.Gets the score required to win the game.doublegetWidth()Gets the width of the game screen.intGets the winner of the game.voidreset()Resets the game state.voidresizeHeight(double factor) Resizes the height of game components.voidresizeWidth(double factor) Resizes the width of game components.voidSets the ball object.voidsetHeight(double height) Sets the height of the game screen.voidsetOptions(Options options) Sets the game options.voidsetPlayer1(Player player1) Sets player 1 object.voidsetPlayer2(Player player2) Sets player 2 object.voidsetWidth(double width) Sets the width of the game screen.voidupdateSettings(Options options) Updates the game settings with the provided options.
-
Constructor Details
-
GamePong
public GamePong(int screenWidth, int screenHeight) Constructs a GamePong object with the specified screen dimensions.- Parameters:
screenWidth- The width of the screen.screenHeight- The height of the screen.
-
-
Method Details
-
getBall
Gets the ball object.- Returns:
- The ball object.
-
setBall
Sets the ball object.- Parameters:
ball- The ball object to set.
-
getPlayer1
Gets player 1 object.- Returns:
- Player 1 object.
-
setPlayer1
Sets player 1 object.- Parameters:
player1- The player 1 object to set.
-
getPlayer2
Gets player 2 object.- Returns:
- Player 2 object.
-
setPlayer2
Sets player 2 object.- Parameters:
player2- The player 2 object to set.
-
getOptions
Gets the game options.- Returns:
- The game options.
-
updateSettings
Updates the game settings with the provided options.- Parameters:
options- The options to update.
-
getWinner
public int getWinner()Gets the winner of the game.- Returns:
- 1 if player 1 wins, 2 if player 2 wins, or 0 if there is no winner yet.
-
getScoreToWin
Gets the score required to win the game.- Returns:
- The score to win the game.
-
resizeWidth
public void resizeWidth(double factor) Resizes the width of game components.- Parameters:
factor- The factor by which to resize the width.
-
resizeHeight
public void resizeHeight(double factor) Resizes the height of game components.- Parameters:
factor- The factor by which to resize the height.
-
getWidth
public double getWidth()Gets the width of the game screen.- Returns:
- The width of the game screen.
-
setWidth
public void setWidth(double width) Sets the width of the game screen.- Parameters:
width- The width to set.
-
getHeight
public double getHeight()Gets the height of the game screen.- Returns:
- The height of the game screen.
-
setHeight
public void setHeight(double height) Sets the height of the game screen.- Parameters:
height- The height to set.
-
reset
public void reset()Resets the game state. -
fullReset
public void fullReset()Fully resets the game state, including scores. -
setOptions
Sets the game options.- Parameters:
options- The options to set.
-