task leftmove {

	ObjSprite2D_SetSourceRect(Patch, 128*2, 128, 128*3, 128*2); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

	ObjSprite2D_SetDestCenter(Patch); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
	
	}
	
task rightmove {

	ObjSprite2D_SetSourceRect(Patch, 128*2, 128*3, 128*3, 128*4); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

	ObjSprite2D_SetDestCenter(Patch); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
	}
	
task cast {

	let posy1 = 0;
	let posy2 = 1;
	
	loop(25){
		ObjSprite2D_SetSourceRect(Patch, 128*4, posy1, 128*5, 128*posy2); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

		ObjSprite2D_SetDestCenter(Patch); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
		
		if(posy1==0){
			posy1 = 2;
			posy2 = 1;
			}
		else{
			posy1 = 0;
			posy2 = 1;
			}
		
		loop(10){
			yield;
			}
		}
	}
	
task Crosshair(tobj, graphic)  {

	let obj40 = CreateStraightLaserA1(0, 0, 0, 600, 50,0, graphic, 10000);
	let obj10 = CreateStraightLaserA1(0, 0, 90, 600, 50,0, graphic, 10000);
	let obj20 = CreateStraightLaserA1(0, 0, 180, 600, 50,0, graphic, 10000);
	let obj30 = CreateStraightLaserA1(0, 0, 270, 600, 50, 0, graphic, 10000);
	
	ObjStLaser_SetSource(obj40, false);
	ObjStLaser_SetSource(obj10, false);
	ObjStLaser_SetSource(obj20, false);
	ObjStLaser_SetSource(obj30, false);
	
	Obj_SetRenderPriorityI(obj40,20);
	Obj_SetRenderPriorityI(obj10,20);
	Obj_SetRenderPriorityI(obj20,20);
	Obj_SetRenderPriorityI(obj30,20);

	loop{
		ObjMove_SetPosition(obj40, ObjMove_GetX(tobj), ObjMove_GetY(tobj));
		ObjMove_SetPosition(obj10, ObjMove_GetX(tobj), ObjMove_GetY(tobj));
		ObjMove_SetPosition(obj20, ObjMove_GetX(tobj), ObjMove_GetY(tobj));
		ObjMove_SetPosition(obj30, ObjMove_GetX(tobj), ObjMove_GetY(tobj));
		
		yield;
		}
	}

task MCircle(tobj, ID){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
	
	let path = ID;
	ObjPrim_SetTexture(obj,path);
	ObjPrim_SetTexture(obj1,path);
	
	Obj_SetRenderPriorityI(obj,22);
	Obj_SetRenderPriorityI(obj1,22);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetBlendType(obj1,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj,230);
	ObjRender_SetAlpha(obj1,230);
	let sx = (300-0)/2; let sy = (300-0)/2; //taken from BG code, don't know what it does.
	ObjSprite2D_SetSourceRect(obj,0,0,256, 256);
	ObjSprite2D_SetSourceRect(obj1,0,0,256, 256);
	
	ObjRender_SetPosition(obj,ObjMove_GetX(tobj),ObjMove_GetY(tobj),0);
	ObjRender_SetPosition(obj1,ObjMove_GetX(tobj),ObjMove_GetY(tobj),0);
	ObjSprite2D_SetDestRect(obj,-sx,-sy,sx,sy); //taken from BG code, don't know what it does.
	ObjSprite2D_SetDestRect(obj1,-sx,-sy,sx,sy); //taken from BG code, don't know what it does.
	
	spinBG;
 
	task spinBG{
		let spin = 0;
		let spin2 = 0;
		let flag=1;
		
		
		let size = 0;
		
		loop{
		ObjRender_SetAngleXYZ(obj,0,0,spin);
		ObjRender_SetPosition(obj,ObjMove_GetX(tobj),ObjMove_GetY(tobj),0);
		ObjRender_SetScaleXYZ(obj,0.9,0.9,0);
		ObjRender_SetAngleXYZ(obj1,0,0,spin2);
		ObjRender_SetPosition(obj1,ObjMove_GetX(tobj),ObjMove_GetY(tobj),0);
		ObjRender_SetScaleXYZ(obj1,0.75, 0.75,0);
		
		if(ObjEnemy_GetInfo(tobj, INFO_LIFE) <= 0){
			ObjRender_SetScaleXYZ(obj,0,0,0);
			ObjRender_SetScaleXYZ(obj1,0, 0,0);
			}
			
		spin+=-0.6;
		spin2+=0.3;
		yield;
			
		}
	}
	
	}
	
task cast2 {

	let pos1 = 1;
	let pos2 = 2;
	
	
	loop(10){
		ObjSprite2D_SetSourceRect(Patch, 128*5, 128*pos1, 128*6, 128*pos2); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

		ObjSprite2D_SetDestCenter(Patch); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
		
		if(pos1==1){
			pos1 = 2;
			pos2 = 3;
			}
		else{
			pos1 = 1;
			pos2 = 2;
			}
		
		loop(20){
			yield;
			}
		}
	
	}
	
task declare {

	let pos1 = 0;
	let pos2 = 1;
	let flag=0;

	loop(3){
		ObjSprite2D_SetSourceRect(Patch, 128*3, 128*pos1, 128*4, 128*pos2); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

		ObjSprite2D_SetDestCenter(Patch); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
		
		if(flag<=3){
			pos1++;
			pos2+=1;
			flag++;
			}
		else{
			flag++;
			pos1--;
			pos2--;
			}
		
		loop(15){
			yield;
			}
		}
	}
	
task cast3 {

	let pos1 = 1;
	let pos2 = 2;
	
	
	loop{
		ObjSprite2D_SetSourceRect(Patch, 128*5, 128*pos1, 128*6, 128*pos2); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

		ObjSprite2D_SetDestCenter(Patch); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
		
		if(pos1==1){
			pos1 = 2;
			pos2 = 3;
			}
		else{
			pos1 = 1;
			pos2 = 2;
			}
		
		loop(20){
			yield;
			}
		}
	
	}
	
task BG(ID1, ID2, tobj) {

	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	
	let path = ID1;
	let path2 = ID2;
	ObjPrim_SetTexture(obj,path);
	ObjPrim_SetTexture(obj2,path2);
	
	Obj_SetRenderPriorityI(obj,21);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetAlpha(obj,200);
	ObjSprite2D_SetSourceRect(obj,0,0,557,633);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
	
	ObjRender_SetScaleXYZ(obj,1.2,1.2,0);

	Obj_SetRenderPriorityI(obj2,20);
	ObjRender_SetBlendType(obj2,BLEND_ALPHA);
	ObjRender_SetAlpha(obj2,240);
	ObjSprite2D_SetSourceRect(obj2,0,0,512,512);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetScaleXYZ(obj2,1,1,0);
	ObjRender_SetPosition(obj2,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
	spinBG;
 
	task spinBG{
		let spin = 0;
		let spin1 = 0;
		loop{
		ObjRender_SetAngleXYZ(obj2,0,0,spin);
		ObjRender_SetAngleXYZ(obj,0,0,spin1);
		spin+=0.2;
		spin1-=0.2;
		
		if(ObjEnemy_GetInfo(tobj, INFO_LIFE) <= 0){
			ObjRender_SetScaleXYZ(obj,0,0,0);
			ObjRender_SetScaleXYZ(obj2,0, 0,0);
			}
			
		yield;
		}
	}
	}