Package controller

Class GameController

java.lang.Object
controller.GameController
All Implemented Interfaces:
Runnable

public class GameController extends Object implements Runnable
Controller for the game, handles: - the creation of the GameStates - the FPS and UPS re-fresh rate (game loop, updates, and rendering).
  • 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

      public void render(Graphics g)
      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 from Runnable interface.

      Used to ensure that the game runs at a constant frame rate.

      Specified by:
      run in interface Runnable
    • windowFocusLost

      public void windowFocusLost()
      Handles the window focus lost event.
    • getMenuController

      public MenuController getMenuController()
      Returns the MenuController instance.
      Returns:
      the MenuController instance
    • getPlaying

      public PlayingModel getPlaying()
      Returns the PlayingModel instance.
      Returns:
      the PlayingModel instance
    • getPlayingController

      public PlayingController getPlayingController()
      Returns the PlayingController instance.
      Returns:
      the PlayingController instance
    • getHomeController

      public HomeController getHomeController()
      Returns the HomeController instance.
      Returns:
      the HomeController instance