android.gameengine.icadroids.engine
Class GameLoop

java.lang.Object
  extended by android.gameengine.icadroids.engine.GameLoop
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
UpdateLoop

public class GameLoop
extends java.lang.Object
implements java.lang.Runnable

GameLoop is the Thread that handles the timing of the GameLogic and the drawing.
Generally, game programmers will not make direct use of this class. It handles the internal workings of the GameEngine.

Author:
Edward & Bas

Field Summary
 Canvas c
          Canvas that needs to be drawn
static int MAX_FPS
          Max FPS of this Game
 
Constructor Summary
protected GameLoop(GameEngine ge)
          Intialize the Gameloop
 
Method Summary
 void endDraw(Canvas c)
          Stop Drawing
 long getCurrentSystemTime()
          Get the current system time in milliseconds
 boolean getRunningState()
          Get the running staat of the GameLoop Thread
 void run()
          Main game-loop thread that handles gamelogic and rendering.
 void setRunning(boolean running)
          Start or stop the gameloop from running
 void setView(GameView view)
          Set the view which the GameLoop draws on
 void startDraw()
          Start drawing on the canvas
protected  void updateGame()
          Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_FPS

public static int MAX_FPS
Max FPS of this Game


c

public Canvas c
Canvas that needs to be drawn

Constructor Detail

GameLoop

protected GameLoop(GameEngine ge)
Intialize the Gameloop

Parameters:
ge - GameEngine which the game is currently running on
Method Detail

setRunning

public final void setRunning(boolean running)
Start or stop the gameloop from running

Parameters:
running - true to start, false to stop

getCurrentSystemTime

public final long getCurrentSystemTime()
Get the current system time in milliseconds

Returns:
The current time in milliseconds

run

public void run()
Main game-loop thread that handles gamelogic and rendering.

Specified by:
run in interface java.lang.Runnable

startDraw

public final void startDraw()
Start drawing on the canvas


endDraw

public final void endDraw(Canvas c)
Stop Drawing

Parameters:
c - Canvas that needs to be stop drawing

updateGame

protected void updateGame()
Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio.


setView

public final void setView(GameView view)
Set the view which the GameLoop draws on

Parameters:
view -

getRunningState

public final boolean getRunningState()
Get the running staat of the GameLoop Thread

Returns:
True when running, false when stopped