//Background Stage 1
let bushscroll=[]; let bush=[]; let bushrandomx=[];
let canopyscroll=[]; let canopy=[]; let canopygraphic=[]; let canopysprite=rand_int(1,3);

let leaf=0; let leaves=[]; let leaftimer=[];
let EFlightray=0; let lightray=[]; let lightraytimer=[]; let lightrayfade=[]; let lightrayscroll=[];

function randombush1{
let choice=rand_int(0,1);
if(choice==0){ let randombushmin=rand(-80,-150); return randombushmin; }
if(choice==1){ let randombushmax=rand(80,150); return randombushmax; }
}

let BGbush=("\script\Images\3DBackground\Stage 1\Bush.png");
let BGpath=("\script\Images\3DBackground\Stage 1\Path.png");
let BGtrees=("\script\Images\3DBackground\Stage 1\Trees.png");
let BGcanopy1=("\script\Images\3DBackground\Stage 1\Canopy1.png");
let BGcanopy2=("\script\Images\3DBackground\Stage 1\Canopy2.png");
let BGcanopy3=("\script\Images\3DBackground\Stage 1\Canopy3.png");
let BGceiling=("\script\Images\3DBackground\Stage 1\Ceiling.png");

let BGlightray=("\script\Images\3DBackground\Lightray.png");
let BGend=("\script\Images\3DBackground\Wall.png");
let BGleaf=("\script\Images\3DBackground\Leaf.png");

//===============================================================================================================

//Background Stage 2

let bushscroll=[]; let bush=[]; let bushrandomx=[];
let treescroll=[]; let tree=[]; let treerandomx=[];
let rockscroll=[]; let rock=[]; let rockrandomx=[];

let leaf=0; let leaves=[]; let leaftimer=[];
let EFlightray=0; let lightray=[]; let lightraytimer=[]; let lightrayfade=[]; let lightrayscroll=[];

let BGpath=("\script\Images\3DBackground\Stage 1\Path.png");
let BGgrass=("\script\Images\3DBackground\Stage 2\Grass.png");
let BGbush=("\script\Images\3DBackground\Stage 1\Bush.png");
let BGtree=("\script\Images\3DBackground\Stage 2\Tree.png");
let BGrock=("\script\Images\3DBackground\Stage 2\Rocks.png");
let BGmountains1=("\script\Images\3DBackground\Stage 2\Mountains1.png");
let BGmountains2=("\script\Images\3DBackground\Stage 2\Mountains2.png");
let BGsky=("\script\Images\3DBackground\Sky1.png");

let BGlightray=("\script\Images\3DBackground\Lightray.png");
let BGend=("\script\Images\3DBackground\Wall.png");
let BGleaf=("\script\Images\3DBackground\Leaf.png");

//===============================================================================================================

//Background Stage 3
let treescroll=[]; let tree=[]; let treerandomangle=[]; let treerandomx=[];
let EFlightray=0; let lightray=[]; let lightraytimer=[]; let lightrayfade=[]; let lightrayscroll=[];

let BGfloor1=("\script\Images\3DBackground\Stage 3\Floor1.png");
let BGfloor2=("\script\Images\3DBackground\Stage 3\Floor2.png");
let BGfloor3=("\script\Images\3DBackground\Stage 3\Floor3.png");
let BGouterwall=("\script\Images\3DBackground\Stage 3\Wall1.png");
let BGtopwall=("\script\Images\3DBackground\Stage 3\Wall2.png");
let BGinnerwall1=("\script\Images\3DBackground\Stage 3\Wall3a.png");
let BGinnerwall2=("\script\Images\3DBackground\Stage 3\Wall3b.png");
let BGinnerwall3=("\script\Images\3DBackground\Stage 3\Wall3c.png");
let BGroomwall1=("\script\Images\3DBackground\Stage 3\Wall4a.png");
let BGroomwall2=("\script\Images\3DBackground\Stage 3\Wall4b.png");
let BGceiling1=("\script\Images\3DBackground\Stage 3\Ceiling1.png");
let BGceiling2=("\script\Images\3DBackground\Stage 3\Ceiling2.png");
let BGceiling3=("\script\Images\3DBackground\Stage 3\Ceiling3.png");
let BGbeam=("\script\Images\3DBackground\Stage 3\Beam.png");
let BGtree=("\script\Images\3DBackground\Stage 3\Tree.png");
let BGgrass=("\script\Images\3DBackground\Stage 3\Grass.png");

let BGbush1=("\script\Images\3DBackground\Stage 3\Bush1.png");
let BGbush2=("\script\Images\3DBackground\Stage 3\Bush2.png");
let BGbush3=("\script\Images\3DBackground\Stage 3\Bush3.png");
let BGlantern=("\script\Images\3DBackground\Stage 3\Lantern.png");
let BGpath=("\script\Images\3DBackground\Stage 3\Path.png");
let BGrocks=("\script\Images\3DBackground\Stage 3\Rocks.png");
let BGbridge=("\script\Images\3DBackground\Stage 3\Bridge.png");
let BGbamboo=("\script\Images\3DBackground\Stage 3\Bamboo.png");
let BGlake=("\script\Images\3DBackground\Stage 3\Lake.png");

let BGlightray=("\script\Images\3DBackground\Lightray.png");
let BGend=("\script\Images\3DBackground\Wall.png");

//===============================================================================================================

//Background Stage 4

let darkness=1;
let stallscroll1=[]; let stall1=[];
let stallgraphic1=[]; let stallsprite1=rand_int(1,5);
let stallscroll2=[]; let stall2=[];
let stallgraphic2=[]; let stallsprite2=rand_int(1,5);
let lampscroll=[]; let lamp=[];
let bambooscroll=[]; let bamboo=[];
let dancestallscroll=0; let dancestall=-2900;

let BGpath=("\script\Images\3DBackground\Stage 4\Path.png");
let BGdirt=("\script\Images\3DBackground\Stage 4\Dirt.png");
let BGstalls1=("\script\Images\3DBackground\Stage 4\Stalls1.png");
let BGstalls2=("\script\Images\3DBackground\Stage 4\Stalls2.png");
let BGlamps=("\script\Images\3DBackground\Stage 4\Lamps.png");
let BGbamboo=("\script\Images\3DBackground\Stage 4\Bamboo.png");
let BGdancestall1=("\script\Images\3DBackground\Stage 4\DanceStall1.png");
let BGdancestall2=("\script\Images\3DBackground\Stage 4\DanceStall2.png");
let BGdancestallfloor=("\script\Images\3DBackground\Extra\Floor1.png");

let BGend=("\script\Images\3DBackground\Wall.png");
let BGsky=("\script\Images\3DBackground\Sky1.png");

//===============================================================================================================

//Background Stage 5

let bushscroll=[]; let bush=[]; let bushrandomx=[];
let canopyscroll=[]; let canopy=[]; let canopygraphic=[]; let canopysprite=rand_int(1,3); 

let leaf=0; let leaves=[]; let leaftimer=[];
let EFlightray=0; let lightray=[]; let lightraytimer=[]; let lightrayfade=[]; let lightrayscroll=[];

function randombush2{
let choice=rand_int(0,1);
if(choice==0){ let randombushmin=rand(-50,-150); return randombushmin; }
if(choice==1){ let randombushmax=rand(50,150); return randombushmax; }
}

let BGbush=("\script\Images\3DBackground\Stage 1\Bush.png");
let BGpath=("\script\Images\3DBackground\Stage 2\Grass.png");
let BGbamboo=("\script\Images\3DBackground\Stage 5\Bamboo.png");
let BGcanopy1=("\script\Images\3DBackground\Stage 1\Canopy1.png");
let BGcanopy2=("\script\Images\3DBackground\Stage 1\Canopy2.png");
let BGcanopy3=("\script\Images\3DBackground\Stage 1\Canopy3.png");
let BGceiling=("\script\Images\3DBackground\Stage 1\Ceiling.png");

let BGlightray=("\script\Images\3DBackground\Lightray.png");
let BGend=("\script\Images\3DBackground\Wall.png");
let BGleaf=("\script\Images\3DBackground\Leaf.png");

//===============================================================================================================

//Background Stage 6

let doorangle=0;
let eclipse=0;

let BGfloor1=("\script\Images\3DBackground\Stage 6\Floor1.png");
let BGceiling1=("\script\Images\3DBackground\Stage 6\Ceiling1.png");
let BGwall1a=("\script\Images\3DBackground\Stage 6\Wall1a.png");
let BGwall1b=("\script\Images\3DBackground\Stage 6\Wall1b.png");
let BGwall2a=("\script\Images\3DBackground\Stage 6\Wall2a.png");
let BGwall2b=("\script\Images\3DBackground\Stage 6\Wall2b.png");
let BGdoor=("\script\Images\3DBackground\Stage 6\Door.png");
let BGmoon=("\script\Images\3DBackground\Stage 6\Moon.png");
let BGtree=("\script\Images\3DBackground\Stage 2\Tree.png");

let BGfloor2=("\script\Images\3DBackground\Stage 6\Floor2.png");
let BGceiling2=("\script\Images\3DBackground\Stage 6\Ceiling2.png");
let BGbeams1=("\script\Images\3DBackground\Stage 6\Beams1.png");
let BGdebris=("\script\Images\3DBackground\Stage 6\Debris.png");

let BGfloor3=("\script\Images\3DBackground\Stage 6\Floor3.png");
let BGceiling3a=("\script\Images\3DBackground\Stage 6\Ceiling3a.png");
let BGceiling3b=("\script\Images\3DBackground\Stage 6\Ceiling3b.png");
let BGbeams2=("\script\Images\3DBackground\Stage 6\Beams2.png");
let BGwindow=("\script\Images\3DBackground\Stage 6\Window.png");
let BGeclipse=("\script\Images\3DBackground\Stage 6\Eclipse.png");

let BGend=("\script\Images\3DBackground\Wall.png");

//===============================================================================================================

//Background Extra

let grassscroll1=[]; let grass1=[]; let grassrandomx1=[];
let grassscroll2=[]; let grass2=[]; let grassrandomx2=[];

let EFlightray=0; let lightray=[]; let lightraytimer=[]; let lightrayfade=[]; let lightrayscroll=[];

function randomgrass{
let choice=rand_int(0,1);
if(choice==0){ let randomgrassmin=rand(-80,-150); return randomgrassmin; }
if(choice==1){ let randomgrassmax=rand(80,150); return randomgrassmax; }
}

let GRlightray=("\script\Images\3DBackground\Lightray.png");

let BGsand=("\script\Images\3DBackground\Extra\Sand.png");
let BGdunes1=("\script\Images\3DBackground\Extra\Dunes1.png");
let BGdunes2=("\script\Images\3DBackground\Extra\Dunes2.png");
let BGgrass1=("\script\Images\3DBackground\Extra\Grass1.png");
let BGgrass2=("\script\Images\3DBackground\Extra\Grass2.png");
let BGfence1=("\script\Images\3DBackground\Extra\Fence1.png");
let BGsky=("\script\Images\3DBackground\Sky1.png");

let BGwater1=("\script\Images\3DBackground\Extra\Water1.png");
let BGwater2=("\script\Images\3DBackground\Extra\Water2.png");
let BGwaves=("\script\Images\3DBackground\Extra\Waves.png");

let BGfloor1=("\script\Images\3DBackground\Extra\Floor1.png");
let BGfloor2=("\script\Images\3DBackground\Extra\Floor2.png");
let BGfence2=("\script\Images\3DBackground\Extra\Fence2.png");
let BGceiling=("\script\Images\3DBackground\Extra\Ceiling.png");

let BGend=("\script\Images\3DBackground\Wall.png");

//===============================================================================================================

//Background Nightmare

let viewdistance=1;

let bg1fade=255;
let bg1distance=0;

let bg2spin=0;
let bg2distance=1080;
let bg2hscroll=0;
let bg2vscroll=0;
let bg2rotate=0;
let bg2height=0;

let bg3fade=0;
let bg3distance=200;
let bg3viewspin=0;

let bgphasetime=0;

let BGnightmare1=("\script\Images\3DBackground\Nightmare\1.png");
let BGnightmare2=("\script\Images\3DBackground\Nightmare\2.png");
let BGnightmare3=("\script\Images\3DBackground\Nightmare\3.png");
let BGnightmare4=("\script\Images\3DBackground\Nightmare\4.png");
let BGnightmare5=("\script\Images\3DBackground\Nightmare\5.png");

let BGend=("\script\Images\3DBackground\Wall.png");

//===============================================================================================================

