Class GameBase

All Implemented Interfaces:
Runnable
Direct Known Subclasses:
Gameplay

public abstract class GameBase extends Object implements Runnable
Main class of game. Responsibility: main loop, game objects and window.
  • Field Details

  • Constructor Details

    • GameBase

      public GameBase()
      Awake of game.
  • Method Details

    • initialize

      public void initialize(GameObject gameObject)
      Initialize gameobject on gameplay.
    • destroy

      public void destroy(GameObject gameObject)
      Destroy gameobject and invoke OnDestroy().
    • addKeyListener

      public void addKeyListener(KeyListener listener)
      Add new key listener.
      Parameters:
      listener - - new key listener.
    • run

      public void run()
      Main loop of game.
      Specified by:
      run in interface Runnable
    • finish

      public void finish()
      Stop and finish main loop.
    • getGameObjects

      public List<GameObject> getGameObjects()
      Get gameobjects in gameplay.
    • getDeltaTime

      protected float getDeltaTime()
      DeltaTime of current frame.
    • openWindow

      protected void openWindow(int widthOfWindow, int heightOfWindow, String title)
      Parameters:
      widthOfWindow -
      heightOfWindow -
      title -
    • awakeScene

      protected void awakeScene()
      Scene awake on open the game.
    • startScene

      protected void startScene()
      Invoke before main loop.
    • updateScene

      protected void updateScene()
      Update scene before game objects.
    • onDestroyScene

      protected void onDestroyScene()
      Destroy scene after game objects.
    • renderScene

      protected void renderScene(Graphics2D g)
      Render scenes before game objects.
      Parameters:
      g - - Graphics2D