if(GetCommonData("BackgroundStop")==0){

if(time%20==0){
let xsize=30;
let ysize=150;
	EFlightray=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(EFlightray,cx,cy);
	ObjEffect_SetScale(EFlightray,rand(2,4),5); ObjEffect_SetAngle(EFlightray,0,0,rand(-10,10));
	ObjEffect_SetLayer(EFlightray,1); ObjEffect_SetTexture(EFlightray,GRlightray); ObjEffect_SetRenderState(EFlightray,ADD);
	ObjEffect_SetPrimitiveType(EFlightray,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(EFlightray,4);
	ObjEffect_SetVertexXY(EFlightray,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(EFlightray,0,0,0);
	ObjEffect_SetVertexXY(EFlightray,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(EFlightray,1,xsize,0);
	ObjEffect_SetVertexXY(EFlightray,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(EFlightray,2,0,ysize);
	ObjEffect_SetVertexXY(EFlightray,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(EFlightray,3,xsize,ysize);
	ObjEffect_SetVertexColor(EFlightray,0,0,255,255,255); ObjEffect_SetVertexColor(EFlightray,1,0,255,255,255);
	ObjEffect_SetVertexColor(EFlightray,2,0,255,255,255); ObjEffect_SetVertexColor(EFlightray,3,0,255,255,255);
	lightray=lightray~[EFlightray];
	lightraytimer=lightraytimer~[EFlightray]; lightraytimer[length(lightray)-1]=0;
	lightrayfade=lightrayfade~[EFlightray]; lightrayfade[length(lightray)-1]=0;
	lightrayscroll=lightrayscroll~[EFlightray];
	let random=rand_int(1,2);
	if(random==1){ lightrayscroll[length(lightray)-1]=1.5; } if(random==2){ lightrayscroll[length(lightray)-1]=-1.5; }
}

let i=0;
while(i<length(lightray)){
	if(Obj_BeDeleted(lightray[i])){
	lightray=erase(lightray,i); lightraytimer=erase(lightraytimer,i); lightrayfade=erase(lightrayfade,i); lightrayscroll=erase(lightrayscroll,i);
	i--;
	}
	else{
	Obj_SetX(lightray[i],Obj_GetX(lightray[i])+lightrayscroll[i]);
	ObjEffect_SetVertexColor(lightray[i],0,lightrayfade[i],255,255,255); ObjEffect_SetVertexColor(lightray[i],1,lightrayfade[i],255,255,255);
	ObjEffect_SetVertexColor(lightray[i],2,lightrayfade[i],255,255,255); ObjEffect_SetVertexColor(lightray[i],3,lightrayfade[i],255,255,255);
	if(lightrayfade[i]<100){ lightrayfade[i]=lightrayfade[i]+1; }
	if(Obj_GetX(lightray[i])<minx-100 || Obj_GetX(lightray[i])>maxx+100){ Obj_Delete(lightray[i]); }
	ObjEffect_SetAngle(lightray[i],0,0,-lightrayscroll[i]*lightraytimer[i]/20);
	lightraytimer[i]=lightraytimer[i]+1;
	}
i++;
}


let i=0;
let a=0;
let distance=50;
	while(i<length(grass1)){
	grass1[i]=a+grassscroll1[i];
	a+=distance;
	if(grass1[i]>400){
		grassscroll1[i]=grassscroll1[i]-(length(grass1)*distance);
		grassrandomx1[i]=randomgrass;
	}
	grassscroll1[i]=grassscroll1[i]+scrollspeed;
	i++;
}
let i=0;
let a=0;
let distance=70;
	while(i<length(grass2)){
	grass2[i]=a+grassscroll2[i];
	a+=distance;
	if(grass2[i]>400){
		grassscroll2[i]=grassscroll2[i]-(length(grass2)*distance);
		grassrandomx2[i]=randomgrass;
	}
	grassscroll2[i]=grassscroll2[i]+scrollspeed;
	i++;
}

hscroll-=scrollspeed; vscroll-=scrollspeed;

} //BackgroundStop


if(GetCommonDataDefault("SpinBG",0)>0){
	newviewx=(360/12)*GetCommonData("SpinBG");
	viewmovetimexy=120;
	SetCommonData("SpinBG",0);
}


