function OblitScene()
{
	if (key_play || key_record)
	{
		//change the map tiles
		SetTile(447,48, 2,0);
		SetTile(448,48, 2,0);
	
		SetTile(447,49,2, 575);
		SetTile(448,49,2,576);
		
		SetTile(459,49,0,0);
		SetTile(459,48,0,0);
		
		cur_weap = 9;
		entities[0].dir1 = "aim1";
		
		weap_possess[7] = 1;
		ammo_array[cur_weap].curammo = 10;
		ammo_array[cur_weap].curclip = 1;



		SetPersonDirection("main_gun8", GetPersonDirection(entities[0].name));
		SetPersonFrame("main_gun8", GetPersonFrame(entities[0].name));
		SetPersonX("main_gun8", entities[0].x);
		SetPersonY("main_gun8", GetPersonY(entities[0].name));
		SetPersonLayer("main_gun8", GetPersonLayer(entities[0].name));
	
		SetPersonX(entities[0].name, -100);
		SetPersonX("main_gun2", -100);
		SetPersonX("main_gun3", -100);
		SetPersonX("main_gun4", -100);
		SetPersonX("main_gun5", -100);
		SetPersonX("main_gun6", -100);
		SetPersonX("main_gun7", -100);
		return;
	}


	var skip_tiles = 0;
	
	var images = new Array(9);
	images[0] = LoadImage("oblit scene/door_eye1_001.png");
	images[1] = LoadImage("oblit scene/door_eye1_002.png");
	images[2] = LoadImage("oblit scene/door_eye1_003.png");
	images[3] = LoadImage("oblit scene/door_eye1_004.png");
	images[4] = LoadImage("oblit scene/door_eye1_005.png");
	images[5] = LoadImage("oblit scene/door_eye1_006.png");
	images[6] = LoadImage("oblit scene/door_eye1_007.png");
	images[7] = LoadImage("oblit scene/door_eye1_008.png");
	images[8] = LoadImage("oblit scene/door_eye1_009.png");
	images[9] = LoadImage("oblit scene/door_eye1_010.png");
	images[10] = LoadImage("oblit scene/door_eye1_011.png");
	images[11] = LoadImage("oblit scene/door_eye1_012.png");
	images[12] = LoadImage("oblit scene/door_eye1_013.png");
	images[13] = LoadImage("oblit scene/door_eye1_014.png");
	images[14] = LoadImage("oblit scene/door_eye1_015.png");

	images[15] = LoadImage("oblit scene/door_opened_remains1_001.png");
	
	images[16] = LoadImage("oblit scene/door_opened1_001.png");
	images[17] = LoadImage("oblit scene/door_opened1_002.png");
	images[18] = LoadImage("oblit scene/door_opened1_003.png");

	images[19] = LoadImage("oblit scene/oblit_pickup1_01.png");
	images[20] = LoadImage("oblit scene/oblit_pickup1_02.png");
	images[21] = LoadImage("oblit scene/oblit_pickup1_03.png");
	images[22] = LoadImage("oblit scene/oblit_pickup1_04.png");
	images[23] = LoadImage("oblit scene/oblit_pickup1_05.png");
	images[24] = LoadImage("oblit scene/oblit_pickup1_06.png");
	images[25] = LoadImage("oblit scene/oblit_pickup1_07.png");
	images[26] = LoadImage("oblit scene/oblit_pickup1_08.png");
	images[27] = LoadImage("oblit scene/oblit_pickup1_09.png");
	images[28] = LoadImage("oblit scene/oblit_pickup1_10.png");
	images[29] = LoadImage("oblit scene/oblit_pickup1_11.png");
	images[30] = LoadImage("oblit scene/oblit_pickup1_12.png");
	images[31] = LoadImage("oblit scene/oblit_pickup1_13.png");
	images[32] = LoadImage("oblit scene/oblit_pickup1_14.png");
	
	images[33] = LoadImage("oblit scene/oblit_ready1_001.png");
	images[34] = LoadImage("oblit scene/oblit_ready1_002.png");
	images[35] = LoadImage("oblit scene/oblit_ready1_003.png");
	images[36] = LoadImage("oblit scene/oblit_ready1_004.png");

	images[37] = LoadImage("oblit scene/oblit_shield_face_back_001.png");
	images[38] = LoadImage("oblit scene/oblit_shield_face_back_002.png");
	images[39] = LoadImage("oblit scene/oblit_shield_face_back_003.png");
	images[40] = LoadImage("oblit scene/oblit_shield_face_back_004.png");
	images[41] = LoadImage("oblit scene/oblit_shield_face_back_005.png");

	images[42] = LoadImage("oblit scene/rework_closeup1_001.png");
	images[43] = LoadImage("oblit scene/rework_closeup1_002.png");
	images[44] = LoadImage("oblit scene/rework_closeup1_003.png");


//oblit pickup
//dooreye
//oblit shield face back
//door opened
//oblit ready
//rework closeup
//remains
//end



var skip_aim = 1;
var skip_aim2 = 1;


	var lasttime = GetTime();

	if (skip_tiles != 1)
	{
		
		for (wi=0;wi<=20;wi++)
		{
			//draw back stuff;
			RenderBackground();
			Rectangle(0,0,320,240, CreateColor(0,0,0,255*wi/20));
			FlipScreen();
			while (GetTime()-lasttime < 1000/30);
			lasttime = GetTime();
		}
		lasttime = GetTime();
		PauseHeart();
		PauseAllMusic();
		
		//change the map tiles
		SetTile(447,48, 2,0);
		SetTile(448,48, 2,0);
	
		SetTile(447,49,2, 575);
		SetTile(448,49,2,576);
		
		cur_weap = 9;
		entities[0].dir1 = "aim1";
		
		weap_possess[7] = 1;
		ammo_array[cur_weap].curammo = 10;
		ammo_array[cur_weap].curclip = 1;



		SetPersonDirection("main_gun8", GetPersonDirection(entities[0].name));
		SetPersonFrame("main_gun8", GetPersonFrame(entities[0].name));
		SetPersonX("main_gun8", entities[0].x);
		SetPersonY("main_gun8", GetPersonY(entities[0].name));
		SetPersonLayer("main_gun8", GetPersonLayer(entities[0].name));
	
		SetPersonX(entities[0].name, -100);
		SetPersonX("main_gun2", -100);
		SetPersonX("main_gun3", -100);
		SetPersonX("main_gun4", -100);
		SetPersonX("main_gun5", -100);
		SetPersonX("main_gun6", -100);
		SetPersonX("main_gun7", -100);


	}

	
	var fratey = 1000/12;

	var quity = false;
	var db_message = "";

	function DrawBars()
	{
		Rectangle(0,0,320,20, CreateColor(0,0,0,255));
		Rectangle(0,240-20,320,20, CreateColor(0,0,0,255));
		font2.drawText(5,224, db_message);
	}

	function CheckExit()
	{
		while(AreKeysLeft())
		{
			switch(GetKey())
			{
				case KEY_ENTER:
				{
					quity = true;
				
				}
				case KEY_ESCAPE:
				{
					quity = true;
				
				}
				case KEY_SPACE:
				{
					quity = true;
				
				}
			}
		}
	}
	
	
	//19-32
	for (wi=0;wi<14;wi++)
	{
		while(GetTime()-lasttime < 1000/8)
		{
			images[19+wi].blit(0,0);
			DrawBars();
			if (wi < 8)
				Rectangle(0,0,320,240,CreateColor(0,0,0,255-wi*255/8));
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	}

	while(GetTime()-lasttime < 2000 && !quity)
	{
		images[3].blit(0,0);
		DrawBars();
		FlipScreen();
		CheckExit();
	}
	lasttime = GetTime();

	for (wi=2;wi>0;wi--)
	{
		while(GetTime()-lasttime < 1000/8)
		{
			images[wi].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	}
	

	while(GetTime()-lasttime < 2000 && !quity)
	{
		images[0].blit(0,0);
		DrawBars();
		FlipScreen();
		CheckExit();
	}
	lasttime = GetTime();

	for (wi=1;wi<3;wi++)
	{
		while(GetTime()-lasttime < 1000/8)
		{
			images[wi].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	}

	while(GetTime()-lasttime < 2000 && !quity)
	{
		images[3].blit(0,0);
		DrawBars();
		FlipScreen();
		CheckExit();
	}
	lasttime = GetTime();


	for (wi=4;wi<8;wi++)
	{
		while(GetTime()-lasttime < 1000/16)
		{
			images[wi].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	}


	for (wj=8;wj<15;wj++)
	{

		while(GetTime()-lasttime < fratey*2 && !quity)
		{
			if (GetTime()-lasttime < fratey*2)
			{
				images[wj].blit(0,0);
				if (wj < 14)
					images[wj+1].blitMask(0,0, CreateColor(255,255,255,255*(GetTime()-lasttime)/(fratey*3)));
			}
			else
				images[wj].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	}
	
	
	while(GetTime()-lasttime < 2000 && !quity)
	{
		images[14].blit(0,0);
		DrawBars();
		FlipScreen();
		CheckExit();
	}
	lasttime = GetTime();










	for (wj=37;wj<42;wj++)
	{

		while(GetTime()-lasttime < fratey*4 && !quity)
		{
			if (GetTime()-lasttime < fratey*4)
			{
				images[wj].blit(0,0);
				if (wj < 41)
					images[wj+1].blitMask(0,0, CreateColor(255,255,255,255*(GetTime()-lasttime)/(fratey*4)));
			}
			else
				images[wj].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	}


	var lasttime2 = GetTime();
	while(GetTime()-lasttime < fratey*18 && !quity)
	{
		images[16].blit(0,0);
		Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(241, 186, 135, 96-((GetTime()-lasttime2)*96)/(fratey*16)));
		DrawBars();
		FlipScreen();
		CheckExit();
	}
	lasttime = GetTime();


	for (wj=17;wj<19;wj++)
	{

		while(GetTime()-lasttime < fratey*2 && !quity)
		{
			images[wj].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	}

	while(GetTime()-lasttime < fratey*6 && !quity)
	{
		images[18].blit(0,0);
		DrawBars();
		FlipScreen();
		CheckExit();
	}
	lasttime = GetTime();


	if (skip_aim == 0)
	{
		while(GetTime()-lasttime < fratey*6 && !quity)
		{
			images[36].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	
		for (wj=36;wj>32;wj--)
		{
	
			while(GetTime()-lasttime < fratey*2 && !quity)
			{
				images[wj].blit(0,0);
				DrawBars();
				FlipScreen();
				CheckExit();
			}
			lasttime = GetTime();
		}
		while(GetTime()-lasttime < fratey*8 && !quity)
		{
			images[33].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
	}
	else
	{
	/*
		while(GetTime()-lasttime < fratey*16 && !quity)
		{
			images[33].blit(0,0);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
		lasttime = GetTime();
*/	
	}

//GetKey();


	while(GetTime()-lasttime < fratey*12 && !quity)
	{
		images[42].blit(0,0);
		DrawBars();
		FlipScreen();
		CheckExit();
	}
	lasttime = GetTime();

	lasttime2 = GetTime();
	if (skip_aim2 == 1)
	{
		for (wj=42;wj<45;wj++)
		{
			while(GetTime()-lasttime < fratey*4 && !quity)
			{
				images[wj].blit(0,0);
				Rectangle(0,0, GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,255*(GetTime()-lasttime2)/(fratey*12)));
				DrawBars();
				FlipScreen();
				CheckExit();
			}
			lasttime = GetTime();
		}
	}
	else
	{
		for (wj=42;wj<45;wj++)
		{
			while(GetTime()-lasttime < fratey*4 && !quity)
			{
				images[wj].blit(0,0);
				Rectangle(0,0, GetScreenWidth(), GetScreenHeight(), CreateColor(255,255,255,255*(GetTime()-lasttime2)/(fratey*12)));
				DrawBars();
				FlipScreen();
				CheckExit();
			}
			lasttime = GetTime();
		}
	
		for (wj=0;wj<8;wj++)
		{
			while(GetTime()-lasttime < fratey*2 && !quity)
			{
				Rectangle(0,0, GetScreenWidth(), GetScreenHeight(), CreateColor(255,255,255,255));
				DrawBars();
				FlipScreen();
				CheckExit();
			}
			lasttime = GetTime();
		}
	
	
		var ry = -20;
		lasttime = GetTime();
		for (wj=0;wj<15;wj++)
		{
			while(GetTime()-lasttime < fratey*2 && !quity)
			{
				images[15].blit(0,ry);
				Rectangle(0,0, GetScreenWidth(), GetScreenHeight(), CreateColor(255,255,255,255-255*wj/15));
				DrawBars();
				FlipScreen();
				CheckExit();
			}
			lasttime = GetTime();
		}
	
		for (wj=0;wj<4;wj++)
		{
			while(GetTime()-lasttime < fratey*2 && !quity)
			{
				images[15].blit(0,ry);
				DrawBars();
				FlipScreen();
				CheckExit();
			}
			lasttime = GetTime();
		}
	
	
	
		var wcount = 0;
		var wmessagey = " Leigh: ...Oh BABY.";
		db_message = "";
	
		for (wj=0;wj<14;wj++)
		{
			while(GetTime()-lasttime < fratey*1 && !quity)
			{
				images[15].blit(0,ry);
				DrawBars();
				FlipScreen();
				CheckExit();
			}
	
			lasttime = GetTime();
			wcount++;
			db_message = wmessagey.substr(0,wcount);
	
		}
	
		while(GetTime()-lasttime < fratey*5 && !quity)
		{
			images[15].blit(0,ry);
			DrawBars();
			FlipScreen();
			CheckExit();
		}
	
	
		for (wj=0;wj<14;wj++)
		{
			while(GetTime()-lasttime < fratey*1 && !quity)
			{
				images[15].blit(0,ry);
				DrawBars();
				FlipScreen();
				CheckExit();
			}
	
			lasttime = GetTime();
			wcount++;
			db_message = wmessagey.substr(0,wcount);
	
		}
	
	
	
		for (wj=0;wj<15;wj++)
		{
			while(GetTime()-lasttime < fratey*1 && !quity)
			{
				images[15].blit(0,ry);
				Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,255*wj/15));
				DrawBars();
				FlipScreen();
				CheckExit();
			}
			lasttime = GetTime();
		}
	
		for (wj=0;wj<15;wj++)
		{
			while(GetTime()-lasttime < fratey*1 && !quity)
			{
				DrawBars();
				Rectangle(0,0,GetScreenWidth(), GetScreenHeight(), CreateColor(0,0,0,255*wj/15));
				FlipScreen();
				CheckExit();
			}
			lasttime = GetTime();
		}
	}

	StartHeart();
	UnPauseAllMusic();

	if (skip_tiles != 1)
	{
		SetTile(459,49,0,0);
		SetTile(459,48,0,0);

		//Level8Kill();

		for (wi=0;wi<=20;wi++)
		{
			//draw back stuff;
			RenderBackground();
			Rectangle(0,0,320,240, CreateColor(0,0,0,255-255*wi/20));
			FlipScreen();
			while (GetTime()-lasttime < 1000/30);
			lasttime = GetTime();
		}
		lasttime = GetTime();
	}

}








function Level8Kill()
{
	SetTile(459,49,0,0);
	SetTile(459,48,0,0);
	  for (fi=1;fi<max_entities;fi++)
	  {
			if (entities[fi].name == "enemy1_legs_1" || entities[fi].name == "enemy1_legs_2" || entities[fi].name == "enemy1_legs_3" || entities[fi].name == "enemy2_legs_1" || entities[fi].name == "enemy2_legs_2")
			{
				entities[fi].hp = 0;

				if (entity_misc[entities[fi].type].blood == 1)
				{
					SpawnBlood(entities[fi].x,entities[fi].y,Math.random()*4-2,-7-3*Math.random(),1, "w", 0);
					SpawnBlood(entities[fi].x,entities[fi].y,Math.random()*4-2,-7-3*Math.random(),1, "w", 0);
					SpawnBlood(entities[fi].x,entities[fi].y,Math.random()*4-2,-7-3*Math.random(),1, "w", 0);
				}
		
				if (entities[fi].hp <=0)
				{
					if (entity_misc[entities[fi].type].blood == 1)
					{
						SpawnBlood(entities[fi].x,entities[fi].y,Math.random()*4-2,-5-3*Math.random(),1, "w", 0);
						SpawnBlood(entities[fi].x,entities[fi].y,Math.random()*4-2,-5-3*Math.random(),1, "w", 0);
						
						AddBackBlood(Math.floor(entities[fi].x/GetTileWidth()),Math.floor(entities[fi].y/GetTileHeight()),4);
						if (Math.random()<0.6)
							AddBackBlood(Math.floor(entities[fi].x/GetTileWidth()),Math.floor(entities[fi].y/GetTileHeight()+1),4);
						if (Math.random()<0.6)
							AddBackBlood(Math.floor(entities[fi].x/GetTileWidth()),Math.floor(entities[fi].y/GetTileHeight()-1),4);
						if (Math.random()<0.6)
							AddBackBlood(Math.floor(entities[fi].x/GetTileWidth()+1),Math.floor(entities[fi].y/GetTileHeight()),4);
						if (Math.random()<0.6)
							AddBackBlood(Math.floor(entities[fi].x/GetTileWidth()-1),Math.floor(entities[fi].y/GetTileHeight()),4);
					}

					SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "guts"+(2+Math.floor(3*Math.random())), 1, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
					SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "guts"+(2+Math.floor(3*Math.random())), 1, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
					SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "guts"+(2+Math.floor(3*Math.random())), 1, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);

					if (entities[fi].type == 1)
					{
						SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy1_guts1", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
						if (entities[fi].hp1 > 0)
							SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy1_arm", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
						if (entities[fi].hp2 > 0)
							SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy1_arm", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
						if (entities[fi].hp3 > 0)
						{
							SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy1_leg", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
							if (Math.random() < 0.5)
								SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy1_leg", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
						}
					}
					else if (entities[fi].type == 3)
					{
						SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy2_guts1", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
						if (entities[fi].hp1 > 0)
							SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy2_arm", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
						if (entities[fi].hp2 > 0)
							SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy2_arm", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
						if (entities[fi].hp3 > 0)
						{
							SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy2_leg", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
							if (Math.random() < 0.5)
								SpawnGuts(fi,entities[fi].x,entities[fi].y,entities[fi].vx-1+2*Math.random(),-7+2*Math.random(), "enemy2_leg", 0, gut_layer+Math.floor(2*Math.random()), entities[fi].mask);
						}
					}

					SpawnHead(fi, entities[fi].x,entities[fi].y,entities[fi].vx-4+8*Math.random(),entities[fi].vy-8+4*Math.random(), 1);
	
					entities[fi].hp = 0;

					if (entities[fi].hp3 > 0)
						entities[fi].dir2 = "die2";
					else
						entities[fi].dir2 = "legdie2";
					entities[fi].frame2 = 0;
				}
			}
	  }
}
















function OblitSceneEnd()
{
		//change the map tiles
		SetTile(200,12, 2,0);
		SetTile(201,12, 2,0);
	
		SetTile(200,13,2, 575);
		SetTile(201,13,2,576);
		
		SetTile(212,12,0,0);
		SetTile(212,13,0,0);
		
		cur_weap = 9;
		entities[0].dir1 = "aim1";
		
		weap_possess[7] = 1;
		ammo_array[cur_weap].curammo = 10;
		ammo_array[cur_weap].curclip = 1;



		SetPersonDirection("main_gun8", GetPersonDirection(entities[0].name));
		SetPersonFrame("main_gun8", GetPersonFrame(entities[0].name));
		SetPersonX("main_gun8", entities[0].x);
		SetPersonY("main_gun8", GetPersonY(entities[0].name));
		SetPersonLayer("main_gun8", GetPersonLayer(entities[0].name));
	
		SetPersonX(entities[0].name, -100);
		SetPersonX("main_gun2", -100);
		SetPersonX("main_gun3", -100);
		SetPersonX("main_gun4", -100);
		SetPersonX("main_gun5", -100);
		SetPersonX("main_gun6", -100);
		SetPersonX("main_gun7", -100);
}







