package com.zealouscoder.ld35;

import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

import com.zealouscoder.ld35.rendering.GamePosition;
import com.zealouscoder.ld35.rendering.GameRenderContext;
import com.zealouscoder.ld35.rendering.SwingRenderer;
import com.zealouscoder.ld35.rendering.swing.GameComponent;

public class Pup8Bit implements GameConstants {

	private static Sprite								avatar;
	private static final Game						game			= new Game(NAME);
	private static GameRenderContext		context		= GameRenderContext.wrap(null);
	private static final MapLoader			mapLoader	= new MapLoader(
			"resources/puplevel1.tmx", context, game);
	private static final SwingRenderer	renderer	= new SwingRenderer();
	private static final InputSystem		input			= new InputSystem(avatar, game);

	static {
		System.setProperty("sun.java2d.opengl", "True");

		InputStream stream = Pup8Bit.class.getClassLoader()
				.getResourceAsStream("puppy.png");
		BufferedImage img;
		try {
			img = ImageIO.read(stream);
			avatar = new Sprite(context.loadImageResource("avatar", img),
					img.getWidth(), img.getHeight(),
					GamePosition.wrap(0, 0, game.getMapViewLayer().forLayer(20)));

		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) throws IOException {
		game.start();
		GameComponent comp = new GameComponent(game, context, renderer);
		JFrame jframe = createWindow(comp);
		mapLoader.load();
		game.add((g, dt) -> {
			if (g.every(FPS, comp)) {
				comp.repaint();
			}
		});
		game.add(avatar);
		input.init(jframe);
		jframe.setVisible(true);
	}

	private static JFrame createWindow(GameComponent comp) {
		JFrame jframe = new JFrame("Pup8Bit");
		jframe.setLayout(new BorderLayout());
		jframe.add(comp);
		jframe.pack();
		jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jframe.setLocationRelativeTo(null);
		jframe.setResizable(false);
		return jframe;
	}

}

@@ -831,84 +831,8 @@
 r();
-%0A%09private static final InputSystem%09%09input%09%09%09= new InputSystem(avatar, game);
 %0A%0A%09s
@@ -1276,16 +1276,94 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09private static final InputSystem%09%09input%09%09%09= new InputSystem(avatar, game);%0A%09%0A
 %09public 

Fix input issue with no reference to avatar.