Main.java - Video 4

Java Game code

Below I show the code in segments (by each class). If you want to learn more about game development, I highly suggest visiting the Youtube channel for IndieDeveloper as most of this is his work. However I will do my best to explain it later.

Update: Indie Developer is no longer supporting Java tutorials so I have replaced the missing video with one I began a while ago on my channel. My apologies, but I can't control what other people decide. He just felt it wasn't going anywhere and is a waste of time. Honestly, if I believed that about the Commodore 64 or Atari this website would be pointless.

Channel for IndieDeveloper latest video (54)
- Video 4
GameWindow.java
 
package dungeonmain;

import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

import javax.swing.JFrame;

//Tutorial 4: 4:18
public class GameWindow extends JFrame{
	
	private static final long serialVersionUID = -7832916794747021154L;
	boolean fse = false;
	int fsm = 0;	// full screen mode
	GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0];

	public GameWindow(String title, int width, int height) {
		setTitle(title);
		//setSize(width, height);
		setSize(width, height);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
		setResizable(false);
	}
	
	private void setfullscreen() {
		switch(fsm) {
		case 0:
			System.out.println("No full screen");
			break;
		case 1:
			//setUndecorated(true);
			setExtendedState(JFrame.MAXIMIZED_BOTH);
			break;
		case 2:
			setUndecorated(true);
			device.setFullScreenWindow(this);
			break;
		}
	}
	
	public void setFullscreen(int fsnm) {
		fse = true;
		if (fsm <=2) {
			this.fsm = fsnm;
			setfullscreen();
		} else {
			System.err.println("Error " + fsnm + " is not supported!");
		}
	}
}
Main.java - Video 4
 

package dungeonmain;

import gameloop.GameLoop;
import generator.World;

import java.applet.Applet;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Toolkit;

import moveableobjects.Player;
import dungeonmain.GameWindow;
import dungeonmain.SpriteSheet;
import managers.MouseManager;

public class Main extends Applet implements Runnable {

	Thread thread = new Thread(this);
	boolean running=true;
	Player p;
	
	public static GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
	public static int width = gd.getDisplayMode().getWidth();
	public static int height = gd.getDisplayMode().getHeight();
	
	static SpriteSheet blocks = new SpriteSheet(); // instantiate BufferedImage (class)
	
	public Main() {
	}
	
	public void init() {
		GameWindow frame = new GameWindow("TheDlooter", width, height);
		frame.setFullscreen(1);
		Toolkit toolkit = Toolkit.getDefaultToolkit();
		Cursor cursor = toolkit.createCustomCursor(toolkit.getImage(""), new Point(0, 0), "Cursor");
		frame.setCursor(cursor);
		
		frame.addMouseListener(new MouseManager());
		frame.addMouseMotionListener(new MouseManager());
		frame.addMouseWheelListener(new MouseManager());
		
		frame.addKeyListener(new Player());
		frame.add(new GameLoop(width,height));
		frame.setVisible(true);
	}
	
	public void run() {
		while (running) 
		{
			World world = null;
			p.start();
			try {
				Thread.sleep(20);
			} catch (InterruptedException e) {
				System.out.print("An error has occured. Please restart the game.");
			}
		}
	}
	
	public static void main(String[] args) {
		GameWindow frame = new GameWindow("TheDlooter", width, height);
		frame.setFullscreen(1);
		Toolkit toolkit = Toolkit.getDefaultToolkit();
		Cursor cursor = toolkit.createCustomCursor(toolkit.getImage(""), new Point(0, 0), "Cursor");
		frame.setCursor(cursor);
		
		frame.addMouseListener(new MouseManager());
		frame.addMouseMotionListener(new MouseManager());
		frame.addMouseWheelListener(new MouseManager());
		
		frame.addKeyListener(new Player());
		frame.add(new GameLoop(width,height));
		frame.setVisible(true);
	}
}
loadImageFrom.java - Video 7
 
package dungeonmain;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;

// Tutorial 7: 4:50
public class loadImageFrom {

	// Load different images from different classes
	public static BufferedImage LoadImageFrom(Class classfile, String path) {
		URL url = classfile.getResource(path);
		BufferedImage img = null;
		
		try{
			img = ImageIO.read(url);
		} catch(IOException e) {
			e.printStackTrace();
		}
		return img;
	}
}

SpriteSheet.java - Video 7
 
package dungeonmain;

import java.awt.image.BufferedImage;
import java.util.Set;

// Tutorial 7: 8:12
@SuppressWarnings("unused")
public class SpriteSheet {

	private BufferedImage spriteSheet;
	
	public SpriteSheet() {
		
	}
	
	public void setSpriteSheet(BufferedImage spriteSheet) {
		this.spriteSheet = spriteSheet;
	}
	
	public BufferedImage getTile(int xTile, int yTile, int width, int height) {
		BufferedImage sprite = spriteSheet.getSubimage(xTile, yTile, width, height);
		return sprite;
	}
	
	public BufferedImage getTile2(int xTile, int yTile, int width, int height, int i, int j, Object object) {
		BufferedImage sprite = spriteSheet.getSubimage(xTile, yTile, width, height);
		return sprite;
	}
}
Vector2F.java - Video 8
 
package dungeonmain;

import java.util.ArrayList;

// Tutorial 8
// Java 2D Game Development Tutorial [8] For Beginners - Vector2F (GOP) 

// www.mathisfun.com/algebra/vectors.html
public class Vector2F {

	public float xpos;
	public float ypos;
	
	public static float worldXpos;
	public static float worldYpos;
	
	// zero out xpos, ypos (as float)
	public Vector2F() {
		this.xpos = 0.0f;
		this.ypos = 0.0f;
	}
	
	public Vector2F(Integer integer, ArrayList diamondPos2) {
		this.xpos = 0.0f;
		this.ypos = 0.0f;
	}
	
	public Vector2F(float xpos, float ypos) {
		this.xpos = xpos;
		this.ypos = ypos;
	}

	// zero out xpos, ypos (as decimal)
	public static Vector2F zero() {
		return new Vector2F(0,0);
	}
	
	// normalize direction of shooting is bullet
	// another bullet can change direction if shot 
	public void normalize() {
		double length = Math.sqrt(xpos * xpos + ypos * ypos);
		
		if (length != 0.0) {
			float s = 1.0f / (float) length;
			xpos = xpos * s;
			ypos = ypos * s;
		}
	}
	
	public Vector2F getScreenLocation() {
		return new Vector2F(xpos, ypos);
	}
	
	public Vector2F getWorldLocation() {
		return new Vector2F(xpos - worldXpos, ypos - worldYpos);
	}
	
	// Check if vectors are equal
	public boolean equals(Vector2F vec) {
		// return if 2 vectors are at the same location
		return (this.xpos == vec.xpos && this.ypos == vec.ypos);
	}
	
	// Create a copy of vector to return
	public Vector2F copy(Vector2F vec) {
		xpos = vec.xpos;
		ypos = vec.ypos;
		return new Vector2F(xpos, ypos);
	}
	
	// physics (add new vector to current vector)
	public Vector2F add(Vector2F vec) {
		xpos = xpos + vec.xpos;
		ypos = ypos + vec.ypos;
		return new Vector2F(xpos, ypos);
	}
	
	public static void setWorldVariables(float wx, float wy) {
		worldXpos = wx;
		worldYpos = wy;
	}
	
	// check if player is close to an object
	public static double getDistanceOnScreen(Vector2F vec1, Vector2F vec2) {
		float v1 = vec1.xpos - vec2.xpos;	// player position
		float v2 = vec1.ypos - vec2.ypos;	// object position
		return Math.sqrt(v1 * v1 + v2 * v2);
	}
	
	public double getDistanceBetweenWorldVectors(Vector2F vec) {
		float dx = Math.abs(getWorldLocation().xpos -  vec.getWorldLocation().xpos);
		float dy = Math.abs(getWorldLocation().ypos -  vec.getWorldLocation().ypos);
		return Math.abs(dx * dx - dy * dy);
	}
}

IDGameLoop.java - Video 9
 

package dungeonmain;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

// Tutorial 9 0:49
public class IDGameLoop extends JPanel implements Runnable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6415945024962927674L;
	private Thread thread;
	private boolean running; // initialize sets everything to running
	
	@SuppressWarnings("unused")
	private int fps;	// frames per second
	@SuppressWarnings("unused")
	private int tps;	// ticks per second
	
	private int width;
	private int height;
	
	public Graphics2D graphics2D;
	private BufferedImage img;
	
	public static double currFPS = 120D;
	
	public IDGameLoop(int width, int height) {
		this.width = width;
		this.height = height;
		
		setPreferredSize(new Dimension(width, height));  // from JPanel
		setFocusable(false);
		requestFocus();
	}
	
	// This runs one time before the class starts
	@Override
	public void addNotify() {
		super.addNotify();
		
		// if  the thread doesn't exist
		if (thread == null) {
			thread = new Thread(this);
			thread.start();	
		}
	}
	
	// **************** Actual Game Loop ************************
	@Override
	public void run() {
		
		/*INIT*/
		init(); // initialize all game objects
		
		// return most precise time in nanoseconds
		long lastTime = System.nanoTime(); // return time in nanoseconds
		double nsPerTick = 1000000000D / currFPS;
		int frames = 0;
		int ticks = 0;
		// return current time in milliseconds
		long lastTimer = System.currentTimeMillis();
		double deltaTime = 0; // speed up game if it is slow
		
		while (running == true) {
			long now = System.nanoTime();
			deltaTime += (now - lastTime) / nsPerTick;
			lastTime = now;
			boolean shouldRender = false;
			
			while(deltaTime >= 1) {
				ticks++;
				/*TICK + DeltaTime*/
				tick(deltaTime); // update game/speed up physics
				deltaTime -= 1;
				shouldRender = true;
				
				if (shouldRender == true) {
					frames++;
					/*RENDER*/
					render(); // render everything to draw
				}
				
				try {Thread.sleep(2);} catch (InterruptedException e) {e.printStackTrace();}
				
				if (System.currentTimeMillis() - lastTimer >= 1000) {
					lastTime += 1000;
					tps = frames;
					fps = ticks;
					frames = 0;
					ticks = 0;
				}
			}
		}
	}
	
	public void init() {
		img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		graphics2D = (Graphics2D) img.getGraphics();
		running = true;
	}

	public void render() {
		graphics2D.clearRect(0, 0, width, height); // clear the screen
	}

	public void tick(double deltaTime) {	
	}
	
	public void clear() {
		Graphics g2 = getGraphics();
		if (img != null) {	// if image exists
			g2.drawImage(img, 0, 0, null);
		}
		g2.dispose();
	}

}
GameState.java - Video 10
 
package gamestate;

import java.awt.Graphics2D;

// Tutorial 10: 5:15
public abstract class GameState {

	private static final GameState MENU = null;
	protected GameStateManager gsm;
	public static GameStateSwitch gameState = GameStateSwitch.MENU;
	
	public enum GameStateSwitch {
		MENU, INTRO, PLAY, END
	}
	
	public GameState(GameStateManager gsm) {
		this.gsm = gsm;
		//init();
	}
	
	public abstract void init();
	public abstract void tick(double deltaTime);
	public abstract void render(Graphics2D g);
	
	public static GameStateSwitch getState() {
		return gameState;
	}

}
GameStateManager.java - Video 10
 
package gamestate;
package gamestate;

import java.awt.Graphics2D;

import gamestates.DungeonLevelLoader;
import gamestates.MenuState;

import java.util.Stack;

import javax.swing.JApplet;

// Tutorial 10: 5:42
@SuppressWarnings("unused")
public class GameStateManager {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7061722419653715091L;
	// stack allows you to push stuff on top of the stack
	public static Stack states;
	
	public GameStateManager() {
		states = new Stack();
		states.push(new MenuState(this));
	}
	
	public void tick(double deltaTime) {
		states.peek().tick(deltaTime);
	}
	
	public void render(Graphics2D g) {
		states.peek().render(g);
	}

	public void init() {
		states.peek().init();
	}
}
GameLoop.java - Video 11
 
package gameloop;

import gamestate.GameStateManager;

import java.awt.Component;

import dungeonmain.Assets;
import dungeonmain.IDGameLoop;
import dungeonmain.Vector2F;

// Tutorial 11: 6:31
@SuppressWarnings("unused")
public class GameLoop extends IDGameLoop {

	private static final long serialVersionUID = 8858679985546626864L;
	GameStateManager gsm;
	public static Assets assets = new Assets();
	
	public GameLoop(int fwidth, int fheight) {
		super(fwidth, fheight);
	}
	
	
	@Override
	public void init() {
		assets.init();
		gsm = new GameStateManager();
		gsm.init();
		super.init();
	}

	@Override
	public void tick(double deltaTime) {
		super.tick(deltaTime);
		gsm.tick(deltaTime);
	}

	@Override
	public void render() {
		super.render();
		gsm.render(graphics2D);
		clear();	// clear the screen
	}
	
	@Override
	public void clear() {
		super.clear();
	}
}
DungeonLevelLoader.java - Video 11
 
package gamestates;

import items.GameItems;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;

import audio.AudioPlayerExample1;
import sounds.SFXAudio;
import status.HealthStatus;
import managers.MouseManager;
import moveableobjects.Player;
import dungeonmain.Animator;
import dungeonmain.Assets;
import dungeonmain.Check;
import dungeonmain.Main;
import dungeonmain.SpriteSheet;
import dungeonmain.Vector2F;
import dungeonmain.loadImageFrom;
import gamestate.GameState;
import gamestate.GameStateManager;
import generator.Block;
import generator.TileManager;
import generator.World;
import generator.Block.BlockType;

// Tutorial 11: 6:30
@SuppressWarnings("unused")
public class DungeonLevelLoader extends GameState {
	
	public static World world;
	public TileManager tiles;
	public Check evaluate;
	public Player playerupd;
	public HealthStatus status;
	GameStateButton startGame;
	GameStateManager gsm;
	MouseManager mm;
	public GameItems gmitems;
	public static int HEALTH = 100;
	public static boolean death;
	
	private SFXAudio gamemusic;
	private String worldName;
	private String map_name;
	private boolean WorldInitialized;
	//Map map;
	SpriteSheet test = new SpriteSheet();
	
	public static int clock=0;
	public static int count;
	public static int diamondflash=0;
	public static int objmove;
	public static int temp_objmove;
	private int world_width;
	private int world_height;
	private int blockSize = 128;
	private boolean hasSizeWaterAnimation = false;
	public BufferedImage map;
	
	private ArrayList listIdle;
	Animator ani_idle;
	private static long animationSpeed = 1;
	Vector2F pos;
	
	public static CopyOnWriteArrayList blocks = new CopyOnWriteArrayList();
	public static CopyOnWriteArrayList load_blocks = new CopyOnWriteArrayList();
	
	public void DungeonLevelLoader(String worldName, String map_name) {
		this.worldName = worldName;
		this.map_name = map_name;
	}
	
	public DungeonLevelLoader(GameStateManager gsm) {
		super(gsm);
	}
	
	// gsm.states.push(new DungeonLevelLoader(gsm, wn, mn));
	public DungeonLevelLoader(GameStateManager gsm, String worldName, String map_name) {
		super(gsm);
		this.worldName = worldName;
		this.map_name = map_name;
	}

	@Override
	public void init() {
		//tiles = new TileManager();
		listIdle = new ArrayList();
		
		listIdle.add(Assets.player.getTile(3,66,15,15));
		listIdle.add(Assets.player.getTile(3,66,15,15));
		listIdle.add(Assets.player.getTile(3,66,15,15));
		listIdle.add(Assets.player.getTile(3,66,15,15));
		
		ani_idle = new Animator(listIdle);
		ani_idle.setSpeed(animationSpeed);
		ani_idle.play();
		
		if (worldName == null) {
			worldName = "NULL";
			map_name = "map5";
		}
		
		if (!WorldInitialized) {
			world = new World(worldName, this, gsm);
			world.setSize(100,100); // 45,2
			world.setWorldSpawn(22,16); // 1,10, 86,3, 28,9, 22, 7
			world.addPlayer(new Player());
			world.init();
			world.generate(map_name);	
			WorldInitialized=true;
		}
		else {
			world = new World(worldName, this, gsm);
			world.setSize(100,100); // 45,2
			world.addPlayer(new Player());
			world.init();
			world.generate(map_name);		
		}
		
		//gamemusic = new SFXAudio("/Music/level1-1.mp3");
		//gamemusic.play();
		
        //String audioFilePath = "C:/Audio/cry.mp3";
        //AudioPlayerExample1 player = new AudioPlayerExample1();
        //player.play(audioFilePath);
        
        
/*        final File audioFile = new File("C:/Audio/cry.mp3");
        InputStream in = null;
		try {
			in = new FileInputStream( audioFile );
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        try {
			final AudioInputStream ais = AudioSystem.getAudioInputStream( in );
		} catch (UnsupportedAudioFileException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
        
		if (death) {
			startGame = new GameStateButton(30, 70, new DungeonLevelLoader(gsm), gsm, "StartGame");
		}

		
		//test.setSpriteSheet(loadImageFrom.LoadImageFrom(Main.class, "spritesheetC.png"));
	//	map = new Map();
	//	map.init();
	}

	@Override
	public void tick(double deltaTime) {
		
		for(Block block : blocks) {
			block.tick(deltaTime);
 
			
			if (clock == 0) {
				tiles.blocks.add(new Block(new Vector2F(2560,2688), BlockType.CHEST_1).isTreasureChest(false));
			}
			else if (clock == 1) {			
				tiles.blocks.add(new Block(new Vector2F(2688,2688), BlockType.DIAMOND_1).isTreasureChest(false));
			}
			else if (clock == 2) {	
				tiles.blocks.add(new Block(new Vector2F(2944,2688), BlockType.DOOR_1).isTreasureChest(false));
			}
			
				
				if (!load_blocks.contains(block)) {
					load_blocks.add(block);
					tiles.blocks.add(new Block(new Vector2F(2560,2688), BlockType.CHEST_1).isTreasureChest(false));
				}
				else {
					if(load_blocks.contains(block)) {
						load_blocks.remove(block);
					}
					block.setAlive(false);
				}
		}
		
		if(world.hasGenerated()) {
			world.tick(deltaTime);
			
/*		if (!blocks.isEmpty()) {
			for (Block block : blocks) {
				block.tick(deltaTime);
				//if (block.blocktype.WATERANIMATION1 == null) {
				//if (!load_blocks.contains(block)) {
					//tiles.blocks.add(new Block(new Vector2F(), BlockType.DIAMOND_1).isTreasureChest(false));
					//tiles.blocks.add(new Block(new Vector2F(2560,2688), BlockType.WATERANIMATION1).isTreasureChest(false));
				
					if (clock == 0) {
						tiles.blocks.add(new Block(new Vector2F(2688,2688), BlockType.CHEST_1).isTreasureChest(false));
					}
					else if (clock == 1) {			
						tiles.blocks.add(new Block(new Vector2F(2816,2688), BlockType.WATERANIMATION2).isTreasureChest(false));
					}
					else if (clock == 2) {	
						tiles.blocks.add(new Block(new Vector2F(2944,2688), BlockType.WATERANIMATION3).isTreasureChest(false));
					}
				//}
			}
		}*/
			
			
			
			
			clock++;
			if (clock > 3) clock=0;
			diamondflash++;
			if (diamondflash > 10) diamondflash=0;
			temp_objmove = objmove;
			objmove+=128;
			
			if (death) {
				//mm.tick();
				//startGame.tick();
			}
		}
	}

	@Override
	public void render(Graphics2D g) {
		for(Block block : tiles.blocks) {
			block.render(g);
		}
		
		if(world.hasGenerated()) {
			world.render(g);
			//status.bitten = evaluate.bites;
			status = new HealthStatus();
			status.Healthcondition(evaluate.bites);
			
			
			g.drawImage(Assets.getBase_1(), 30, 2, 64, 64, null);
			g.drawImage(Assets.getHealth(), 30, 2, 64, 64, null);
			
			g.drawImage(Assets.getBase_1(), 94, 2, 64, 64, null);
			g.drawImage(Assets.getHealth(), 94, 2, 64, 64, null);
			
			g.drawImage(Assets.getBase_1(), 158, 2, 64, 64, null);
			g.drawImage(Assets.getHealth(), 158, 2, 64, 64, null);
			g.setColor(Color.white);
			g.drawString("Player Status: ", 30, 110);
			g.setColor(Color.green);
			g.drawString(status.getHealthStatus(), 200, 110);
			g.setColor(Color.white);
			g.drawString("Treasure chest item: ", 30, 140);
			g.setColor(Color.green);
			g.drawString(gmitems.getItemFound(), 280, 140);
			g.setColor(Color.white);
			g.drawString("Keys: " + evaluate.getKey(), 30, 170);
			//g.drawString("Map X: " + world.map_pos.xpos, 30, 200);
			//g.drawString("Map Y: " + world.map_pos.ypos, 30, 230);
			//g.drawString("Ladder: " + evaluate.getLadderStatus(), 30, 160);
			//g.drawString("BoostMaxRange: " + playerupd.getBoost(), 30, 200);
			//g.drawString("Armor: " + evaluate.getArmor(), 30, 320);
			//g.drawString("CountBoost: " + playerupd.getCountBoost(), 30, 230);
			g.setColor(Color.yellow);
			g.drawString("Score: " + evaluate.getGameScore(), 240, 30);
			g.drawString("Health: ", 240, 70);
			//g.drawImage(Assets.getwaterAnimation_1(), 30, 300, 64, 64, null);
			
			if (HEALTH < 1) {
				death = true;
				//gsm = new GameStateManager();
				gsm.states.get(0);
				//startGame.render(g);
				//mm.render(g);
				g.setColor(Color.PINK);
				g.drawString("You drowned!!", 400, 10);
			}
			
			if (HEALTH > 40) {
				g.setColor(Color.GREEN);
			}
			else
				g.setColor(Color.RED);
			
			g.fillRect(380, 40,  HEALTH * 2, 32);
			g.setColor(Color.BLUE);
			g.drawRect(380, 40,  200, 32);
		}
		
		
		
		map = null;
		//tilemapPos = new int[410];
		
	if (!hasSizeWaterAnimation) {
			try {
				map = loadImageFrom.LoadImageFrom(Main.class,"map5.png");
				
			} catch (Exception e) {
				
			}
			
		//if (block.blocktype.SPIDER_1 != null)
			
			
		//for (int x=0; x < 100; x++) {
			
			for(Block block : blocks) {
				block.render(g);
			//for (int y=0; y < 100; y++) {
				//int waterPosx = waterPos[i];
				//int waterPosy = waterPos[i+1];
				//int col = map.getRGB(x, y);
				//int col2 = map.getRGB(x, y);
				
				//System.out.println("x+objmove,y" + x + "," + y + "**" + (col & 0xFFFFFF));
				
				//0x0046FF, 0x00FFFF, 0026FF
				//if (col!=0x0046FF && col!=0x00FFFF && col!=0x0026FF) {
				//	continue;
				//}
						
				//switch (col & 0xFFFFFF) {
				//switchTile(spiderMatchx, spiderMatchy, clock);
					
			//if (tiles.blocks != null) {
				//switchTile(spiderMatchx, spiderMatchy, clock);
				
				//g.drawImage(ani_left.sprite, (int)pos.xpos - width / 2, ((int)pos.ypos - height) + gravity, width * scale, height * scale, null);
				
				//case 0x0046FF:			
					if (clock == 0) {
						tiles.blocks.add(new Block(new Vector2F(2560,2688), BlockType.CHEST_1).isTreasureChest(false));
						//g.drawImage(ani_idle.sprite, (int) pos.getWorldLocation().xpos + blockSize / 2, (int) pos.getWorldLocation().ypos + blockSize /2, null);
						
						
						//System.out.println("ani_idle.sprite:" + ani_idle.sprite);
						
						
						//g.drawImage(Assets.getDiamond_1(), 600, 30, 40,40, null); // small game character at top
						Vector2F pos2 = new Vector2F();
						//g.drawImage(Assets.getChest_1(), (int) pos2.getWorldLocation().xpos, (int) pos2.getWorldLocation().ypos, blockSize,blockSize, null);
						
						
						//g.drawImage(ani_idle.sprite, (int)pos.xpos - width / 2, ((int)pos.ypos - height), width * scale, height * scale, null);
						
						//g.drawImage(ani_idle.sprite, (int) pos.getWorldLocation().xpos,100, 111,1111, null);
						//g.drawImage(Assets.getwaterAnimation_1(), 30, 300, 64, 64, null);
						//ani_idle.update(System.currentTimeMillis());
					}
					else if (clock == 1) {			
						tiles.blocks.add(new Block(new Vector2F(2688,2688), BlockType.WATERANIMATION2).isTreasureChest(false));
						//g.drawImage(ani_idle.sprite, (int) pos.getWorldLocation().xpos + blockSize / 2, (int) pos.getWorldLocation().ypos + blockSize /2, null);
						//g.drawImage(Assets.getwaterAnimation_2(), 30, 300, 64, 64, null);
					}
					else if (clock == 2) {	
						tiles.blocks.add(new Block(new Vector2F(2944,2688), BlockType.WATERANIMATION3).isTreasureChest(false));
						//g.drawImage(ani_idle.sprite, (int) pos.getWorldLocation().xpos + blockSize / 2, (int) pos.getWorldLocation().ypos + blockSize /2, null);
						//g.drawImage(Assets.getwaterAnimation_3(), 30, 300, 64, 64, null);
					}
					//break;
				//case 0x00466E:	
					//if (clock == 0) {
					//	tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATERFALL1).isTreasureChest(false));
					//}
					//else if (clock == 1) {			
					//}
					//else if (clock == 2) {	
					//	tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATERFALL2).isTreasureChest(false));
					//}
				//break;
/*				case 0x00FFFF:	// diamond: cyan color
					if (!Check.ImpactBlock(
							new Point((int) (pos.xpos + world.map_pos.xpos + width + speed), 
									  (int) (pos.ypos + world.map_pos.ypos)),
									  
							new Point((int) (pos.xpos + world.map_pos.xpos + width + speed),
									  (int) (pos.ypos + world.map_pos.ypos + height)))) {
						
					}
					
					if ((col2-count & 0xFFFFFF) == 0xFF00DC) {
						System.out.println("Object hit a wall");
					}
					
					
					//tiles.blocks.add(new Block(new Vector2F(x*blockSize+objmove, y*blockSize), BlockType.DIAMOND_1).isTreasureChest(false));
					//tiles.blocks.add(new Block(new Vector2F(x*blockSize+temp_objmove, y*blockSize), BlockType.FLOOR_1).isTreasureChest(false));
					count++;
					
					//tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_1).isDiamondRing(true));
					//System.out.println("Diamond:" + new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_2));
					
					if (diamondflash == 0) {
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_1).isTreasureChest(false));
						//tiles.blocks.add(new Block(new Vector2F(diamondPos2.get(i),diamondPos2.get(i+1)), BlockType.DIAMOND_1).isTreasureChest(false));
					}
					else if (diamondflash == 10) {	
						
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_2).isTreasureChest(false));
						//tiles.blocks.add(new Block(new Vector2F(diamondPos2.get(i),diamondPos2.get(i+1)), BlockType.DIAMOND_2).isTreasureChest(false));
					}
					//else if (diamondflash == 20) {	
					//	tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMONDBLACKTILE).isTreasureChest(false));
						//tiles.blocks.add(new Block(new Vector2F(diamondPos2.get(i),diamondPos2.get(i+1)), BlockType.DIAMONDBLACKTILE).isTreasureChest(false));
					//}
					else if (diamondflash == 30) {
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_2).isTreasureChest(false));
						//tiles.blocks.add(new Block(new Vector2F(diamondPos2.get(i),diamondPos2.get(i+1)), BlockType.DIAMOND_).isTreasureChest(false));
					}					
					break;
				case 0x0026FF:	
				// Enemies: dark blue
					if (clock == 0) {
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.BLANK).isTreasureChest(false));
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SPIDER_3).isTreasureChest(false));
					}
					else if (clock == 5) {
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.BLANK).isTreasureChest(false));
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SPIDER_2).isTreasureChest(false));
					}
					else if (clock == 10) {
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.BLANK).isTreasureChest(false));
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SPIDER_1).isTreasureChest(false));
					}
				break;*/
				//}
				//hasSizeWaterAnimation = true;
			//}
			}
		//}
	}
	}
	
	public void animateScenes() {

	}
	
	public CopyOnWriteArrayList getBlocks() {
		return blocks;
	}
	
	public CopyOnWriteArrayList getLoadedBlocks() {
		return load_blocks;
	}
}
Assets.java - Video 14
package dungeonmain;

import java.awt.image.BufferedImage;

// Tutorial 14: 0:40
// Java 2D Game Development Tutorial [14] For Beginners - Tilemap and Blocks
public class Assets {
	
	public static SpriteSheet blocks = new SpriteSheet();
	public static SpriteSheet player = new SpriteSheet();
	public static SpriteSheet eventObject = new SpriteSheet();
	public static BufferedImage enemy_1;
	// Stats
	public static BufferedImage blank;
	public static BufferedImage health;
	// Stars
	public static BufferedImage stars;
	public static BufferedImage stalagmite_stars;
	public static BufferedImage distant_star;
	public static BufferedImage blacktile;
	public static BufferedImage sky;
	public static BufferedImage skyclouds;
	public static BufferedImage sun;
	public static BufferedImage skyground;
	public static BufferedImage floor_1;
	public static BufferedImage base_1;
	public static BufferedImage water_1;
	public static BufferedImage water_2;
	public static BufferedImage waterbase;
	//Animation
	public static BufferedImage wateranimation1;
	public static BufferedImage wateranimation2;
	public static BufferedImage wateranimation3;
	public static BufferedImage wateranimation4;
	
	public static BufferedImage waterfalltop;
	public static BufferedImage waterfall1;
	public static BufferedImage waterfall2;
	public static BufferedImage waterfallbottom;
	// Game won item
	public static BufferedImage teleporter_1;
	public static BufferedImage teleporter_2;
	public static BufferedImage teleporter_3;
	// Mountains
	public static BufferedImage mountains_1;
	public static BufferedImage mountains_2;
	public static BufferedImage mountainsleft;
	public static BufferedImage mountainsbase;
	public static BufferedImage mountainsright;
	public static BufferedImage mountainsdistantright;
	public static BufferedImage mountainsdistantleft;
	
	// Walls
	public static BufferedImage stone_1;
	public static BufferedImage stone_2;
	public static BufferedImage stone_3;
	public static BufferedImage stalagmite;
	public static BufferedImage wall_1;
	public static BufferedImage wallbottom;
	public static BufferedImage pillar_1;
	// Ladders
	public static BufferedImage ladder_1;
	public static BufferedImage ladder_stars;
	public static BufferedImage ladderwall;
	public static BufferedImage ladderwall2;
	public static BufferedImage ladderinwater;
	public static BufferedImage laddertop;
	public static BufferedImage laddertopblacktile;
	// Game items
	public static BufferedImage chest_1;
	public static BufferedImage chestblacktile;
	public static BufferedImage diamond_1;
	public static BufferedImage diamond_2;
	public static BufferedImage diamondblacktile;
	// Doors
	public static BufferedImage door_1;
	public static BufferedImage door_2;
	// Keys
	public static BufferedImage key_1;
	public static BufferedImage key_2;
	// Enemies
	public static BufferedImage spider_1;
	public static BufferedImage spider_2;
	public static BufferedImage spider_3;
	// Mouse/extras
	private static BufferedImage mouse_pressed;
	private static BufferedImage mouse_unpressed;
	
	private static BufferedImage button_heldover;
	private static BufferedImage button_notover;
	
	private static boolean drawOnce;
	
	public void init() {
		//if (!drawOnce) {
		
		blocks.setSpriteSheet(loadImageFrom.LoadImageFrom(Main.class, "spritesheetC.png"));
		//player.setSpriteSheet(loadImageFrom.LoadImageFrom(Main.class, "PlayerSheet.png"));
		player.setSpriteSheet(loadImageFrom.LoadImageFrom(Main.class, "spritesheetcharmask2.png"));
		//eventObject.setSpriteSheet(loadImageFrom.LoadImageFrom(Main.class, "eventObjects.png"));
		
		// location (Y): Be sure to press F5 (refresh) after drawing new sprites
		// X = 2, 18, 34, 50, 66, 83, 99, 115, 131, 147, 163, 179, 195, 211
		// 2 = 1st row
		// 18 = 2nd row
		// 34 = 3rd row
		// 50 = 4th row
		// 67 = 5th row
		// 82 = 6th row
		
		// Stats (blank, health)
		// Not all are listed here because they are only
		// stationary objects (not in game).
		blank = player.getTile(115, 2, 14, 15);
		// Starry skies/sky/background
		stars = blocks.getTile(131, 18, 15, 15);
		stalagmite_stars = blocks.getTile(131, 34, 15, 15);
		distant_star = blocks.getTile(179, 18, 15, 15);
		blacktile = blocks.getTile(147, 34, 15, 15);
		sky = blocks.getTile(147, 50, 15, 15);
		skyground = blocks.getTile(163, 34, 15, 15);
		skyclouds = blocks.getTile(163, 50, 15, 15);
		sun = blocks.getTile(115, 66, 15, 15);
		floor_1 = blocks.getTile(35, 2, 15, 15);
		base_1 = blocks.getTile(83, 34, 15, 15);
		water_1 = blocks.getTile(131, 67, 15, 15);
		water_2 = blocks.getTile(147, 67, 15, 15);
		waterbase = blocks.getTile(131, 82, 15, 15);
		//Animation *******************************
		wateranimation1 = blocks.getTile(131,99,14,15);
		wateranimation2 = blocks.getTile(147,99,14,15);
		wateranimation3 = blocks.getTile(163,99,14,15);
		// waterfalls
		waterfalltop = blocks.getTile(195,66,14,15);
		waterfall1 = blocks.getTile(195,82,15,15);
		waterfall2 = blocks.getTile(211,66,15,15);
		waterfallbottom = blocks.getTile(211,82,15,15);
		
		//wateranimation4 = blocks.getTile(179,99,15,15);
		// Game won item
		teleporter_1 = blocks.getTile(83, 98, 15, 16);
		teleporter_2 = blocks.getTile(99, 98, 15, 16);
		teleporter_3 = blocks.getTile(115, 98, 15, 16);
		// Mountains
		mountains_1 = blocks.getTile(67, 66, 15, 15);
		mountains_2 = blocks.getTile(83, 66, 15, 15);
		mountainsleft = blocks.getTile(67, 82, 15, 15);
		mountainsbase = blocks.getTile(83, 81, 15, 15);
		mountainsright = blocks.getTile(99, 82, 15, 15);
		mountainsdistantright = blocks.getTile(179, 98, 15, 15);
		mountainsdistantleft = blocks.getTile(195, 98, 15, 15);
		// Walls
		stone_1 = blocks.getTile(0, 0, 16, 16); 
		stone_2 = blocks.getTile(67, 18, 15, 15); 
		stone_3 = blocks.getTile(19, 34, 15, 15); 
		stalagmite = blocks.getTile(67, 34, 15, 15);
		wall_1 = blocks.getTile(51, 18, 15, 15);
		wallbottom = blocks.getTile(115, 34, 15, 15); 
		pillar_1 = blocks.getTile(115, 18, 15, 15);
		
		// Ladder stuff
		ladder_1 = blocks.getTile(83, 3, 15, 15);
		ladder_stars = blocks.getTile(131, 50, 15, 15);
		ladderwall = blocks.getTile(131, 1, 15, 15);
		ladderwall2 = blocks.getTile(147, 2, 15, 15);
		ladderinwater = blocks.getTile(147, 82, 15, 15);
		laddertop = blocks.getTile(163, 2, 15, 15);
		laddertopblacktile = blocks.getTile(179, 2, 15, 15);
		
		// Game items
		chest_1 = blocks.getTile(19, 2, 15, 15);	
		chestblacktile = blocks.getTile(147, 18, 15, 15);
		diamond_1 = blocks.getTile(83, 18, 15, 15);	
		diamond_2 = blocks.getTile(179, 34, 15, 15);
		diamondblacktile = blocks.getTile(163, 18, 15, 15);	
		
		// Doors
		door_1 = blocks.getTile(3, 50, 15, 15);
		door_2 = blocks.getTile(19, 50, 15, 15);
		
		// Keys
		key_1 = blocks.getTile(3, 82, 15, 15);
		key_2 = blocks.getTile(19, 82, 15, 15);
		//key_1 = player.getTile(3, 82, 15, 15);
		health = blocks.getTile(3, 34, 15, 15);	 
		
		// Enemies
		enemy_1 = player.getTile(99, 18, 15, 15);
		spider_1 = player.getTile(99, 18, 15, 15);
		spider_2 = player.getTile(99, 34, 15, 15);
		spider_3 = player.getTile(99, 50, 15, 15);
		
		// Mouse/extras
		mouse_pressed = blocks.getTile(51, 2, 15, 15);
		mouse_unpressed = blocks.getTile(51, 2, 15, 15);
		//button_heldover = player.getTile(64+64+32, 32, 48, 16);
		button_heldover = blocks.getTile(3, 3, 15, 15);
		//button_notover = player.getTile(64+64+32, 32, 48, 16);
		button_notover = blocks.getTile(3, 3, 15, 15);
		//}
	}
	
	// Stats/ health
	public static BufferedImage getBlank() {
		return blank;
	}
	
	public static BufferedImage getHealth() {
		return health;
	}	
	
	// Starry skies/ sky/ background
	public static BufferedImage getStars() {
		return stars;
	}
	
	public static BufferedImage getStalagmite_stars() {
		return stalagmite_stars;
	}
	
	public static BufferedImage getdistantStar() {
		return distant_star;
	}
	
	public static BufferedImage getblackTile() {
		return blacktile;
	}
	
	public static BufferedImage getSky() {
		return sky;
	}
	
	public static BufferedImage getskyClouds() {
		return skyclouds;
	}
	
	public static BufferedImage getSun() {
		return sun;
	}
	
	public static BufferedImage getskyGround() {
		return skyground;
	}
	
	public static BufferedImage getFloor_1() {
		return floor_1;
	}
	
	public static BufferedImage getBase_1() {
		return base_1;
	}
	public static BufferedImage getWater_1() {
		return water_1;
	}
	public static BufferedImage getWater_2() {
		return water_2;
	}
	public static BufferedImage getwaterBase() {
		return waterbase;
	}
	// Animation
	public static BufferedImage getwaterAnimation_1() {
		return wateranimation1;
	}
	public static BufferedImage getwaterAnimation_2() {
		return wateranimation2;
	}
	public static BufferedImage getwaterAnimation_3() {
		return wateranimation3;
	}
	public static BufferedImage getwaterAnimation_4() {
		return wateranimation4;
	}
	
	public static BufferedImage getwaterfallTop() {
		return waterfalltop;
	}
	
	public static BufferedImage getwaterFall1() {
		return waterfall1;
	}
	
	public static BufferedImage getwaterFall2() {
		return waterfall2;
	}
	
	public static BufferedImage getwaterfallBottom() {
		return waterfallbottom;
	}
	
	// Game won item
	public static BufferedImage getTeleporter_1() {
		return teleporter_1;
	}
	public static BufferedImage getTeleporter_2() {
		return teleporter_2;
	}
	public static BufferedImage getTeleporter_3() {
		return teleporter_3;
	}
	
	// Mountains
	public static BufferedImage getMountains_1() {
		return mountains_1;
	}
	public static BufferedImage getMountains_2() {
		return mountains_2;
	}
	public static BufferedImage getmountainsLeft() {
		return mountainsleft;
	}
	public static BufferedImage getmountainsBase() {
		return mountainsbase;
	}
	public static BufferedImage getmountainsRight() {
		return mountainsright;
	}
	
	public static BufferedImage getmountainsdistantRight() {
		return mountainsdistantright;
	}
	
	public static BufferedImage getmountainsdistantLeft() {
		return mountainsdistantleft;
	}
	
	// Walls
	public static BufferedImage getStone_1() {
		return stone_1;
	}
	
	public static BufferedImage getStone_2() {
		return stone_2;
	}
	
	public static BufferedImage getStone_3() {
		return stone_3;
	}
	
	public static BufferedImage getStalagmite() {
		return stalagmite;
	}
	public static BufferedImage getWall_1() {
		return wall_1;
	}
	
	public static BufferedImage getwallBottom() {
		return wallbottom;
	}
	
	public static BufferedImage getPillar_1() {
		return pillar_1;
	}
	
	// Ladder stuff
	public static BufferedImage getLadder_1() {
		return ladder_1;
	}
	
	public static BufferedImage getladderStars() {
		return ladder_stars;
	}
	
	public static BufferedImage getLadderWall() {
		return ladderwall;
	}
	public static BufferedImage getLadderWall2() {
		return ladderwall2;
	}
	public static BufferedImage getLadderinWater_1() {
		return ladderinwater;
	}
	public static BufferedImage getladderTop() {
		return laddertop;
	}
	public static BufferedImage getladdertopBlacktile() {
		return laddertopblacktile;
	}
	
	// Game items
	public static BufferedImage getChest_1() {
		return chest_1;
	}
	public static BufferedImage getchestBlacktile() {
		return chestblacktile;
	}
	
	public static BufferedImage getDiamond_1() {
		return diamond_1;
	}
	
	public static BufferedImage getDiamond_2() {
		return diamond_2;
	}
	
	public static BufferedImage getdiamondBlacktile() {
		return diamondblacktile;
	}
	
	// Doors
	public static BufferedImage getDoor_1() {
		return door_1;
	}
	
	public static BufferedImage getDoor_2() {
		return door_2;
	}
	
	// Keys
	public static BufferedImage getKey_1() {
		return key_1;
	}
	
	public static BufferedImage getKey_2() {
		return key_2;
	}
	
	// Enemies
	public static BufferedImage getEnemy_1() {
		return enemy_1;
	}
	
	public static BufferedImage getSpider_1() {
		return spider_1;
	}
	
	public static BufferedImage getSpider_2() {
		return spider_2;
	}
	
	public static BufferedImage getSpider_3() {
		return spider_3;
	}
	
	//Mouse/extras
	public static BufferedImage getMouse_pressed() {
		return mouse_pressed;
	}
	
	public static BufferedImage getMouse_unpressed() {
		return mouse_unpressed;
	}
	
	public static BufferedImage getbutton_heldover() {
		return button_heldover;
	}
	
	public static BufferedImage getbutton_notover() {
		return button_notover;
	}
}
TileManager.java - Video 14
package generator;

import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;

import animation.WaterAnimation;
import moveableobjects.Player;
import dungeonmain.Vector2F;

//Tutorial 14: 12:45 - created
//Java 2D Game Development Tutorial [14] For Beginners - Tilemap and Blocks
@SuppressWarnings("unused")
public class TileManager {
	
	// All blocks are different buffered images
	public static CopyOnWriteArrayList blocks = new CopyOnWriteArrayList();
	public static CopyOnWriteArrayList load_blocks = new CopyOnWriteArrayList();
	
	private World world;

	public TileManager(World world) {
		this.world = world;
	}
	
	public TileManager() {
		this.world = world;
	}
	
	public TileManager(WaterAnimation waterAnimation) {
		this.world = world;
	}

	@SuppressWarnings("static-access")
	public void tick(double deltaTime) {
		for(Block block : blocks) {
			block.tick(deltaTime);
			
			// player world view (surrounded by rectangle)
			
			// Check if rectangle surrounding the player has
			// touched any of the blocks.
			if (Player.render.intersects(block)) {
				block.setAlive(true);
				
				if (!load_blocks.contains(block)) {
					load_blocks.add(block);
				}
				else {
					if(load_blocks.contains(block)) {
						load_blocks.remove(block);
					}
					block.setAlive(false);
				}

			}
			
			if(!world.getPlayer().isDebuging()) {
				if (!load_blocks.isEmpty()) {
					load_blocks.clear();
				}
			}
		}
	}
	
	public void render(Graphics2D g) {
		for(Block block : blocks) {
			block.render(g);
		}
	}
	
	public CopyOnWriteArrayList getBlocks() {
		return blocks;
	}
	
	public CopyOnWriteArrayList getLoadedBlocks() {
		return load_blocks;
	}
}
Block.java - Video 14
package generator;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

import dungeonmain.Assets;
import dungeonmain.Vector2F;

//Tutorial 14: 9:10
//Java 2D Game Development Tutorial [14] For Beginners - Tilemap amd Blocks
@SuppressWarnings("unused")
public class Block extends Rectangle {
	
	private static final long serialVersionUID = -1643076062339697708L;
	Vector2F pos = new Vector2F();
	private int BlockSize = 128;
	public BlockType blocktype;
	private BufferedImage block;
	private BufferedImage eventObject;
	private boolean isSolid;
	private boolean isAlive;
	private boolean isTeleporter;
	private boolean isTreasureChest;
	private boolean isDiamondRing;
	private boolean isSpider;
	private boolean isDoorOpen;
	private boolean isKey;
	private boolean isKey2;
	private boolean isLadder;
	private boolean isDoor1Open;
	private boolean isDoor2Open;
	
	private boolean isHealth;
	private boolean isTest;
	public int isSuperJumpBoost;
	
	private boolean dropped = false;
	private int blockSize = 48;
	public static Vector2F map_pos = new Vector2F();
	
	public static float worldXpos;
	public static float worldYpos;
	public Block bump;
	
	public Block(Vector2F pos) {
		setBounds((int)pos.xpos, (int)pos.ypos, BlockSize, BlockSize);
		this.pos = pos;
		isAlive = true;
	}
	
	// used by tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATERANIMATION2).isTreasureChest(false));
	public Block(Vector2F pos, BlockType blocktype) {
		setBounds((int)pos.xpos, (int)pos.ypos, BlockSize, BlockSize);
		this.pos = pos;
		isAlive = true;
		this.blocktype = blocktype;
		init();
	}

	public Block isSolid(boolean isSolid) {
		this.isSolid = isSolid;
		return this;
	}
	
	public Block isTeleporter(boolean isTeleporter) {
		this.isTeleporter = isTeleporter;
		return this;
	}
	
	public Block isTreasureChest(boolean isTreasureChest) {
		this.isTreasureChest = isTreasureChest;
		return this;
	}
	
	public Block isDiamondRing(boolean isDiamondRing) {
		this.isDiamondRing = isDiamondRing;
		return this;
	}
	
	public Block isSpider(boolean isSpider) {
		this.isSpider = isSpider;
		return this;
	}
	
	public Block isLadder(boolean isLadder) {
		this.isLadder = isLadder;
		return this;
	}
	
	public Block isDoorOpen(boolean isDoorOpen) {
		this.isDoorOpen = isDoorOpen;
		return this;
	}
	
	public Block isKey(boolean isKey) {
		this.isKey = isKey;
		return this;
	}
	
	public Block isKey2(boolean isKey2) {
		this.isKey2 = isKey2;
		return this;
	}
	
	public Block isDoor1Open(boolean isDoor1Open) {
		this.isDoor1Open = isDoor1Open;
		return this;
	}
	
	public Block isDoor2Open(boolean isDoor2Open) {
		this.isDoor2Open = isDoor2Open;
		return this;
	}
	
	public void init() {
		switch(blocktype) {
		// Stats/health
		case BLANK:
			block = Assets.getBlank();
			break;
		case HEALTH:
			block = Assets.getHealth();
			break;
		// Starry skies/sky/background
		case STARS:
			block = Assets.getStars();
			break;
		case STALAGMITE_STARS:  
			block = Assets.getStalagmite_stars();
			break;
		case DISTANT_STAR:
			block = Assets.getdistantStar();
			break;
		case BLACKTILE:
			block = Assets.getblackTile();
			break;
		case SKY:
			block = Assets.getSky();
			break;
		case SKYCLOUDS:
			block = Assets.getskyClouds();
			break;
		case SUN:
			block = Assets.getSun();
			break;
		case SKYGROUND:
			block = Assets.getskyGround();
			break;
		case FLOOR_1: 
			block = Assets.getFloor_1();
			break;
		case BASE_1:
			block = Assets.getBase_1();
			break;
		case WATER_1:
			block = Assets.getWater_1();
			break;
		case WATER_2:
			block = Assets.getWater_2();
			break;
		case WATERANIMATION1:
			block = Assets.getwaterAnimation_1();
			break;
		case WATERANIMATION2:
			block = Assets.getwaterAnimation_2();
			break;
		case WATERANIMATION3:
			block = Assets.getwaterAnimation_3();
			break;
		case WATERANIMATION4:
			block = Assets.getwaterAnimation_4();
			break;
		case WATERFALLTOP:
			block = Assets.getwaterfallTop();
			break;
		case WATERFALL1:
			block = Assets.getwaterFall1();
			break;
		case WATERFALL2:
			block = Assets.getwaterFall2();
			break;
		case WATERFALLBOTTOM:
			block = Assets.getwaterfallBottom();
			break;
		case WATERBASE:
			block = Assets.getwaterBase();
			break;
		case TELEPORTER_1:
			block = Assets.getTeleporter_1();
			break;
		case TELEPORTER_2:
			block = Assets.getTeleporter_2();
			break;
		case TELEPORTER_3:
			block = Assets.getTeleporter_3();
			break;
		// Mountains
		case MOUNTAINS_1:
			block = Assets.getMountains_1();
			break;
		case MOUNTAINS_2:
			block = Assets.getMountains_2();
			break;
		case MOUNTAINSLEFT:
			block = Assets.getmountainsLeft();
			break;
		case MOUNTAINSBASE:
			block = Assets.getmountainsBase();
			break;
		case MOUNTAINSRIGHT:
			block = Assets.getmountainsRight();
			break;
		case MOUNTAINSDISTANTRIGHT:
			block = Assets.getmountainsdistantRight();
			break;
		case MOUNTAINSDISTANTLEFT:
			block = Assets.getmountainsdistantLeft();
			break;
		// Walls
		case STONE_1:
			block = Assets.getStone_1();
			break;
		case STONE_2:  
			block = Assets.getStone_2();
			break;
		case STONE_3:  
			block = Assets.getStone_3();
			break;
		case STALAGMITE:  
			block = Assets.getStalagmite();
			break;
		case WALL_1: 
			block = Assets.getWall_1();
			break;
		case WALLBOTTOM: 
			block = Assets.getwallBottom();
			break;
		case PILLAR_1: 
			block = Assets.getPillar_1();
			break;
		// Ladder stuff
		case LADDER_1: 
			block = Assets.getLadder_1();
			break;
		case LADDER_STARS: 
			block = Assets.getladderStars();
			break;
		case LADDERWALL: 
			block = Assets.getLadderWall();
			break;
		case LADDERWALL2: 
			block = Assets.getLadderWall2();
			break;
		case LADDERINWATER: 
			block = Assets.getLadderinWater_1();
			break;
		case LADDERTOP: 
			block = Assets.getladderTop();
			break;
		case LADDERTOPBLACKTILE: 
			block = Assets.getladdertopBlacktile();
			break;
		// Game items
		case CHEST_1: 
			block = Assets.getChest_1();
			break;
		case CHESTBLACKTILE: 
			block = Assets.getchestBlacktile();
			break;
		case DIAMOND_1:
			block = Assets.getDiamond_1();
			break;
		case DIAMOND_2:
			block = Assets.getDiamond_2();
			break;
		case DIAMONDBLACKTILE:
			block = Assets.getdiamondBlacktile();
			break;
		// Doors
		case DOOR_1:
			block = Assets.getDoor_1();
			break;
		case DOOR_2:
			block = Assets.getDoor_2();
			break;
		case ENEMY_1:
			block = Assets.getEnemy_1();
			break;
		// Keys
		case KEY_1:
			block = Assets.getKey_1();
			break;
		case KEY_2:
			block = Assets.getKey_2();
			break;
		// Enemies
		case SPIDER_1:
			block = Assets.getSpider_1();
			break;
		case SPIDER_2:
			block = Assets.getSpider_2();
			break;
		case SPIDER_3:
			block = Assets.getSpider_3();
			break;
		}
	}
	
	public void tick(double deltaTime) {
		if (isAlive) {
			setBounds((int)pos.xpos, (int)pos.ypos, BlockSize, BlockSize);
		}
	}
	
	public void render(Graphics2D g) {
		if (isAlive) {
			g.drawImage(block, (int)pos.getWorldLocation().xpos, (int)pos.getWorldLocation().ypos, BlockSize, BlockSize, null);
		}
		
		//if (isSolid) {
		//	g.drawRect((int)pos.getWorldLocation().xpos, (int)pos.getWorldLocation().ypos, BlockSize, BlockSize);
		//}
	}
	
	// This section draws the WHITE RECTANGLE surrounding the blocks
/*	public void render(Graphics2D g) 
	{
		if (isAlive) 
		{
			// draw all block images (door, diamond, spider, key, etc)
			g.drawImage(block, (int)pos.getWorldLocation().xpos, (int)pos.getWorldLocation().ypos, BlockSize, BlockSize, null);
			if (isSolid) 
			{
			{
				g.fillRect((int)pos.getWorldLocation().xpos, (int)pos.getWorldLocation().ypos, BlockSize, BlockSize);
			}
			
		} 
	}
	}*/
	
	public enum BlockType {
		BLANK,
		STARS,
		STALAGMITE_STARS,
		DISTANT_STAR,
		BLACKTILE,
		SKY,
		SKYCLOUDS,
		SUN,
		SKYGROUND,
		BASE_1,
		WATER_1,
		WATER_2,
		WATERBASE,
		WATERANIMATION1,
		WATERANIMATION2,
		WATERANIMATION3,
		WATERANIMATION4,
		WATERFALLTOP,
		WATERFALL1,
		WATERFALL2,
		WATERFALLBOTTOM,
		TELEPORTER_1,
		TELEPORTER_2,
		TELEPORTER_3,
		MOUNTAINS_1,
		MOUNTAINS_2,
		MOUNTAINSLEFT,
		MOUNTAINSBASE,
		MOUNTAINSRIGHT,
		MOUNTAINSDISTANTRIGHT,
		MOUNTAINSDISTANTLEFT,
		STONE_1,
		STONE_2,
		STONE_3,
		STALAGMITE,
		WALL_1,
		WALLBOTTOM,
		PILLAR_1,
		LADDER_1,
		LADDER_STARS,
		LADDERWALL,
		LADDERWALL2,
		LADDERINWATER,
		LADDERTOP,
		LADDERTOPBLACKTILE,
		CHEST_1,
		CHESTBLACKTILE,
		FLOOR_1,
		DIAMOND_1,
		DIAMOND_2,
		DIAMONDBLACKTILE,
		DOOR_1,
		DOOR_2,
		ENEMY_1,
		SPIDER_1,
		SPIDER_2,
		SPIDER_3,
		KEY_1,
		KEY_2,
		TEST_1,
		HEALTH
	}
	
	public int isSuperJumpBoost() {
		return isSuperJumpBoost;
	}

	public boolean isSolid() {
		return isSolid;
	}
	
	public boolean isTeleporter() {
		return isTeleporter;
	}
	
	public boolean isTreasureChest() {
		return isTreasureChest;
	}
	
	public boolean isDiamondRing() {
		return isDiamondRing;
	}
	
	public boolean isSpider() {
		return isSpider;
	}
	
	public boolean isLadder() {
		return isLadder;
	}
	
	public boolean isDoorOpen() {
		return isDoorOpen;
	}
	
	public boolean isDoor1Open() {
		return isDoor1Open;
	}
	
	public boolean isDoor2Open() {
		return isDoor2Open;
	}
	
	public boolean isKey() {
		return isKey;
	}
	
	public boolean isKey2() {
		return isKey2;
	}
	
	public boolean isHealth() {
		return isHealth;
	}
	
	public boolean isAlive() {
		return isAlive;
	}
	
	public void setAlive(boolean isAlive) {
		this.isAlive = isAlive;
	}

	public Vector2F getBlockLocation() {
		return pos;
	}
}
Player.java - Video 17
package moveableobjects;

import gameloop.GameLoop;
import gamestate.GameState;
import gamestate.GameStateManager;
import gamestates.DungeonLevelLoader;
import gamestates.GameStateButton;
import generator.Block;
import generator.TileManager;
import generator.World;
import generator.Block.BlockType;

import java.applet.AudioClip;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.CopyOnWriteArrayList;

import animation.DiamondAnimation;
import animation.TeleporterAnimation;
import animation.WaterAnimation;
import sounds.SFXAudio;
import sounds.Sound;
import managers.GUImanager;
import managers.HUDManager;
import managers.MouseManager;
import dungeonmain.Animator;
import dungeonmain.Assets;
import dungeonmain.Check;
import dungeonmain.Main;
import dungeonmain.Vector2F;
import dungeonmain.loadImageFrom;
import entity.Enemy;

// Tutorial 17: 2:40   /18/21

//***************************************
//              Items                   *
//--------------------------------------*
// Gold, Treasure, Coins                *
// Antidote (spider bites) -            *
//   - found in random treasure chests  *
//***************************************
// After so many bites, the player can  *
// develop a fever, which can only be   *
// cured by the antidote.               *
//***************************************
// Bombs - new items			 		*
//***************************************


// Each time set (challenge) yourself to
// completing a certain task
//=======================================
// Today: 4/28/15 - Get the treasure chest
// object working. So that when the player
// touches a chest he gets the item and
// the chest in that location "only"
// disappears.

//Youtube: Java 2D Game OpenGL

@SuppressWarnings("unused")
public class Player implements KeyListener {
	
	private static final Point Point = null;
	Vector2F pos;
	private World world;
	private int width = 42;	// 48x48
	private int height = 42; // 42x42
	private int scale = 2;
	private static boolean thrustup,up,down,left,right,running;
	private static int boostplayer = 5;
	private static int countBoost = 25;
	private static int boostmaxrange;
	int count;
	private static boolean debug = false;
	private float maxSpeed = 30.09F;
	public TileManager tiles;
	
	//Sounds/Music
	private AudioClip clip;
	private Sound sound;
	public static boolean playsoundOnce;
	public static boolean musicLoop=true;
	private HashMap sfx;
	
	// Levels
	public static int level=1;
	
	private float fixDt = 47F/60F;
	private static long animationSpeed = 180;
	
	private static boolean moving = true;
	private static boolean spawned;
	private Check evaluate = new Check();
	private int blockSize = 128;
	
	// Define objects
	GameStateManager gsm;
	MouseManager playerMM = new MouseManager();
	Enemy enemyMove = new Enemy();
	public static boolean wateranimationOn=true;
	WaterAnimation waterAnimate = new WaterAnimation();
	DiamondAnimation diamondAnimate = new DiamondAnimation();
	TeleporterAnimation teleport = new TeleporterAnimation();
	DungeonLevelLoader dll;
	
	//spider state animation
	public static int fallRate = 2;
	
	// Surround player by large rectangle box
	private int renderDistanceW = 48;
	private int renderDistanceH = 20;
	public static Rectangle render;
	
	// TODO
	private int animationState = 0;
	
	// GOLD
	public static int gold;
	
	
	private int map_pointx;
	private int map_pointy;
	
	
	private float mapscrollx;
	private float mapscrolly;
	/*
	 * 0 = up
	 * 1 = down
	 * 2 = right
	 * 3 = left
	 * 4 = idle 
	 */
	
	private ArrayList listUp;
	Animator ani_up;
	private ArrayList listDown;
	Animator ani_down;
	private ArrayList listLeft;
	Animator ani_left;
	private ArrayList listRight;
	Animator ani_right;
	
	private ArrayList listIdle;
	Animator ani_idle;
	
	private ArrayList spiderFrame1;
	Animator ani_spider1;
	private ArrayList spiderFrame2;
	Animator ani_spider2;
	private ArrayList spiderFrame3;
	Animator ani_spider3;
	private ArrayList spiderClear;
	Animator ani_spiderclear;
	
	private HUDManager hudm;
	private GUImanager guim;
	
	//private boolean mapMove = true;
	private float speedUp = 20;
	private float speedDown = 20;
	private float speedLeft = 20;
	private float speedRight = 20;
	private float slowdown = 12F;
	
	private int gravity = 0;
	
	private Block bump;
	
	public static int clock=0;
	public static int diamondflash=0;
	public static int objmove;
	public static int temp_objmove;
	public BufferedImage map;
	public static CopyOnWriteArrayList blocks = new CopyOnWriteArrayList();
	private int world_width;
	private int world_height;
	private boolean hasSizeWaterAnimation = false;	

	
	public Player() {	
		pos = new Vector2F(Main.width / 4 - width / 2, (Main.height / 4 - height / 2) + gravity - 1);
		//System.out.println(pos);
	}
	
	// Start Applet
	public void start() {
		init(world);
		new Thread((Runnable) this).start();
	}

	public void init(World world) {
		//evaluate = new Check();
		//tiles = new TileManager();
		//tiles.getLoadedBlocks();
		hudm = new HUDManager(world);
		//guim = new GUImanager();
		this.world = world;
		evaluate.setDoorIsLocked(true);
		//dll = new DungeonLevelLoader(gsm, "world2", "map5.png");
		
		
		if (musicLoop) {
			sound = new Sound("/Music/AMemoryAway.mp3");
			sound.play();
			musicLoop = false;
		}
		
		render = new Rectangle(
				(int) (pos.xpos - pos.getWorldLocation().xpos + pos.xpos - renderDistanceW*32 / 2 + width / 2),
				(int) (pos.ypos - pos.getWorldLocation().ypos + pos.ypos - renderDistanceH*32 / 2 + height / 2),
				renderDistanceW*32,
				renderDistanceH*32);
		
		listUp = new ArrayList();
		listDown = new ArrayList();
		listRight = new ArrayList();
		listLeft = new ArrayList();
		listIdle = new ArrayList();
		
		spiderFrame1 = new ArrayList();
		spiderFrame2 = new ArrayList();
		spiderFrame3 = new ArrayList();
		spiderClear = new ArrayList();
		
		
		// xTile, yTile, width, height
		listUp.add(Assets.player.getTile(4,34,15,14));
		listUp.add(Assets.player.getTile(19,34,15,14));
		
		listDown.add(Assets.player.getTile(0,50,15,15));
		listDown.add(Assets.player.getTile(19,50,15,15));
		
		listRight.add(Assets.player.getTile(35,50,15,15));
		listRight.add(Assets.player.getTile(51,50,15,15));
		listRight.add(Assets.player.getTile(67,50,15,15));
		listRight.add(Assets.player.getTile(83,50,15,15));
		
		listLeft.add(Assets.player.getTile(35,34,15,15));
		listLeft.add(Assets.player.getTile(51,34,15,15));
		listLeft.add(Assets.player.getTile(67,34,15,15));
		listLeft.add(Assets.player.getTile(83,34,15,15));
		
		listIdle.add(Assets.player.getTile(3,66,15,15));
		listIdle.add(Assets.player.getTile(3,66,15,15));
		listIdle.add(Assets.player.getTile(3,66,15,15));
		listIdle.add(Assets.player.getTile(3,66,15,15));
		
		// x,y = 2, 18, 34, 50, 66, 82, 98
		
		spiderFrame1.add(Assets.player.getTile(3,3,15,15));
		//spiderFrame1.add(Assets.player.getTile(98,18,15,15));
		spiderFrame2.add(Assets.player.getTile(98,34,15,15));
		spiderFrame3.add(Assets.player.getTile(98,50,15,15));
		spiderClear.add(Assets.floor_1);
		
		//UP
		ani_up = new Animator(listUp);
		ani_up.setSpeed(animationSpeed);
		ani_up.play();
		//DOWN
		ani_down = new Animator(listDown);
		ani_down.setSpeed(animationSpeed);
		ani_down.play();
		//RIGHT
		ani_right = new Animator(listRight);
		ani_right.setSpeed(animationSpeed);
		ani_right.play();
		//LEFT
		ani_left = new Animator(listLeft);
		ani_left.setSpeed(animationSpeed);
		ani_left.play();
		//IDLE
		ani_idle = new Animator(listIdle);
		ani_idle.setSpeed(animationSpeed);
		ani_idle.play();
		
		ani_spider1 = new Animator(spiderFrame1);
		ani_spider1.setSpeed(animationSpeed);
		ani_spider1.play();
		
		ani_spider2 = new Animator(spiderFrame2);
		ani_spider2.setSpeed(animationSpeed);
		ani_spider2.play();
		
		ani_spider3 = new Animator(spiderFrame3);
		ani_spider3.setSpeed(animationSpeed);
		ani_spider3.play();
		spawned = true;
	}

	public void tick(double deltaTime) {
		render = new Rectangle(
				(int) (pos.xpos - pos.getWorldLocation().xpos + pos.xpos - renderDistanceW*32 / 2 + width / 2),
				(int) (pos.ypos - pos.getWorldLocation().ypos + pos.ypos - renderDistanceH*32 / 2 + height / 2),
				renderDistanceW*32,
				renderDistanceH*32);
		//g.drawRect((int)pos.xpos - renderDistanceW * 32 / 2 + width / 2, (int)pos.ypos - renderDistanceH * 32 / 2 + height / 2, renderDistanceW * 32, renderDistanceH * 32);
		
		playerMM.tick();
		//enemyMove.tick();
		//diamondAnimate.tick();
		//teleport.tick();
		//tiles.tick(deltaTime);
		//if (wateranimationOn) {
		//	waterAnimate.tick(deltaTime);
		//}
		//world = new World("world", this, gsm);
		//world.setSize(100,100); // 45,2
		//world.addPlayer(new Player());
		//world.init();
		//world.generate("map5.png");	
		//waterAnimate.init(world);
		
		//button1.tick();
		
		float moveAmountu = (float) (speedUp * fixDt);
		float moveAmountd = (float) (speedDown * fixDt);
		float moveAmountl = (float) (speedLeft * fixDt);
		float moveAmountr = (float) (speedRight * fixDt);
		
		
		//int boostUp = evaluate.setSuperJumpBoost(6);
		
		if (evaluate.ladderStatus == 0 && evaluate.playerhitWall == true) {	// player is not touching a ladder
			countBoost = 25;
		}
		
		if (!up && countBoost > 0) {
		
			// Execute this code only if a player is not touching a ladder
			// and countBoost > 0 (still has 5 jumps left)
		
				if (thrustup && countBoost > 0 && evaluate.ladderStatus == 0) {
					countBoost -= 1;
				
					// Player can still jump
					if (countBoost > 0) {
						animationState = 0;
						world.map_pos.ypos -= countBoost * 2; // how high he jumps
						moveMapUp(moveAmountu);
					}
					
					if (countBoost < 1) {
						countBoost = 0;
					}
					
					// Player can no longer jump
					// since exceeded 5 jumps.
					//else  {
						//moveMapUp(moveAmountu);
					//	boostmaxrange = 0;		 
					//}
			
				} 
		}
			
			else if (up && evaluate.ladderStatus == 1 && thrustup == false) 
			{
				moveMapUp(moveAmountu);
				animationState = 0;
			}
		
		//else {
		//	moveMapUpGlide(moveAmountu);
		//	System.out.println("Gliding up");
		//}
		if (down && evaluate.ladderStatus == 1) {
			moveMapDown(moveAmountd); 
			animationState = 1;
		}else {
			moveMapDownGlide(moveAmountd);
		}
		if (right) {
			moveMapRight(moveAmountr);
			animationState = 2;
		}else {
			moveMapRightGlide(moveAmountr);
		}
		if (left) {
			moveMapLeft(moveAmountl);
			animationState = 3;
		}else {
			moveMapLeftGlide(moveAmountl);
		}
		
		if (!up && !down && !right && !left) {
			/*
			 * standing still
			 */
			animationState = 4;
			if(moving) {
				moving = false;
			}
		}
		
		if (running) {
			if (animationSpeed !=100) {
				animationSpeed = 100;
				ani_up.setSpeed(animationSpeed);
				ani_down.setSpeed(animationSpeed);
				ani_right.setSpeed(animationSpeed);
				ani_left.setSpeed(animationSpeed);
				ani_idle.setSpeed(animationSpeed);		
				maxSpeed += 64;
			} 
		}
	}
	
	@SuppressWarnings("static-access")
	public void moveMapUp(float speed) {
		
		Point a = new Point((int) (pos.xpos + world.map_pos.xpos), 
				  (int) (pos.ypos + world.map_pos.ypos - speed + countBoost));
		
		Point b = new Point((int) (pos.xpos + world.map_pos.xpos + width),
				  (int) (pos.ypos + world.map_pos.ypos - speed + countBoost));
		
		if (!Check.ImpactBlock(a, b)) {
		
		//if (!Check.ImpactBlock(
		//		new Point((int) (pos.xpos + world.map_pos.xpos), 
		//				  (int) (pos.ypos + world.map_pos.ypos - speed + countBoost)),
						  
		//		new Point((int) (pos.xpos + world.map_pos.xpos + width),
		//				  (int) (pos.ypos + world.map_pos.ypos - speed + countBoost)))) {
			
			// If not colliding then check
			// maxSpeed movement
			
			if (speedUp < maxSpeed) {
				speedUp += slowdown;
			}else {
				speedUp = maxSpeed;
			}
			world.map_pos.ypos -= speed;
			
		} else {
			speedUp = 0;
		}
	}
	
	@SuppressWarnings("static-access")
	public void moveMapUpGlide(float speed) {
		if (!Check.ImpactBlock(
				new Point((int) (pos.xpos + world.map_pos.xpos), 
						  (int) (pos.ypos + world.map_pos.ypos - speed)),
						  
				new Point((int) (pos.xpos + world.map_pos.xpos + width),
						  (int) (pos.ypos + world.map_pos.ypos - speed)))) {
			
			if (speedUp != 0) {
				speedUp -= slowdown;
 
				if (speedUp < 0) {
					speedUp = 0;
				}
			}	
			world.map_pos.ypos -= speed;
			
		} else {
			speedUp = 0;
		}
	}
	
	@SuppressWarnings("static-access")
	public void moveMapDown(float speed) {
		
		Point a = new Point((int) (pos.xpos + world.map_pos.xpos), 
				  (int) (pos.ypos + world.map_pos.ypos + height + speed));
		
		Point b = new Point((int) (pos.xpos + world.map_pos.xpos + width),
				  (int) (pos.ypos + world.map_pos.ypos + height + speed));
		
		if (!Check.ImpactBlock(a, b)) {
		
		//if (!Check.ImpactBlock(
		//		new Point((int) (pos.xpos + world.map_pos.xpos), 
		//				  (int) (pos.ypos + world.map_pos.ypos + height + speed)),
						  
		//		new Point((int) (pos.xpos + world.map_pos.xpos + width),
		//				  (int) (pos.ypos + world.map_pos.ypos + height + speed)))) 
		//{

			if (speedDown < maxSpeed) {
				speedDown += slowdown;
			}else {
				speedDown = maxSpeed;
			}
			world.map_pos.ypos += speed;
			
		} else {
			Check.foundChest = false;

			speedDown = 0;
		}
	}
	
	@SuppressWarnings("static-access")
	public void moveMapDownGlide(float speed) {
		if (!Check.ImpactBlock(
				new Point((int) (pos.xpos + world.map_pos.xpos), 
						  (int) (pos.ypos + world.map_pos.ypos + height + speed)),
						  
				new Point((int) (pos.xpos + world.map_pos.xpos + width),
						  (int) (pos.ypos + world.map_pos.ypos + height + speed)))) {
			
			if (speedDown != 0) {
				speedDown -= slowdown;
 
				if (speedDown < 0) {
					speedDown = 0;
				}
			}	
			world.map_pos.ypos += speed;
			
		} else {
			speedDown = 0;
		}
	}
	
	@SuppressWarnings("static-access")
	public void moveMapRight(float speed) {
		
		Point a = new Point((int) (pos.xpos + world.map_pos.xpos + width + speed), 
				  (int) (pos.ypos + world.map_pos.ypos));
		
		Point b = new Point((int) (pos.xpos + world.map_pos.xpos + width + speed),
				  (int) (pos.ypos + world.map_pos.ypos + height));
		
		if (!Check.ImpactBlock(a, b)) {
		
		
		//if (!Check.ImpactBlock(
		//		new Point((int) (pos.xpos + world.map_pos.xpos + width + speed), 
		//				  (int) (pos.ypos + world.map_pos.ypos)),
						  
		//		new Point((int) (pos.xpos + world.map_pos.xpos + width + speed),
		//				  (int) (pos.ypos + world.map_pos.ypos + height)))) {
		
			if (speedRight < maxSpeed) {
				speedRight += slowdown;
			}else {
				speedRight = maxSpeed;
			}
			world.map_pos.xpos += speed;
		} else {
			speedRight = 0;
		}
	}
	
	@SuppressWarnings("static-access")
	public void moveMapRightGlide(float speed) {
		if (!Check.ImpactBlock(
				new Point((int) (pos.xpos + world.map_pos.xpos + width + speed), 
						  (int) (pos.ypos + world.map_pos.ypos)),
						  
				new Point((int) (pos.xpos + world.map_pos.xpos + width + speed),
						  (int) (pos.ypos + world.map_pos.ypos + height)))) {
			
			if (speedRight != 0) {
				speedRight -= slowdown;
 
				if (speedRight < 0) {
					speedRight = 0;
				}
			}	
			world.map_pos.xpos += speed;
			
		} else {
			speedRight = 0;
		}
	}
	
	@SuppressWarnings("static-access")
	public void moveMapLeft(float speed) {
		
		Point a = new Point((int) (pos.xpos + world.map_pos.xpos - speed), 
				  (int) (pos.ypos + world.map_pos.ypos + height));
		
		Point b = new Point((int) (pos.xpos + world.map_pos.xpos - speed),
				  (int) (pos.ypos + world.map_pos.ypos));
		
		if (!Check.ImpactBlock(a, b)) {
		
		//if (!Check.ImpactBlock(
		//		new Point((int) (pos.xpos + world.map_pos.xpos - speed), 
		//				  (int) (pos.ypos + world.map_pos.ypos + height)),
						  
		//		new Point((int) (pos.xpos + world.map_pos.xpos - speed),
		//				  (int) (pos.ypos + world.map_pos.ypos)))) {
			
			if (speedLeft < maxSpeed) {
				speedLeft += slowdown;
			}else {
				speedLeft = maxSpeed;
			}
			world.map_pos.xpos -= speed;
			
		} else {
			speedLeft = 0;
		}
	}
	@SuppressWarnings("static-access")
	public void moveMapLeftGlide(float speed) {
		if (!Check.ImpactBlock(
				new Point((int) (pos.xpos + world.map_pos.xpos - speed), 
						  (int) (pos.ypos + world.map_pos.ypos + height)),
						  
				new Point((int) (pos.xpos + world.map_pos.xpos - speed),
						  (int) (pos.ypos + world.map_pos.ypos)))) {
			
			if (speedLeft != 0) {
				speedLeft -= slowdown;
 
				if (speedLeft < 0) {
					speedLeft = 0;
				}
			}	
			world.map_pos.xpos -= speed;
			
		} else {
			speedLeft = 0;
		}
	}
	
	//GameStateButton button1 = new GameStateButton(200,200);

	public void render(Graphics2D g) {
		
		//tiles.render(g);
		Point a = new Point((int) (pos.xpos + world.map_pos.xpos), 
				  (int) (pos.ypos + world.map_pos.ypos + height + fallRate));
		
		Point b = new Point((int) (pos.xpos + world.map_pos.xpos + width),
				  (int) (pos.ypos + world.map_pos.ypos + height + fallRate));

		if (!Check.ImpactBlock(a, b)) {
			
			// If not colliding then check
			// maxSpeed movement
			if (speedDown < maxSpeed) {
				speedDown += slowdown;
			}else {
				speedDown = maxSpeed + fallRate;
			}
			world.map_pos.ypos += fallRate;
			
			if (!playsoundOnce) {
				sound = new Sound("/SFX/jump2.wav");
				sound.play();
				playsoundOnce = true;
			}
			
		} else {
			speedDown = 0;
			playsoundOnce = false;
		}
		
		// UP	
		if (animationState == 0) {
			g.drawImage(ani_up.sprite, (int)pos.xpos - width / 2, ((int)pos.ypos - height) + gravity, width * scale, height * scale, null);
			if (up) {
				ani_up.update(System.currentTimeMillis());
			}
		}
		
		// DOWN
		if (animationState == 1) {
			g.drawImage(ani_down.sprite, (int)pos.xpos - width / 2, ((int)pos.ypos - height) + gravity, width * scale, height * scale, null);
			if (down) {
				ani_down.update(System.currentTimeMillis());
			}
		}
		
		// RIGHT
		if (animationState == 2) {
			g.drawImage(ani_right.sprite, (int)pos.xpos - width / 2, ((int)pos.ypos - height) + gravity, width * scale, height * scale, null);
			if (right) {
				ani_right.update(System.currentTimeMillis());
			}
		}
		
		// LEFT
		if (animationState == 3) {
			g.drawImage(ani_left.sprite, (int)pos.xpos - width / 2, ((int)pos.ypos - height) + gravity, width * scale, height * scale, null);
			if (left) {
				ani_left.update(System.currentTimeMillis());
			}
		}
		
		// IDLE
		if (animationState == 4) {
			g.drawImage(ani_idle.sprite, (int)pos.xpos - width / 2, ((int)pos.ypos - height) + gravity, width * scale, height * scale, null);
				ani_idle.update(System.currentTimeMillis());
				//System.out.println("ani_idle.sprite:" + ani_idle.sprite);
		}
		
		//player box above head
		//g.drawRect((int)pos.xpos + width / 2, (int)pos.ypos / 2 + height / 2, 42, 42);
		
		
		
		// surround player by large rectangle box
		//g.drawRect((int)pos.xpos + width / 2, (int)pos.ypos / 2 + height / 2, 42, 42);
		//guim.render(g);
		
		// Rectangle surrounding player
		//g.drawRect((int)pos.xpos - renderDistanceW * 32 / 2 + width / 2, (int)pos.ypos - renderDistanceH * 32 / 2 + height / 2, renderDistanceW * 32, renderDistanceH * 32);
		
		
		//if (wateranimationOn) {
		//	g.setColor(Color.white);
		//	g.drawString("Animation" + wateranimationOn, 30, 200);
		//}
		
		//g.drawImage(ani_spider1.sprite, (int)pos.getWorldLocation().xpos - width / 2, ((int)pos.getWorldLocation().ypos - height), width * scale, height * scale, null);
		//g.drawImage(ani_spider1.sprite, 100,100, width * scale, height * scale, null);
		
		
		g.drawImage(ani_spider1.sprite, (int)pos.getWorldLocation().xpos, (int)pos.getWorldLocation().ypos, blockSize, blockSize, null);
		g.fillRect((int)pos.getWorldLocation().xpos, (int)pos.getWorldLocation().ypos, blockSize, blockSize);
		
		
		
		hudm.render(g);
		//button1.render(g);
		playerMM.render(g);
		//enemyMove.render(g);
		//diamondAnimate.render(g);
		//teleport.render(g);
		
		//if (wateranimationOn) {
		//	waterAnimate.render(g);
		//}
		//DungeonLevelLoader dll = new DungeonLevelLoader("world4", "map5.png");
		//dll.init();
		//DungeonLevelLoader.world.changeToWorld("world", "map5");
		
	}

	@Override
	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		
		if (key == KeyEvent.VK_ENTER) {
			clip.loop();
			musicLoop = true;
		}
		
		if (key == KeyEvent.VK_A) {
			mapscrollx = mapscrollx - 128; //getMapMoveX();
			moveMapLeft(mapscrollx);	
		}
		
		if (key == KeyEvent.VK_D) { 
			mapscrollx = mapscrollx + 128; //getMapMoveX();
			moveMapRight(mapscrollx);
		}
		
		if (key == KeyEvent.VK_W) {
			mapscrolly = mapscrolly - 128; //getMapMoveX();
			moveMapUp(mapscrolly);	
		}
		
		if (key == KeyEvent.VK_Z) {
			mapscrolly = mapscrolly + 128; //getMapMoveX();
			moveMapDown(mapscrolly);	
		}
		
		if (key == KeyEvent.VK_NUMPAD7) {
			wateranimationOn = true;
		 }
		
		if (key == KeyEvent.VK_NUMPAD8) {
			wateranimationOn = false;
		}
		
		if (key == KeyEvent.VK_SPACE) {
			thrustup = true;
			boostmaxrange = 5;
			evaluate.ladderStatus = 1;
		}
		if (key == KeyEvent.VK_UP) {
			if(!moving) {
				moving = true;
			}
			up = true;
		}
		if (key == KeyEvent.VK_DOWN) {
			if(!moving) {
				moving = true;
			}
			down = true;
		}
		if (key == KeyEvent.VK_LEFT) {
			if(!moving) {
				moving = true;
			}
			left = true;
		}
		if (key == KeyEvent.VK_RIGHT) {
			if(!moving) {
				moving = true;
			}
			right = true;
		}
		if (key == KeyEvent.VK_SHIFT) {
			running = true;
		}
		if (key == KeyEvent.VK_ESCAPE) {
			System.exit(1);
		}
		if (key == KeyEvent.VK_F4) {
			if (!debug) {
				debug = true;
			} else {
				debug = false;
			}
		}
		
		if (key == KeyEvent.VK_F1) {
			DungeonLevelLoader.world.changeToWorld("world", "map5");
			level = 1;
		}
		
		if (key == KeyEvent.VK_F2) {
			DungeonLevelLoader.world.changeToWorld("world2", "map2");
			level = 2;
		}
		
		if (key == KeyEvent.VK_F3) {
			DungeonLevelLoader.world.changeToWorld("world3", "map3");
			level = 3;
		}
	}

	@Override
	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();
		
		if (key == KeyEvent.VK_SPACE) {
			boostmaxrange = 0;
			thrustup = false;
		}
		
		if (key == KeyEvent.VK_UP) {
			up = false;
		}
		if (key == KeyEvent.VK_DOWN) {
			down = false;
		}
		if (key == KeyEvent.VK_LEFT) {
			left = false;
		}
		if (key == KeyEvent.VK_RIGHT) {
			right = false;
		}	
		if (key == KeyEvent.VK_SHIFT) {
			running = false;
		}	
		if (key == KeyEvent.VK_ESCAPE) {
			System.exit(1);
		}
	}

	@Override
	public void keyTyped(KeyEvent e) {
		
	}
	
	public void getPoint() {
		
	}
	
	/////////////////////////////
	// Getters
	////////////////////////////
	
	public Vector2F getPos() {
		return pos;
	}
	
	public float getMaxSpeed() {
		return maxSpeed;
	}
	
	public float getSlowdown() {
		return slowdown;
	}
	
	public World getWorld() {
		return world;
	}
	
	public static boolean isDebuging() {
		return debug;
	}
	
	public boolean isMoving() {
		return moving;
	}
	
	public boolean hasSpawned() {
		return spawned;
	}
	
	public static int getGold() {
		return Player.gold;
	}
	
	public static int getBoost() {
		return Player.boostmaxrange;
	}
	
	public static int getCountBoost() {
		return Player.countBoost;
	}
	
	public int setCountBoost(int countBoost) {
		this.countBoost = countBoost;
		return countBoost;
	}
	
	public float getMapMoveX() {
		return world.map_pos.xpos;
	}
	
	public float getMapMoveY() {
		return world.map_pos.ypos;
	}
}
Check.java - Video 19
package dungeonmain;

import gamestate.GameStateManager;
import gamestates.DungeonLevelLoader;
import generator.Block;
import generator.TileManager;
import generator.World;
import generator.Block.BlockType;
import items.GameItems;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.util.Arrays;

import moveableobjects.Player;
import sounds.Sound;
import status.HealthStatus;

// Tutorial 19 0:43
public class Check extends GameItems{
	
	@SuppressWarnings("unused")
	private static Vector2F pos;
	public static TileManager tiles;
	public static World world;
	private static int width = 42;	 
	private static int height = 42; 
	public static Vector2F map_pos = new Vector2F();
	public static boolean foundChest;
	public static boolean foundRing;
	public static boolean foundKey;
	public static boolean foundLadder;
	
	public static int doorlocked = 1;
	public static int doorlocked2 = 1;
	public static int onLadder = 0;
	public static int ladderStatus = 0;
	public static int gravityOff;
	
	public static boolean doorislocked;
	public static boolean spiderImpact;
	public static String enemyMsg;
	public static boolean doorStatus;
	public static boolean keyStatus;
	public static boolean keyStatus2;
	
	public static GameItems gItems;
	public static Sound sound;
	
	public static Player playerStatus;
	public static boolean playerhitWall;
	
	// Check class variables
	public static int gold;
	public static int ring;
	public static int door;
	public static int key;
	public static int bites;
	
	public static int armor = 0;
	public static int clock = 0;
	public static int infection = 0;
	
	public static int[] chestItem = {0,30,0,25,35,0,0};
	public static int chestCount = 0;
	
	public static Raster buffer;
	public static Graphics2D g;

	public static GameItems bonusScore;
	static GameStateManager gsm;
	public static DungeonLevelLoader stats;
	
	public static Block tileInit;
	private static final int CHEST_SOUND=1;
	private static final int SPIDER_SOUND=2;
	private static final int RING_SOUND=3;
	private static final int COINS_SOUND=4;
	public static Effect soundeffect;
	public static String soundString;
	
	// Check for 2 points on the player. Loop through all the
	// blocks. Check whether they are solid
	// If the block contains p1, p2 return true
	
	// "Point" represents a "location" on the Player

	
	// Applet example: https://docs.oracle.com/javase/tutorial/2d/basic2d/
	//redtowhite = new GradientPaint(0,0,color.RED,100, 0,color.WHITE);

	public static boolean ImpactBlock(Point p1, Point p2) {
		
		for (Block block : TileManager.blocks) {
			// BufferedImage src = ImageIO.read(new File("abc.jpg"));

			// search for treasure chest
			if (block.isTreasureChest()) {
				//if (Arrays.asList(chestItem).contains("0")) {
				//for(int i=0; i < chestItem.length; i++) {
					//if (chestItem[1] == 30 || chestItem[3] == 25 || chestItem[4] == 35) {
						if (block.contains(p1) || block.contains(p2)) {
							
							//setFoundChest(true);
							//tiles.blocks.add(new Block(new Vector2F(2432,512), BlockType.FLOOR_1).isTreasureChest(false));
							
							//   public static int[] chestItem = {0,30,0,25,35,0,0};
							// 2432,512
							//if (chestItem[1] == 30) {
							 
							Point a = p1;
							Point b = p2;
							
							float x = world.map_pos.ypos - width / 2;
							float y = world.map_pos.ypos - height;
							World w = new World("My world", stats, gsm);
							
								//3712,1280
								tiles.blocks.add(new Block(new Vector2F(x,y), BlockType.HEALTH).isTreasureChest(false));
								tiles.blocks.remove(new Block(new Vector2F(x,y), BlockType.HEALTH).isTreasureChest(false));
								chestItem[1] = -1;
								armor+=250;
								chestCount++;
								System.out.println("Chest 1"); 
								gItems = new GameItems();
								gItems.ItemsFound();
								gamescore = gamescore + bonusScore.getGameScore();
								setFoundChest(false);
								gamesoundEffect(1);
								//CHEST_SOUND = 1;
								
								//if (playerStatus.playsoundOnce) {
								//	sound = new Sound("/SFX/ding.wav");
								//	sound.play();
								//	playerStatus.playsoundOnce = false;
								//}
 
								//Point a = p1;
								//Point b = p2;
								//System.out.println("Point:" + a.getX() + "," + b.getY()); 
								
								//float x = world.map_pos.ypos;
								//float y = world.map_pos.ypos;
								
								//float x = world.tilemapPos[0];
								//float y = world.tilemapPos[1];
								
								System.out.println("Player:" + x + "," + y); 
								break;
							//}
						}

			}
			
			// Teleporter
			if (block.isTeleporter()) {
				if (block.contains(p1) || block.contains(p2)) {
					gamesoundEffect(2);
					DungeonLevelLoader.world.changeToWorld("world2", "map2");
					playerStatus.level = 2;
					System.out.println("Teleport was found!!!");
				}
			}
			
			if (block.isDiamondRing()) {
				if (block.contains(p1) || block.contains(p2)) {
					setFoundDiamondRing(true);
					ring++;
					score+=100;
					gItems = new GameItems();
					gItems.playerScore();
					gItems.score += 100;
					gamescore = gamescore + bonusScore.getGameScore();
					gamesoundEffect(3);
				}
				//return true;
			}
			
			if (block.isDoor1Open()) {
				if (block.contains(p1) || block.contains(p2)) {
					if (doorlocked == 1) {
						setDoorIsLocked(true);
						//ring++;
						return true; // open pathway
					}
					else
						return false; // closed pathway
				}
			}
			
			
			if (block.isDoor2Open()) {
				if (block.contains(p1) || block.contains(p2)) {
					if (doorlocked2 == 1) {
						setDoorIsLocked(true);
						//ring++;
						return true; // open pathway
					}
					else
						return false; // closed pathway
				}
			}
			
			if (block.isSpider()) {
				if (block.contains(p1) || block.contains(p2)) {
					setSpiderNear(true);
					bites++;
					infection += (bites/8) * 2;
					stats.HEALTH -= 1;
					gamesoundEffect(2);
					//SPIDER_SOUND = 2;
					//2560,384 - left spider
					//tiles.blocks.add(new Block(new Vector2F(4224,384), BlockType.ENEMY_1).isTreasureChest(false));
				}
			}
			
			if (block.isLadder()) {
				if (block.contains(p1) || block.contains(p2)) {
					setFoundLadder(true);
					//System.out.println("Ladder was found");
					onLadder = 1;
					ladderStatus = 1;
					gravityOff = 1;
					return false;
				}
				else 
				{
					//onLadder = 0;
					ladderStatus = 0; 
					gravityOff = 0;
					//System.out.println("Ladder was NOT found");
				}
			}
			
			if (block.isDoorOpen()) {
				if (block.contains(p1) || block.contains(p2)) {
					if (doorlocked == 1) {
						door = 0;
					}
					else {
						setDoorOpen(true);
						door++;
					}
				}
			}
				
			if (block.isSolid()) {
				if (block.contains(p1) || block.contains(p2)) {
					playerStatus = new Player();
					playerStatus.setCountBoost(0);
					playerhitWall = true;
					return true; // if true, locks that position
				}
				playerhitWall = false;
			}
			
			// If player has touched the door (x,y) 
			// set doorvariable = 0 (because the door is no longer locked)
			tiles = new TileManager();
			if (block.isKey() && doorlocked == 1) {
				if (block.contains(p1) || block.contains(p2)) {
					setKeyFound(true);
					// tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.KEY_1).isKey(true));
	
					// 5760, 2176
					tiles.blocks.add(new Block(new Vector2F(2176, 768), BlockType.FLOOR_1).isSolid(false));
					key++;
					// remove the key
					//block.isKey(true);
					
					// the code below makes the key position solid (can't pass through) 
					//tiles.blocks.add(new Block(new Vector2F(3328,512), BlockType.KEY_1).isSolid(false));
					tiles.blocks.add(new Block(new Vector2F(3328,512), BlockType.FLOOR_1).isSolid(false));
					doorlocked = 0; // door is now open
					gamescore+=100;
				}
			}
			
				
			if (block.isKey2() && doorlocked2 == 1) {
				if (block.contains(p1) || block.contains(p2)) {
					setKeyFound2(true);
					key++;			
					// the code below makes the key position solid (can't pass through) 
					tiles.blocks.add(new Block(new Vector2F(4352,384), BlockType.FLOOR_1).isSolid(false));
					tiles.blocks.add(new Block(new Vector2F(5120,768), BlockType.FLOOR_1).isSolid(false));
					doorlocked2 = 0; // door is now open
					gamescore+=100;
				}
			}
			
			// Search doors
			if (block.isDoor1Open() && doorlocked == 0) {
				if (block.contains(p1) || block.contains(p2)) {
					setKeyFound(true);
					tiles.blocks.add(new Block(new Vector2F(2176, 768), BlockType.STONE_1).isSolid(false));
					doorlocked = 0; // door is now open
				}
			}
		}
		
		return false;
	}
	
	public enum Effect {
		CHEST_SOUND, SPIDER_SOUND, RING_SOUND, COINS_SOUND
	}
	
	public static void gamesoundEffect(int i) {
		switch(i) {
		case CHEST_SOUND:
			soundString = "ding";
			break;
		case SPIDER_SOUND:
			soundString = "spiderbite";
			break;
		case RING_SOUND:
			soundString = "beep";
			break;
		case COINS_SOUND:
			soundString = "coins";
			break;
		}
		
		if (!playerStatus.playsoundOnce) {
			sound = new Sound("/SFX/" + soundString + ".wav");
			sound.play();
			playerStatus.playsoundOnce = true;
		}
	}
	
	public static boolean setTreasureInit(boolean isTreasureInit) {
		return isTreasureInit = isTreasureInit;
	}
	
	public static boolean setFoundChest(boolean isTreasureChest) {
		return isTreasureChest = isTreasureChest;
	}
	
	public static boolean setFoundDiamondRing(boolean foundRing) {
		return foundRing = foundRing;
	}
	
	public static boolean setDoorIsLocked(boolean foundRing) {
		return doorislocked = doorislocked;
	}
	
	public static boolean setFoundKey(boolean foundKey) {
		return foundKey = foundKey;
	}
	
	public static boolean setFoundLadder(boolean foundLadder) {
		return foundLadder = foundLadder;
	}
	
	public static boolean setSpiderNear(boolean spiderImpact) {
		return spiderImpact = spiderImpact;
	}
	
	public static String setEnemyMsg(String enemyMsg) {
		return enemyMsg = enemyMsg;
	}
	
	public static boolean setDoorOpen(boolean doorStatus) {
		return doorStatus = doorStatus;
	}
	
	public static boolean setKeyFound(boolean keyStatus) {
		return keyStatus = keyStatus;
	}
	
	public static boolean setKeyFound2(boolean keyStatus) {
		return keyStatus2 = keyStatus2;
	}
	
	public static int getKey() {
		return key;
	}
	
	public static int getLadder() {
		return onLadder;
	}
	
	public static int getLadderStatus() {
		return ladderStatus;
	}
	
	public static int getGameScore() {
		return gamescore;
	}
	
	public static int getArmor() {
		return armor;
	}
	
	public static int getClock() {
		return clock;
	}
	
	public static int getInfection() {
		return infection;
	}
}
 
Animator.java - Video 22
package dungeonmain;

import java.awt.image.BufferedImage;
import java.util.ArrayList;


// Tutorial 22: 0.56
public class Animator {
	
	private ArrayList frames;
	private volatile boolean running = false;
	public BufferedImage sprite;
	
	private long prevTime, speed;
	private int frameatPause, currentFrame;
	
	public Animator(ArrayList frames)  {
		this.frames = frames;
	}
	
	public void setSpeed(long speed) {
		this.speed = speed;
	}
	
	public void update(long time) {
		if (running) {
			if (time - prevTime >= speed) {
				currentFrame++;
				try {
					if (currentFrame < frames.size()) {
						sprite = frames.get(currentFrame);
					}
					else {
						reset();
					}
				}catch (IndexOutOfBoundsException e) {
					reset();
					sprite = frames.get(currentFrame);
					//e.printStackTrace();
				}
				prevTime = time;
			}
		}
	}
	
	public void play() {
		running = true;
		prevTime = 0;
		frameatPause = 0;
		currentFrame = 0;
	}
	
	public void stop() {
		running = false;
		prevTime = 0;
		frameatPause = 0;
		currentFrame = 0;
	}
	
	public void pause() {
		frameatPause = currentFrame;
		running = false;
	}
	
	public void resume() {
		currentFrame = frameatPause;
	}
	
	public void reset() {
		currentFrame = 0;
	}
	
	public boolean isDoneAnimating() {
		if (currentFrame == frames.size()) {
			return true;
		}else  {
			return false;
		}
	}

}

HUDManager.java - Video 25
package managers;

import generator.World;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;

import dungeonmain.Check;
import dungeonmain.Light;
import dungeonmain.Main;
import dungeonmain.Vector2F;
import dungeonmain.loadImageFrom;
import moveableobjects.Player;

// Tutorial 25 2:36
public class HUDManager {
	
	private BufferedImage light;
	// position lightmap
	private BufferedImage lightmap = new BufferedImage(100 * 32, 100 * 32, BufferedImage.TYPE_INT_ARGB);
	private ArrayList lights = new ArrayList();
	@SuppressWarnings("unused")
	private Vector2F lightm = new Vector2F();
	@SuppressWarnings("unused")
	private boolean callOnce = false;
	private World world;
	@SuppressWarnings("unused")
	private Player action;
	private Check impact;
	
	public HUDManager(World world) {
		this.world = world;
		light = loadImageFrom.LoadImageFrom(Main.class, "Light.png");
		//addLights();
	}
	
	@SuppressWarnings("unused")
	private void addLights() {
		//lights.add(new Light(player.getPos().xpos, player.getPos().ypos, 20, 120)); // Fix later
		lights.add(new Light(200, 200, 200, 220));
	}
	
	public void UpdateLights() {
		Graphics2D g = null;
		if (g == null) {
			g = (Graphics2D) lightmap.getGraphics();
		}
		
		g.setColor(new Color(0,0,0,255));
		// draw blackbox on entire screen
		g.fillRect(0, 0, lightmap.getWidth(), lightmap.getHeight());
		g.setComposite(AlphaComposite.DstOut);
		
		for (Light light : lights) {
			light.render(g);
			//light.lightpos.xpos++;	// move lightmap on the screen
		}
		g.dispose();
	}
	
	@SuppressWarnings("static-access")
	public void render(Graphics2D g) {
		g.setColor(Color.WHITE);
		g.drawImage(light, 0, 0, Main.width, Main.height, null);
		
		if (world.getPlayer().isDebuging()) {
			g.drawString("Chest:" + Check.foundChest, 30, 30);
			g.drawString("[MapXpos]"+world.getWorldXpos(), 30, 60);
			g.drawString("[MapYpos]"+world.getWorldYpos(), 30, 90);
			g.drawString("[PlayerXpos]"+world.getPlayer().getPos().xpos, 30, 120);
			g.drawString("[PlayerYpos]"+world.getPlayer().getPos().ypos, 30, 150);
			g.drawString("[Current World Blocks]"+world.getWorldBlocks().getBlocks().size(), 30, 180);
			g.drawString("[Current Loaded World]"+world.getWorldBlocks().getLoadedBlocks().size(), 30, 210);
			g.drawString("Gold:" + impact.gold, 30, 240);
			g.drawString("Ring:" + impact.ring, 30, 270);
			g.drawString("Door:" + impact.door,30, 300);
			g.drawString("Key:" + impact.key, 30, 330);
			g.drawString("Bites:" + impact.bites, 30, 360);
			g.drawString("Chest totals:" + impact.chestCount, 30, 390);
			g.drawString("Ladder: " + impact.getLadderStatus(), 30, 420);
			g.drawString("Number" + (int)(Math.random()*100),30, 450);
			
			if (impact.spiderImpact == true) {
				g.drawString("Spider bite!" + impact.enemyMsg, 30, 330);
			} else {
				impact.enemyMsg = "";
				g.drawString("" , 30, 330);
			}
			
			//g.drawString("x" + world.getWorldChestXPos(), 30, 240);
			//g.drawString("y" + world.getWorldChestYPos(), 30, 270);
			//System.out.println(world.getWorldBlocks().getLoadedBlocks());
			
		}
		
		// Light example 1
		//g.drawString(player.getPos().xpos + "", 200, 200);
	}
}
Light.java - Video 26
package dungeonmain;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RadialGradientPaint;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;

// Tutorial 26: 4:49 (Done)
public class Light {

	public Vector2F lightpos = new Vector2F();
	@SuppressWarnings("unused")
	private int radius;
	@SuppressWarnings("unused")
	private int lightPower;
	private BufferedImage image;
	
	public Light(float xpos, float ypos, int radius, int lightPower) {
		this.lightpos.xpos = xpos;
		this.lightpos.ypos = ypos;
		this.radius = radius;
		this.lightPower = lightPower;
		
		Point2D center = new Point(radius, radius);
		@SuppressWarnings("unused")
		Point2D focus = new Point(radius, radius);
		
		float[] dist = {0F, 1F};
		Color[] colour = {new Color(0,0,0,lightPower), new Color(0,0,0,0)};
		
		image = new BufferedImage(radius * 2, radius * 2, BufferedImage.TYPE_INT_ARGB);
		Graphics2D g2 = (Graphics2D) image.getGraphics();
		
		RadialGradientPaint rgp = new RadialGradientPaint(center, radius, dist, colour);
		g2.setPaint(rgp);
		
		g2.fillOval(0, 0, radius * 2, radius * 2);
	}
	
	public void render(Graphics2D g) {
		g.drawImage(image, (int)lightpos.xpos, (int)lightpos.ypos, null);
	}
}
MouseManager.java - Video 27
package managers;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;

import dungeonmain.Assets;

public class MouseManager implements MouseListener, MouseMotionListener, MouseWheelListener 
{

	private static int mouseMovedX, mouseMovedY;
	public static Point mouse;
	
	public static boolean pressed;
	
	public void tick() {
		mouse = new Point(mouseMovedX, mouseMovedY);
	}
	
	public void render(Graphics2D g) {
		// Create square white mouse cursor
		
		// white dot
		//g.fillRect(mouseMovedX, mouseMovedY, 4, 4);
		
		if (pressed) {
			g.drawImage(Assets.getMouse_pressed(), mouseMovedX, mouseMovedY, 32,32,null);
		}else {
			g.drawImage(Assets.getMouse_unpressed(), mouseMovedX, mouseMovedY, 32,32,null);
		}
	}

	@Override
	public void mouseWheelMoved(MouseWheelEvent e) {
		
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		mouseMovedX = e.getX();
		mouseMovedY = e.getY();
	}

	@Override
	public void mouseMoved(MouseEvent e) {
		mouseMovedX = e.getX();
		mouseMovedY = e.getY();
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		if (e.getButton() == MouseEvent.BUTTON1) {
			pressed = true;
		}
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		if (e.getButton() == MouseEvent.BUTTON1) {
			pressed = false;
		}	
	}
}
World.java - Video 29
package generator;

import gamestate.GameStateManager;
import gamestates.DungeonLevelLoader;
import generator.Block.BlockType;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;

import moveableobjects.Player;
import dungeonmain.Assets;
import dungeonmain.Main;
import dungeonmain.Vector2F;
import dungeonmain.loadImageFrom;

public class World {
	
	public static Vector2F map_pos = new Vector2F();
	@SuppressWarnings("unused")
	private String worldName;
	public BufferedImage map;
	private int world_width;
	private int world_height;
	private int blockSize = 128;
	private Player player;
	private boolean hasGenerated;
	public static int total;
	World world;
	public static int clock=0;
	
	// LISTS
	private CopyOnWriteArrayList blockents;
	public TileManager tiles;
	
	//world spawn
	private Block spawn;
	
	// Save positions
	public static int savex;
	public static int savey;
	private ArrayList tilemapPos;
	
	//BOOLEANS
	private boolean hasSize = false;
	public DungeonLevelLoader dll;
	private GameStateManager gsm;

	public World(String worldName, DungeonLevelLoader dll, GameStateManager gsm) {
		this.worldName = worldName;
		this.dll = dll;
		this.gsm = gsm;
		Vector2F.setWorldVariables(map_pos.xpos, map_pos.ypos);
	}

	public void init() {
		blockents = new CopyOnWriteArrayList();
		tiles = new TileManager(this);
		
		map_pos.xpos = spawn.getBlockLocation().xpos - player.getPos().xpos;
		map_pos.ypos = spawn.getBlockLocation().ypos - player.getPos().ypos;
		
		if (player != null) {
			player.init(this);
		}
	}

	@SuppressWarnings("static-access")
	public void tick(double deltaTime) {
		
		Vector2F.setWorldVariables(map_pos.xpos, map_pos.ypos);
		
		if (!player.hasSpawned()) {
			spawn.tick(deltaTime);
		}
		spawn.tick(deltaTime);
		
		tiles.tick(deltaTime);
		
		if (!blockents.isEmpty()) {
			for(BlockEntity ent : blockents) {
				if (player.render.intersects(ent)) {
					ent.tick(deltaTime);
					ent.setAlive(true);
				} else {
					ent.setAlive(false);
				}
			}
		}
		
		if (player != null) {
			player.tick(deltaTime);	
		}
	}

	@SuppressWarnings("static-access")
	public void render(Graphics2D g) {
		tiles.render(g);
		
		if (!player.hasSpawned()) {
			spawn.render(g);
		}
		
		if (!blockents.isEmpty()) {
			for(BlockEntity ent : blockents) {
				if (player.render.intersects(ent)) {
					ent.render(g);
				} 
			}
		}
		
		if (player != null) {
			player.render(g);	
		}
	}

	public void generate() {
		
	}

	@SuppressWarnings("static-access")
	public void generate(String world_image_name) {
		
		map = null;
		
		if (hasSize) {
			try {
				map = loadImageFrom.LoadImageFrom(Main.class, world_image_name + ".png");
				
			} catch (Exception e) {
				
			}
			
			for (int x=0; x < world_width; x++) {
				for (int y=0; y < world_height; y++) {
					
					int col = map.getRGB(x, y);
					
					switch (col & 0xFFFFFF) {
					// If the image contains the color (gray) then add new
					// block at that x,y location
					// Then loop through the blocks and render them
					// (in TileManager class)					
					// draw the map block tile on the screen
					
					// Starry skies/sky/background
					case 0xFF7FB6: // black
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.STARS));
					break;
					case 0x007F0E:	 
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.STALAGMITE_STARS).isSolid(false));
					break;
					case 0xCCFFEF:  
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DISTANT_STAR));
					break;
					case 0x000000:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.BLACKTILE));
					break;
					case 0x00FF90:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SKY));
					break;
					case 0xFFB27F:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SKYCLOUDS));
					break;
					case 0xB6FF50:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SUN));
					break;
					case 0xB6FF00:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SKYGROUND).isSolid(true));
					break;
					case 0xFFFFFF:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.FLOOR_1));
					break;
					// Water
					case 0x0046FF:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATER_1));
						//System.out.println("Water:" + new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATER_1));			
					break;
					case 0x00AAFF:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATERBASE));
					break;
					case 0x0046A0:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATERFALLTOP));
					break;
					case 0x00466E:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATERFALL1));
					break;
					case 0x00464B:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WATERFALLBOTTOM));
					break;
					// Game won item
					case 0x7FC9FF:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.TELEPORTER_1).isTeleporter(true));
						System.out.println("Teleporter:" + new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.TELEPORTER_1).isTeleporter(true));
					break;
					case 0x009090:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.MOUNTAINS_1));
					break;
					case 0x007890:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.MOUNTAINS_2));
					break;
					case 0x3C5090:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.MOUNTAINSLEFT));
					break;
					case 0x005090:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.MOUNTAINSBASE));
					break;
					case 0x785090:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.MOUNTAINSRIGHT));
					break;
					case 0x00FFC8:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.MOUNTAINSDISTANTRIGHT));
					break;
					case 0x00A5F0:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.MOUNTAINSDISTANTLEFT));
					break;
					case 0x808080:	
					// Walls	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.STONE_1).isSolid(true));
					break;
					case 0xC0C0C0:	 	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.STONE_2).isSolid(true));
					break;
					case 0xFF00DC:	 	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.STONE_3).isSolid(true));
					break;
					case 0x00FF21:	 
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.STALAGMITE).isSolid(false));
					break;
					// Walls
					case 0x404040:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WALL_1).isSolid(true));
					break;
					case 0x7F006E:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.WALLBOTTOM).isSolid(true));
					break;
					case 0xB200FF:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.PILLAR_1).isSolid(false));
					break;
					// Ladders
					case 0x7F3300:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.LADDER_1).isLadder(true));
					break;
					case 0x7F0000:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.LADDER_STARS).isLadder(true));
					break;
					case 0x7F6A00:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.LADDERWALL).isLadder(true));
					break;
					case 0x303030:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.LADDERWALL2).isLadder(true));
					break;
					case 0xCD0000:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.LADDERINWATER).isLadder(true));
					break;
					case 0xC4FFFF:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.LADDERTOP).isLadder(true));
					break;
					case 0xC4B0FF:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.LADDERTOPBLACKTILE).isLadder(true));
					break;
					case 0xFF6A00:	
					// Game items: chest: orange
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.CHEST_1).isTreasureChest(true));
						//System.out.println("Chest:" + new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.CHEST_1));		
					break;
					case 0xFF7F7F:	
					// Game items: chest: orange
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.CHESTBLACKTILE).isTreasureChest(true));
					break;
					case 0x00FFFF:	// diamond: cyan color
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_1).isDiamondRing(true));
						//System.out.println("Diamond:" + new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_2));
					break;
					case 0xB28CFF:	 
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_2).isDiamondRing(true));
					break;
					case 0x007F7F:	// diamond: cyan color
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMONDBLACKTILE).isDiamondRing(true));
						//System.out.println("Diamond Black Tile:" + new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DIAMOND_2));
					break;
					// Doors: red color
					case 0x4800FF:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DOOR_1).isDoor1Open(true));
					break;
					case 0xFF0000:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DOOR_2).isDoor2Open(true));
						//System.out.println("Door:" + new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.DOOR_2));
					break;
					// Keys: yellow
					case 0xFFD800:	
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.KEY_1).isKey(true));
					break;
					case 0x0094FF:	// key: blue
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.KEY_2).isKey2(true));
						//System.out.println(new Block(new Vector2F(x*blockSize, y*blockSize)));
					break;
					case 0x0026FF:	
					// Enemies: dark blue
						tiles.blocks.add(new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SPIDER_1).isSpider(true));
						//System.out.println("Spider:" + new Block(new Vector2F(x*blockSize, y*blockSize), BlockType.SPIDER_1));
					break;
					}
				}
			}
		}
		hasGenerated = true;
	}

	public void setSize(int world_width, int world_height) {
		this.world_width  = world_width;
		this.world_height = world_height;
		hasSize = true;
	}
	
	public Vector2F getWorldPos() {
		return map_pos;
	}
	
	public float getWorldXpos() {
		return map_pos.xpos;
	}
	
	public float getWorldYpos() {
		return map_pos.ypos;
	}

	public void addPlayer(Player player) {
		this.player = player;
	}
	
	public void dropBlockEntity(Vector2F pos, BufferedImage block_image) {
		BlockEntity ent = new BlockEntity(pos, block_image);
		if (!blockents.contains(ent)) {
			blockents.add(ent);
		}
	}
	
	public void setWorldSpawn(float xpos, float ypos) {
		if (xpos < world_width) {
			if (ypos < world_height) {
				Block spawn = new Block(new Vector2F(xpos*blockSize,ypos*blockSize));
				this.spawn = spawn;
			}
		}
	}
	
	public Vector2F getWorldSpawn() {
		return spawn.pos;
	}
	
	public void removeDroppedBlockEntity(BlockEntity blockEntity) {
		if (blockents.contains(blockEntity)) {
			blockents.remove(blockEntity);
		}
	}
	
	public TileManager getWorldBlocks() {
		return tiles;
	}
	
	public Player getPlayer() {
		return player;
	}
	
	public boolean hasGenerated() {
		return hasGenerated;
	}
	
	public int getWorldChestXPos() {
		return savex;
	}
	
	public int getWorldChestYPos() {
		return savey;
	}
	
	public void resetWorld() {
		tiles.getBlocks().clear();
		tiles.getLoadedBlocks().clear();
		blockents.clear();
		spawn = null;
	}
	
	public void changeToWorld(String wn, String mn) {
		if (wn != worldName) {
			resetWorld();
			gsm.states.push(new DungeonLevelLoader(gsm, wn, mn));
			gsm.states.peek().init();
		} else {
			System.err.println("You are already in that world!");
		}
	}
}
BlockEntity.java - Video 30
package generator;

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Random;

import dungeonmain.Animator;
import dungeonmain.Vector2F;

public class BlockEntity extends Rectangle {
	
	private static final long serialVersionUID = 7169170114946678228L;
	private Vector2F pos;
	@SuppressWarnings("unused")
	private boolean isAlive;
	private BufferedImage block_image;
	private double rotation;
	private double rotation_speed = 0.8;
	private double blockSize = 24;
	
	
	private ArrayList waterFrame1;
	Animator ani_water1;
	private ArrayList waterFrame2;
	Animator ani_water2;
	private ArrayList waterFrame3;
	Animator ani_water3;
	private ArrayList waterFrame4;
	Animator ani_water4;

	public BlockEntity(Vector2F pos, BufferedImage block_image) {
		this.pos = pos;
		this.block_image = block_image;
		rotation = new Random().nextInt(180);
		setBounds((int)pos.xpos, (int)pos.ypos, (int)blockSize, (int)blockSize);
	}
	
	public void tick(double deltaTime) {
		setBounds((int)pos.xpos, (int)pos.ypos, (int)blockSize, (int)blockSize);
		rotation -= rotation_speed;
	}
	
	public void render(Graphics2D g) {
		g.rotate(Math.toRadians(rotation), 
				pos.getWorldLocation().xpos + blockSize / 2, 
				pos.getWorldLocation().ypos + blockSize /2);
		
		g.drawImage( ani_water1.sprite, 
				(int) pos.getWorldLocation().xpos,
				(int) pos.getWorldLocation().ypos,
				(int) blockSize, (int) blockSize, null);
		
		g.drawRect((int) pos.getWorldLocation().xpos, 
				(int) pos.getWorldLocation().ypos,
				(int) blockSize, (int) blockSize);
	
		g.rotate(-Math.toRadians(rotation), 
				pos.getWorldLocation().xpos + blockSize / 2, 
				pos.getWorldLocation().ypos + blockSize /2);
	}
	
	public void setAlive(boolean isAlive) {
		this.isAlive = isAlive;
	}

}
Sound.java
package sounds;

import java.applet.Applet;
import java.applet.AudioClip;

public class Sound {
	
	private AudioClip clip;
	public static final Sound sound1 = new Sound("/bounce.wav");
	
	public Sound(String filename) {
		try {
			clip = Applet.newAudioClip(Sound.class.getResource(filename));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void play() {
		try {
			new Thread() {
				public void run() {
					clip.play();
				}
			}.start();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
}
Comment Box is loading comments...
Subscribe to the Programmermind newsletter
Copyright 2010 - All Rights Reserved