package com.betato.testgame;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;

import com.betato.gamedisplay.Frame;
import com.betato.gamedisplay.FrameListener;
import com.betato.gamedisplay.GameLoop;
import com.betato.gamedisplay.GameWindow;
import com.betato.gamedisplay.InputListener;

public class TestGame extends GameWindow{
	private static final long serialVersionUID = 1L;
	
	public static void main(String[] args) {
		new TestGame();
	}
	
	int acc;
	int timesUp = 0;
	int timesDown = 0;
	boolean keyState;
	
	public TestGame() {
		Frame frame = new Frame(this, "Title", 300, 300, true);
		start(new GameLoop(60, 120), frame);
	}
	
	@Override
	public void onInit() {
		acc = 100;
		frame.setContentSize(300, 300);
	}

	@Override
	public void onUpdate(InputListener inputListener, FrameListener frameListener, long delta) {
		if (acc < 9999){
			acc++;
		} else {
			acc = 0;
		}
		
		keyState = inputListener.keyState[65];
		if (inputListener.keyUp[KeyEvent.VK_A]) {
			timesUp++;
		}
		if (inputListener.keyDown[KeyEvent.VK_A]) {
			timesDown++;
		}
		for(KeyEvent e : inputListener.keyPresses) { 
			  System.out.println(e.getKeyChar()); 
		}
		for(MouseEvent e : inputListener.mouseClicks) { 
			  System.out.println(e.getButton()); 
		}
	}

	@Override
	public void onRender(Graphics g) {
		g.setColor(Color.white);
		g.fillRect(0, 0, 300, 300);
		g.setColor(Color.black);
		g.drawString("fps:" + fps + " ups:" + ups, 10, 10);
		g.drawString("lalala:" + acc, 10, 30);
		g.drawString("state:" + keyState + " up:" + timesUp + " Down: " + timesDown, 10, 50);
		g.fillOval(200, 200, 8, 8);
	}

	@Override
	public void onExit() {
		System.out.println("exiting");
	}

}

@@ -221,16 +221,52 @@
 stener;%0A
+import com.betato.gamedisplay.Game;%0A
 import c
@@ -411,77 +411,24 @@
 ame 
-extend
+implement
 s Game
-Window%7B%0A%09private static final long serialVersionUID = 1L;
+%7B
 %0A%09%0A%09
@@ -470,16 +470,28 @@
 gs) %7B%0A%09%09
+Game game = 
 new Test
@@ -503,101 +503,47 @@
 );%0A%09
-%7D%0A%09%0A%09int acc;%0A%09int timesUp = 0;%0A%09int timesDown = 0;%0A%09boolean keyState;%0A%09%0A%09public TestGame() %7B
+%09GameLoop loop = new GameLoop(60, 120);
 %0A%09%09F
@@ -569,14 +569,8 @@
 ame(
-this, 
 %22Tit
@@ -586,58 +586,160 @@
  300
-, true);%0A%09%09start(new GameLoop(60, 120), frame);%0A%09%7D
+);%0A%09%09%0A%09%09GameWindow window = new GameWindow(game, loop, frame);%0A%09%09window.start();%0A%09%7D%0A%09%0A%09int acc;%0A%09int timesUp = 0;%0A%09int timesDown = 0;%0A%09boolean keyState;
 %0A%09%0A%09
@@ -765,11 +765,9 @@
 oid 
-onI
+i
 nit(
@@ -787,42 +787,8 @@
 00;%0A
-%09%09frame.setContentSize(300, 300);%0A
 %09%7D%0A%0A
@@ -815,11 +815,9 @@
 oid 
-onU
+u
 pdat
@@ -1340,11 +1340,9 @@
 oid 
-onR
+r
 ende
@@ -1353,16 +1353,34 @@
 aphics g
+, int fps, int ups
 ) %7B%0A%09%09g.
@@ -1704,11 +1704,9 @@
 oid 
-onE
+e
 xit(

Update TestGame to implement Game interface