task AnimateBossM1(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 0;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let ad = 35;
	let m = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 1/FutoBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		if(Anim_Attack==1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			x = 64;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y, x*1, y+96); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y, x*2, y+96); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y, x*3, y+96); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y, x*1, y+96); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*1, y, x*2, y+96); }
			if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*2, y, x*3, y+96); }
			if(count >= r*6){ ObjSprite2D_SetSourceRect(objID, x*3, y, x*4, y+96); }
			if(count >= r*7){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			x = 64;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			x = 64;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			x = 64;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			x = 80;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+192, x*1, y+288); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+192, x*2, y+288); }
			if(count >= r*2){  ObjSprite2D_SetSourceRect(objID, x*2, y+192, x*3, y+288); }
			if(count >= r*3-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			x = 80;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+192, x*3, y+288); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+192, x*2, y+288); }
			if(count >= r*2){  ObjSprite2D_SetSourceRect(objID, x*0, y+192, x*1, y+288); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+288, x*1, y+384); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE1(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 96;
	
	let idle = 10;
	
	let r = idle;
	let ad = 35;
	let m = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 1/TojikoBoss.png");
	ObjRender_SetScaleX(objID, -1);
	
	while(!Obj_IsDeleted(objID)){
		
		if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, 0, x*1, y); }
		if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, 0, x*2, y); }
		if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, 0, x*3, y); }
		if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, 0, x*1, y); }
		if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*1, 0, x*2, y); }
		if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*2, 0, x*3, y); }
		if(count >= r*6){ ObjSprite2D_SetSourceRect(objID, x*3, 0, x*4, y); }
		if(count >= r*7){ count = 0; }
		
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE5(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 64;
	
	let idle = 10;
	
	let r = idle;
	let ad = 35;
	let m = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 5/KisumeBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		
		if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, 0, x*1, y); }
		if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, 0, x*2, y); }
		if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, 0, x*3, y); }
		if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, 0, x*4, y); }
		if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*0, y, x*1, y+64); }
		if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*1, y, x*2, y+64); }
		if(count >= r*6){ ObjSprite2D_SetSourceRect(objID, x*2, y, x*3, y+64); }
		if(count >= r*7){ ObjSprite2D_SetSourceRect(objID, x*3, y, x*4, y+64); }
		if(count >= r*8){ count = 0; }
		
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM6A(objID){
	let count = 0;
	let type = 0;
	
	let x = 50;
	let y = 80;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let ad = 35;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 6/PrismBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35+float);
			float+=0.2*cos(1.5*t);
			t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y+0, x*4, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*4, y+0, x*5, y+70); }
			if(count >= r*2-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*4, y+0, x*5, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*3, y+0, x*4, y+70); }
			if(count >= r*2-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*4, y+0, x*5, y+70); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM6B(objID){
	let count = 0;
	let type = 0;
	
	let x = 50;
	let y = 323;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let ad = 35;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 6/PrismBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35+float);
			float+=0.2*cos(1.5*t);
			t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+80, x*1, y+150); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+80, x*3, y+150); }
			if(count >= r*3-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+80, x*3, y+150); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y+80, x*1, y+150); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+80, x*3, y+150); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM6C(objID){
	let count = 0;
	let type = 0;
	
	let x = 50;
	let y = 165;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let ad = 35;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 6/PrismBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35+float);
			float+=0.2*cos(1.5*t);
			t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+0, x*4, y+70); }
			//if(count >= r*4-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y+0, x*4, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+80, x*1, y+150); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(count >= r*2-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*0, y+80, x*1, y+150); }
			if(count >= r*2-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}