java.lang.Object
project.pong.controller.GameController
The GameController class controls the game logic for the Pong game.
-
Constructor Summary
ConstructorsConstructorDescriptionGameController(MainViewController mainViewController, GameView gameView) Constructs a GameController object with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks collision between game elements.booleanChecks if a goal has been scored.voidChecks if either player has reached the winning score and ends the game if so.getBall()Gets the ball object.booleanGets the game started status.Gets the racket of player 1.Gets the racket of player 2.getPong()Gets the GamePong object.voidmoveBall()Moves the ball.voidStarts the game.voidToggles the pause status of the game.
-
Constructor Details
-
GameController
Constructs a GameController object with the specified parameters.- Parameters:
mainViewController- The main view controller.gameView- The game view.
-
-
Method Details
-
getPlayer1Racket
Gets the racket of player 1.- Returns:
- The racket of player 1.
-
getPlayer2Racket
Gets the racket of player 2.- Returns:
- The racket of player 2.
-
getBall
Gets the ball object.- Returns:
- The ball object.
-
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.
-