
 
@Initialize {
SetCamera();
BackgroundFinal(0);
Background1(0,0);

Background1(512,0);
Background1(512,512);
Background1(512,-512);

Background1(512*2,0);
Background1(512*2,512);
Background1(512*2,-512);

Background1(512*3,0);
Background1(512*3,512);
Background1(512*3,-512);



}

task CloudsR(){

let frame=0;

loop(3){
	Cloud(rand(-512,512),(256*3)+rand(0,512),rand(-200,50),2);
}

while(true){

if(frame==256){

loop(3){
	Cloud(rand(-512,512),(256*3)+rand(0,512),rand(-200,50),2);
}
frame=0;
}

frame++;
yield;
}

}

@MainLoop {

	
	yield;
}

task SetCamera(){
	
	SetCameraRadius(400);
	SetCameraAzimuthAngle(90);
	SetCameraElevationAngle(-60);
	SetFogEnable(true);
	SetFogParam(10,800,100,0,0);
	
}

task CameraFunctions(){
let movego=true;

let sum=0;
let count=0;

	while(!IsCloseScript(GetOwnScriptID)){
	SetCameraAzimuthAngle(90+sum);
	
	if(count==120){
		movego=false;	
	}
	
	if(count==-120){
		movego=true;	
	}
	
	if(movego==true){
		sum+=1/16;
		count++;
	}
	
	if(movego==false){
		sum-=1/16;
		count--;
	}

	yield;
}

}

task Background1(altu,x){
let current = GetCurrentScriptDirectory();
let frame=0;
 let obj = ObjPrim_Create(OBJ_SPRITE_3D);
let obj1 = ObjPrim_Create(OBJ_SPRITE_3D);

 let mx = 0;
 let path1 = current ~ "img/dpstg2_1.png";
let path2 = current ~ "img/dpstg2_2.png";
	
	
	
    ObjRender_SetPosition(obj,0+x,altu,0);
	Obj_SetRenderPriorityI(obj, 20);
	ObjPrim_SetTexture(obj, path1);
	//ObjRender_SetColor(obj,125,0,0);
	
	 ObjRender_SetPosition(obj1,0+x,altu,0);
	Obj_SetRenderPriorityI(obj1, 20);
	ObjPrim_SetTexture(obj1, path2);
	ObjRender_SetAlpha(obj1,100);
	//ObjRender_SetColor(obj1,125,0,0);
	



	 
	while(true){
	ObjSprite3D_SetSourceDestRect(obj, 0,0-mx,512,512-mx);
	ObjSprite3D_SetSourceDestRect(obj1, 0,0,512,512);

		mx-=1;
	yield;
	}
	
	Obj_Delete (obj);
 
}

task Cloud(x,y,z,speed){
let current = GetCurrentScriptDirectory();
let frame=0;
 let obj = ObjPrim_Create(OBJ_SPRITE_3D);
 let path1 = GetCurrentScriptDirectory ~ "img/dpstg2_4.png";


 let mx = 0;

	


	
    ObjRender_SetPosition(obj,x,y,z);
	Obj_SetRenderPriorityI(obj, 21);
	ObjPrim_SetTexture(obj, path1);
	ObjRender_SetAngleXYZ(obj,-90,0,0);


	 
	while(true){
	ObjSprite3D_SetSourceDestRect(obj, 0,0,256,256);
	ObjRender_SetPosition(obj,x,y+mx,z);

	

	mx-=speed;
	yield;
	}
	
	Obj_Delete (obj);
 
}

task BackgroundFinal(dif){
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
let current = GetCurrentScriptDirectory();
let path1 = current ~ "img/stg4bg2.png";
let mx=0;


Obj_SetRenderPriorityI(obj, 20);
	ObjPrim_SetTexture(obj, path1);
	ObjSprite2D_SetSourceRect(obj, 0,0,512,256);
	ObjSprite2D_SetDestRect(obj,0,0,512,256);
	//ObjRender_SetScaleXYZ(obj,1.5,1.5,0);
	ObjRender_SetPosition(obj,0,0+dif,0);
	 
	while(true){
	

	
		mx-=1;
	yield;
	}
	
	Obj_Delete (obj);
 
}

/*
 sets the position of the sprite to the center of the playing field
 ObjRender_SetPosition(obj,0,-65,0);
 Obj_SetRenderPriorityI(obj, 25);
 SetCameraRadius(300);
 SetCameraAzimuthAngle(90);
 SetCameraElevationAngle(-60);
 
 ObjRender_SetPosition pretty much set the position of the background in the playing area. :V
[14:25:44] PS: Obj_SetRenderPriorityI is just to not block your view. Always keep at 25.

Camera radius is pretty much the "distance" between the background and the camera.

In that case, Azimuth is for X axis.
And Elevation is for Y axis.

 while(true)
 {
Sets the viewing recting of the sprite using the given pixels of the texture to show. The arguments refer to the sides of the texture to scroll a bg downward, add the mx value to the top and bottom arguments
  
  ObjSprite3D_SetSourceDestRect(obj, 0, 0 + mx, 250, 250 + mx);
  
Sets the origin of the sprite to the center based on the source rectangle you defined above
  
Increment the mx value each frame to make the bg scroll
  mx-=1;
  yield;
 }
[14:38:38] PS: Oh and the entire code was made by Ultima, I adapted it with the help of Miransu.
[14:39:16 | Editado 14:39:37] PS: So, scrolling is pretty much like how you do a danmaku spiral.

 
 */