package com.betato.duckfall;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;

import com.betato.gamedisplay.GameWindow;
import com.betato.gamedisplay.KeyStates;
import com.betato.gamedisplay.MouseStates;

public class Game extends GameWindow {

	private Entity duck;
	private ArrayList<Entity> bags = new ArrayList<Entity>();
	
	public Game() {
		init(60, 120, "Duck Thing", new Dimension(720, 540), false, false, true);
	}

	@Override
	public void onInit() {
		// Debug images
		BufferedImage texture = null;
		try {
			texture = ImageIO.read(new File("test.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		duck = new Entity(texture, 0, 0);
		bags.add(new Entity(texture, 0, 0));
		bags.get(0).incrementPos(100, 150);
	}

	@Override
	public void onExit() {
		// TODO Auto-generated method stub
	}

	@Override
	public void onUpdate(KeyStates keys, MouseStates mouse, boolean resized) {
		// Follow mouse with duck
		duck.setPos(mouse.pos);
		for (Entity bag : bags){   
			if (bag.isCollidingWith(duck)){
				System.out.println("eh");
			}
		}
	}

	@Override
	public void onRender(Graphics g) {
		// Clear background
		g.setColor(Color.white);
		g.fillRect(0, 0, 720, 540);
		// Draw duck and bags
		duck.draw(g);
		for (Entity bag : bags){
			bag.draw(g);
		}
	}
}

@@ -498,25 +498,80 @@
 );%0A%09
-%0A%09public Game() %7B
+TextureLoader loader;%0A%09%0A%09public Game() %7B%0A%09%09loader = new TextureLoader();
 %0A%09%09i
@@ -688,240 +688,135 @@
 %7B%0A%09%09
-// Debug images%0A%09%09BufferedImage texture = null;%0A%09%09try %7B%0A%09%09%09texture = ImageIO.read(new File(%22test.png%22));%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09duck = new Entity(texture, 0, 0);%0A%09%09bags.add(new Entity(texture, 0, 0
+duck = new Entity(loader.getTexture(%22moneyduck.png%22), 64, 64);%0A%09%09bags.add(new Entity(loader.getTexture(%22whiteduck.png%22), 64, 64
 ));%0A

Make entities use images from TextureLoader