task AnimateEnemyA1(objID, Color){
	let count = 0;
	let type = 0;
	
	let x = 32;
	let y = 0;
	
	let idle = 10;
	let move = 6;
	let attack = 6;
	
	let r = idle;
	let m = 0; 
	
	if(Color == "Blue") { y = 320; }
	if(Color == "Red") { y = 352; }
	if(Color == "Green") { y = 384; }
	if(Color == "Yellow") { y = 416; }
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Fairy.png");
	
	while(!Obj_IsDeleted(objID)){
		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 == 1) {
				count = 0;
				type = 3;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y, x*1, y+32); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y, x*2, y+32); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y, x*3, y+32); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y, x*4, y+32); }
			if(count >= r*4){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*8, y, x*9, y+32); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*9, y, x*10, y+32); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*10, y, x*11, y+32); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*11, y, x*12, y+32); }
			if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*4, y, x*5, y+32); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*5, y, x*6, y+32); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*6, y, x*7, y+32); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*7, y, x*8, y+32); }
			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*7, y, x*8, y+32); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*6, y, x*7, y+32); }
			if(count >= r*2){  ObjSprite2D_SetSourceRect(objID, x*5, y, x*6, y+32); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestRect(objID, -x/2, -y/2+(4*sin(m)), x/2, y/2+(4*sin(m)));
		ObjSprite2D_SetDestCenter(objID);
		//if(!IsTimeStopped){count++;}
		yield;
	}
}
task AnimateEnemyA2(objID, Color){
	let count = 0;
	let type = 0;
	
	let x = 48;
	let y = 0;
	
	let idle = 10;
	let move = 6;
	let attack = 6;
	
	let r = idle;
	let m = 0; 
	
	if(Color == "Blue") { y = 0; }
	if(Color == "Red") { y = 96; }
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Fairy.png");
	
	while(!Obj_IsDeleted(objID)){
		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 == 1) {
				count = 0;
				type = 3;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y, x*1, y+32); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y, x*2, y+32); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y, x*3, y+32); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y, x*4, y+32); }
			if(count >= r*4){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+64, x*1, y+96); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+64, x*2, y+96); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+64, x*3, y+96); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+64, x*4, y+96); }
			if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+32, x*1, y+64); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+32, x*2, y+64); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+32, x*3, y+64); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+32, x*4, y+64); }
			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+32, x*4, y+64); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y+32, x*3, y+64); }
			if(count >= r*2){  ObjSprite2D_SetSourceRect(objID, x*1, y+32, x*2, y+64); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestRect(objID, -x/2, -y/2+(4*sin(m)), x/2, y/2+(4*sin(m)));
		ObjSprite2D_SetDestCenter(objID);
		//if(!IsTimeStopped){count++;}
		yield;
	}
}
task AnimateEnemyA3(objID, Color){
	let count = 0;
	let type = 0;
	
	let xinit = 192;
	let x = 48;
	let y = 0;
	
	let idle = 10;
	let move = 6;
	let attack = 6;
	
	let r = idle;
	let m = 0; 
	
	if(Color == "Blue") { y = 144; }
	if(Color == "Red") { y = 0; }
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Fairy.png");
	
	while(!Obj_IsDeleted(objID)){
		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 == 1) {
				count = 0;
				type = 3;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, xinit+x*0, y, xinit+x*1, y+48); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, xinit+x*1, y, xinit+x*2, y+48); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, xinit+x*2, y, xinit+x*3, y+48); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, xinit+x*3, y, xinit+x*4, y+48); }
			if(count >= r*4){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, xinit+x*0, y+96, xinit+x*1, y+144); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, xinit+x*1, y+96, xinit+x*2, y+144); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, xinit+x*2, y+96, xinit+x*3, y+144); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, xinit+x*3, y+96, xinit+x*4, y+144); }
			if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, xinit+x*0, y+48, xinit+x*1, y+96); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, xinit+x*1, y+48, xinit+x*2, y+96); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, xinit+x*2, y+48, xinit+x*3, y+96); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, xinit+x*3, y+48, xinit+x*4, y+96); }
			if(count >= r*4-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, xinit+x*3, y+48, xinit+x*4, y+96); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, xinit+x*2, y+48, xinit+x*3, y+96); }
			if(count >= r*2){  ObjSprite2D_SetSourceRect(objID, xinit+x*1, y+48, xinit+x*2, y+96); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestRect(objID, -x/2, -y/2+(4*sin(m)), x/2, y/2+(4*sin(m)));
		ObjSprite2D_SetDestCenter(objID);
		//if(!IsTimeStopped){count++;}
		yield;
	}
}
task AnimateEnemyA4(objID){
	let count = 0;
	let type = 0;
	
	let xinit = 398;
	let x = 64;
	let y = 0;
	
	let idle = 10;
	let move = 6;
	let attack = 6;
	
	let r = idle;
	let m = 0; 
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Fairy.png");
	
	while(!Obj_IsDeleted(objID)){
		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 == 1) {
				count = 0;
				type = 3;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, xinit+x*0, y, xinit+x*1, y+64); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, xinit+x*1, y, xinit+x*2, y+64); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, xinit+x*2, y, xinit+x*3, y+64); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, xinit+x*3, y, xinit+x*4, y+64); }
			if(count >= r*4){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, xinit+x*0, y+128, xinit+x*1, y+192); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, xinit+x*1, y+128, xinit+x*2, y+192); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, xinit+x*2, y+128, xinit+x*3, y+192); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, xinit+x*3, y+128, xinit+x*4, y+192); }
			if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, xinit+x*0, y+64, xinit+x*1, y+128); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, xinit+x*1, y+64, xinit+x*2, y+128); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, xinit+x*2, y+64, xinit+x*3, y+128); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, xinit+x*3, y+64, xinit+x*4, y+128); }
			if(count >= r*4-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, xinit+x*3, y+64, xinit+x*4, y+128); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, xinit+x*2, y+64, xinit+x*3, y+128); }
			if(count >= r*2){  ObjSprite2D_SetSourceRect(objID, xinit+x*1, y+64, xinit+x*2, y+128); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestRect(objID, -x/2, -y/2+(4*sin(m)), x/2, y/2+(4*sin(m)));
		ObjSprite2D_SetDestCenter(objID);
		//if(!IsTimeStopped){count++;}
		yield;
	}
}