script_enemy_main {
 let image = GetCurrentScriptDirectory ~ "patchouli.png";
 #include_function ".\AnimationLib.dnh"
 #include_function ".\FunctionLib.dnh"
@Initialize{
    SetLife(10);
    LoadGraphic(image);
    MOVE;
	SetMovePosition03(GetCenterX-50, GetCenterY-80, 10, 4);

	
	CreateAnimation("patchouli","move",4);
	SetAnimationFrame("patchouli", "move", 0, image, 12, 0, 64, 64, 128);
    SetAnimationFrame("patchouli", "move", 1, image, 12, 64, 64, 128, 128);
    SetAnimationFrame("patchouli", "move", 2, image, 12, 128, 64, 192, 128);
    SetAnimationFrame("patchouli", "move", 3, image, 12, 192, 64, 256, 128);
	
    CreateAnimation("patchouli","idle",4);
	SetAnimationFrame("patchouli", "idle", 0, image, 12, 0, 0, 64, 64);
    SetAnimationFrame("patchouli", "idle", 1, image, 12, 64, 0, 128, 64);
    SetAnimationFrame("patchouli", "idle", 2, image, 12, 128, 0, 192, 64);
    SetAnimationFrame("patchouli", "idle", 3, image, 12, 192, 0, 256, 64);
 }
 
@MainLoop{
 yield;
 }
 
 let counter2=0;
 let counter3=0;
 
@DrawLoop{
   SetAlpha(255);
   SetTexture(image);
   SetGraphicScale(1,1);
   
  if(GetSpeedX>0 && counter2==0){
  Animate("patchouli","move",false);
  counter2++;
  counter3=0;}

  if(GetSpeedX<0 && counter2==0){
  SetGraphicAngle(180,0,0);
  Animate("patchouli","move",false);
  counter2++;
  counter3=0;}

  if(GetSpeedX==0 && counter3==0){
  SetGraphicAngle(0,0,0);
  Animate("patchouli","idle",true);
  counter3++;
  counter2=0;}

  //true makes it loop, false makes it continue on the last sprite.
 
  DrawAnimatedSprite("patchouli", GetX, GetY);
 }
@Finalize{
   DeleteGraphic(image);
 }
 task MOVE{

    WaitForNoEvent;
	SetMovePosition03(GetClipMinX-50, GetClipMinY-80, 10, 4);
	
	loop{
	if(GetX==GetClipMinX-50 && GetY==GetClipMinY-80){
    VanishEnemy;
	}
	yield;
  }	
  }


}
