Package controller
Class GameController
java.lang.Object
controller.GameController
- All Implemented Interfaces:
Runnable
Controller for the game, handles:
- the creation of the GameStates
- the FPS and UPS re-fresh rate (game loop, updates, and rendering).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the HomeController instance.Returns the MenuController instance.Returns the PlayingModel instance.Returns the PlayingController instance.voidRenders the game (FPS) calling the draw method in the right class based in the game state.voidrun()Overrides run method fromRunnableinterface.voidStarts the game loop.voidupdate()Updates the game (UPS) calling the update method in the right class based in the game state.voidHandles the window focus lost event.
-
Constructor Details
-
GameController
public GameController()Constructs a new GameController.
-
-
Method Details
-
startGameLoop
public void startGameLoop()Starts the game loop. -
update
public void update()Updates the game (UPS) calling the update method in the right class based in the game state. -
render
Renders the game (FPS) calling the draw method in the right class based in the game state.- Parameters:
g- the graphics object
-
run
public void run()Overrides run method fromRunnableinterface.Used to ensure that the game runs at a constant frame rate.
-
windowFocusLost
public void windowFocusLost()Handles the window focus lost event. -
getMenuController
Returns the MenuController instance.- Returns:
- the MenuController instance
-
getPlaying
Returns the PlayingModel instance.- Returns:
- the PlayingModel instance
-
getPlayingController
Returns the PlayingController instance.- Returns:
- the PlayingController instance
-
getHomeController
Returns the HomeController instance.- Returns:
- the HomeController instance
-