Package base

Class GameLoop

java.lang.Object
base.GameLoop
Direct Known Subclasses:
BreakoutGame, MovingObjectsGame, MultiLevelGame

public class GameLoop extends Object
Main class starting any game, contains main(). Apart from that, this class manages all non-logical functionalities which should be hidden from a game designer like:
  • Setting up windows, panels, buttons, action callbacks, ...
  • Reading keyboard inputs
  • Redrawing game window if necessary
  • managing the game time and calling the appropriate GameObject or Playground methods periodically, at every time step of the game.
There will normally never be a need to modify this file, a designer/game programmer should always redefine the GameObject and Playground classes and implement new functionality there. To make a long story short
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    Pixel width of Game GUI ( above 0)
    static int
    Pixel height of Game GUI (above 0)
  • Constructor Summary

    Constructors
    Constructor
    Description
    constructor which calls defineLevels(), which adds all levels of this game.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    main to start the whole application.
    void
    runGame(String[] args)
    loops over all levels and implements the game loop to update continuously the level during play time

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SIZEX

      public static int SIZEX
      Pixel width of Game GUI ( above 0)
    • SIZEY

      public static int SIZEY
      Pixel height of Game GUI (above 0)
  • Constructor Details

    • GameLoop

      public GameLoop()
      constructor which calls defineLevels(), which adds all levels of this game.
  • Method Details

    • runGame

      public void runGame(String[] args) throws IOException
      loops over all levels and implements the game loop to update continuously the level during play time
      Parameters:
      args - command line arguments forwarded (currently ignored)
      Throws:
      IOException - if hitghscore.txt cannot be written.
    • main

      public static void main(String[] args) throws IOException
      main to start the whole application. It calls. runGame(String[]). (levels are automatically added/loaded by constructor of GameLoop()).
      Parameters:
      args - Java default command line args, forwarded to runGame(String[])
      Throws:
      IOException - in case highscore.txt cannot be written.