@Override
	public void draw(Graphics g) {
		if (!p.isDead()){
		/**
		 * Flips between drawing the background and drawing the foreground.
		 * the offset_X and offset_Y keeps both translations in sync during the rendering process.  Reduces shearing.
		 */
			if (drawBackground){
				offset_X = offsetX;
				offset_Y = offsetY;
				g.translate((int)offset_X, (int)offset_Y);  //(int) casting to reduce horizontal shearing.
				map.render((int)origin.x,(int)origin.y, tileX, tileY, 42, 42, 1, false);
				map.render((int)origin.x,(int)origin.y, tileX, tileY, 42, 42, 2, false);
				ArrayList<Item> items = map.getItemList();
				for (int i = 0; i < items.size(); i++){
					if (items.get(i) != null){
						items.get(i).draw(tileX,tileY);
					}
				}
				g.translate((int)offset_X *-1,(int) offset_Y*-1);	//resets the graphics translation.
				drawBackground = false;
			}
			else{
				g.translate((int)offset_X, (int)offset_Y);
				for (int i = 0; i < spawns.size(); i++){
					Spawn spawn = spawns.get(i);
					if (spawn.hasMob()){
						Mob m = spawn.getMob();
						m.draw(g, tileX, tileY);
						if (m.isOnScreen() && !m.isListed()){
							m.setListed(true);
							mobs.add(m);
						}
						if (!m.isHooked() && m.isOnScreen() && m.withinAggroDistance(p) && m.isHostile()){
							m.setHooked(true, p);
						}
					}
				}
				map.render((int)origin.x,(int)origin.y, tileX, tileY, 42, 42, 3, false);
				map.render((int)origin.x,(int)origin.y, tileX, tileY, 42, 42, 4, false);
				
				//lighting
				g.setDrawMode(Graphics.MODE_ALPHA_MAP);
				g.clearAlphaMap();
				g.setColor(new Color(255,255,255,c.getAlpha()));
				g.fillRect(Settings.CAM_X, Settings.CAM_Y, 672, 672);
				map.drawLights(g, tileX, tileY, c.getAlpha());		
				g.translate((int)offset_X *-1,(int) offset_Y*-1);	//resets the graphics translation.
				
				g.setDrawMode(Graphics.MODE_ALPHA_BLEND);
				g.setColor(new Color(0,0,0,c.getAlpha()));
				g.fillRect(Settings.CAM_X, Settings.CAM_Y, 672, 672);	
				g.setDrawMode(Graphics.MODE_NORMAL);
				g.clearAlphaMap();
				g.flush();
				drawBackground = true;
			}
		}
		else{
			g.setColor(Color.white);
			g.drawString("You are dead.", Settings.CAM_X + 290, Settings.CAM_Y + 300);
		}
	}