Module project.pong

Class GameController

java.lang.Object
project.pong.controller.GameController

public class GameController extends Object
The GameController class controls the game logic for the Pong game.
  • Constructor Details

    • GameController

      public GameController(MainViewController mainViewController, GameView gameView)
      Constructs a GameController object with the specified parameters.
      Parameters:
      mainViewController - The main view controller.
      gameView - The game view.
  • Method Details

    • getPlayer1Racket

      public Racket getPlayer1Racket()
      Gets the racket of player 1.
      Returns:
      The racket of player 1.
    • getPlayer2Racket

      public Racket getPlayer2Racket()
      Gets the racket of player 2.
      Returns:
      The racket of player 2.
    • getBall

      public Object getBall()
      Gets the ball object.
      Returns:
      The ball object.
    • getPong

      public GamePong getPong()
      Gets the GamePong object.
      Returns:
      The GamePong object.
    • startGame

      public void startGame()
      Starts the game.
    • getGameStarted

      public boolean getGameStarted()
      Gets the game started status.
      Returns:
      True if the game has started, false otherwise.
    • moveBall

      public void moveBall()
      Moves the ball.
    • checkCollision

      public void checkCollision()
      Checks collision between game elements.
    • checkScore

      public void checkScore()
      Checks if either player has reached the winning score and ends the game if so.
    • checkGoal

      public boolean checkGoal()
      Checks if a goal has been scored.
      Returns:
      True if a goal has been scored, false otherwise.
    • togglePause

      public void togglePause()
      Toggles the pause status of the game.