Package role

Class GameController

All Implemented Interfaces:
Configuration, ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public abstract class GameController extends JFrame implements Configuration
The game controller defines the logic of the game. This class should be concretized to implement a game. This abstract class implements the game loop which tracks various entities, their states, and invokes call-backs periodically. This class delivers the functionality expected of a controller in the classic MVC design pattern. The Entity list is kept sorted by layer for rendering occlusion, so that higher layer numbers obscure (are in front of) those that are lower.
Author:
Krish Pillai
See Also:
  • Constructor Details

    • GameController

      public GameController()
      No argument constructor creates a controller supporting the default frame rate.
    • GameController

      public GameController(int rate)
      Constructor for client defined frame rate.
      Parameters:
      rate - The frame rate in frames per second
    • GameController

      public GameController(int rate, Dimension size)
      Constructor for client defined frame rate and screen size.
      Parameters:
      rate - the frame rate in frames per second
      size - the dimensions of the game window
  • Method Details

    • getBackground

      public Color getBackground()
      Overrides:
      getBackground in class Window
      Returns:
      the background
    • setBackground

      public void setBackground(Color background)
      Overrides:
      setBackground in class Frame
      Parameters:
      background - the background to set
    • ignoreKeyStrokesForFrames

      public void ignoreKeyStrokesForFrames(int skip)
      Slows down keyboard polling by skipping poll for the specified number of frames
      Parameters:
      skip - The number of frames to skip polling
    • isOnScreen

      public boolean isOnScreen(EntityModel entity)
      Checks if entity model is on screen (visible)
      Parameters:
      entity - the entity to be checked for
      Returns:
      true if entity is enlisted, false if delisted
    • invokeStateUpdate

      public void invokeStateUpdate()
      Invokes the overridden method updateGameState()