com.brackeen.javagamebook.test
Class GameCore

java.lang.Object
  extended by com.brackeen.javagamebook.test.GameCore
Direct Known Subclasses:
GameManager

public abstract class GameCore
extends java.lang.Object

Simple abstract class used for testing. Subclasses should implement the draw() method.


Field Summary
protected static int FONT_SIZE
           
private  boolean isRunning
           
private static java.awt.DisplayMode[] POSSIBLE_MODES
           
protected  ScreenManager screen
           
 
Constructor Summary
GameCore()
           
 
Method Summary
abstract  void draw(java.awt.Graphics2D g)
          Draws to the screen.
 void gameLoop()
          Runs through the game loop until stop() is called.
 void init()
          Sets full screen mode and initiates and objects.
 void lazilyExit()
          Exits the VM from a daemon thread.
 java.awt.Image loadImage(java.lang.String fileName)
           
 void run()
          Calls init() and gameLoop()
 void stop()
          Signals the game loop that it's time to quit
 void update(long elapsedTime)
          Updates the state of the game/animation based on the amount of elapsed time that has passed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FONT_SIZE

protected static final int FONT_SIZE
See Also:
Constant Field Values

POSSIBLE_MODES

private static final java.awt.DisplayMode[] POSSIBLE_MODES

isRunning

private boolean isRunning

screen

protected ScreenManager screen
Constructor Detail

GameCore

public GameCore()
Method Detail

stop

public void stop()
Signals the game loop that it's time to quit


run

public void run()
Calls init() and gameLoop()


lazilyExit

public void lazilyExit()
Exits the VM from a daemon thread. The daemon thread waits 2 seconds then calls System.exit(0). Since the VM should exit when only daemon threads are running, this makes sure System.exit(0) is only called if neccesary. It's neccesary if the Java Sound system is running.


init

public void init()
Sets full screen mode and initiates and objects.


loadImage

public java.awt.Image loadImage(java.lang.String fileName)

gameLoop

public void gameLoop()
Runs through the game loop until stop() is called.


update

public void update(long elapsedTime)
Updates the state of the game/animation based on the amount of elapsed time that has passed.


draw

public abstract void draw(java.awt.Graphics2D g)
Draws to the screen. Subclasses must override this method.