package bwyap.gridgame;

import bwyap.gridgame.engine.GameEngineInterface;
import bwyap.gridgame.input.KeyInputController;
import bwyap.gridgame.res.ResourceLoader;

/**
 * A GridGame object holds all game components, 
 * such as the game engine, game window, input controller and resources. 
 * @author bwyap
 *
 */
public class GridGame {
	
	private static final int FPS_RATE = 60;
	
	protected KeyInputController input;
	protected GridGameWindow window;
	protected GameEngineInterface engine;
	protected Thread engineThread;
	protected ResourceLoader res;
	
	/**
	 * Create a new GridGame object and initialize game engine and game window. 
	 */
	public GridGame() {	
		initResource();
		initInput();
		initWindow();
		initEngine();
	}
	
	/**
	 * Initialize the resource loader
	 */
	protected void initResource() {
		res = new ResourceLoader();
		res.init();
		res.load();
	}
	
	/**
	 * Initialize the input controller
	 */
	protected void initInput() {
		input = new KeyInputController();
	}
	
	/**
	 * Initialize the game window
	 */
	protected void initWindow() {
		window = new GridGameWindow("Game Window");
		window.addKeyListener(input);
	}
	
	/**
	 * Initialize the game engine
	 */
	protected void initEngine() {
		engine = new GridGameEngine(FPS_RATE, window);
		engineThread = new Thread(engine);
	}
	
	/**
	 * Start the game engine and show the game window
	 */
	public void start() {
		window.addKeyListener(input);
		window.setVisible(true);
		engineThread.start();
	}
	
}

@@ -773,17 +773,37 @@
 e loader
+ and load resources.
 %0A
-
 %09 */%0A%09pr
@@ -935,16 +935,17 @@
 ntroller
+.
 %0A%09 */%0A%09p
@@ -1040,32 +1040,106 @@
  the game window
+.%0A%09 * This should be done after the input controller has been initialised.
 %0A%09 */%0A%09protected
@@ -1277,16 +1277,80 @@
 e engine
+.%0A%09 * This should be done after the window has been initialized.
 %0A%09 */%0A%09p
@@ -1470,24 +1470,24 @@
 ;%0A%09%7D%0A%09%0A%09/**%0A
-
 %09 * Start th
@@ -1524,16 +1524,17 @@
 e window
+.
 %0A%09 */%0A%09p

Update documentation