Module project.pong

Class GamePong

java.lang.Object
project.pong.model.GamePong

public class GamePong extends Object
The GamePong class represents the game state and logic of the Pong game.
  • 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

      public Ball getBall()
      Gets the ball object.
      Returns:
      The ball object.
    • setBall

      public void setBall(Ball ball)
      Sets the ball object.
      Parameters:
      ball - The ball object to set.
    • getPlayer1

      public Player getPlayer1()
      Gets player 1 object.
      Returns:
      Player 1 object.
    • setPlayer1

      public void setPlayer1(Player player1)
      Sets player 1 object.
      Parameters:
      player1 - The player 1 object to set.
    • getPlayer2

      public Player getPlayer2()
      Gets player 2 object.
      Returns:
      Player 2 object.
    • setPlayer2

      public void setPlayer2(Player player2)
      Sets player 2 object.
      Parameters:
      player2 - The player 2 object to set.
    • getOptions

      public Options getOptions()
      Gets the game options.
      Returns:
      The game options.
    • updateSettings

      public void updateSettings(Options options)
      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

      public String 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

      public void setOptions(Options options)
      Sets the game options.
      Parameters:
      options - The options to set.