#TouhouDanmakufu
#Title[Reimu Spellcard 1 - Easy]
#Text[Spirit Sign "Fantasy Shoot"
Not to confuse with Scarlet Shoot, this is different.]
#Player[FREE]
#ScriptVersion[2]


script_enemy_main
{
let CSD = GetCurrentScriptDirectory;
#include_function ".\newsfx.txt"
#include_function ".\function_cutin.txt"
#include_function ".\Obj_hpb.txt"
#include_function ".\function_own.txt"
#include_function ".\function_value.txt"
let SpellBG1 = CSD~"system/1.png";
let SpellBG2 = CSD~"system/2.png";
let shot = GetCurrentScriptDirectory() ~ "kshotData.txt" ;
let frame = 0 ;
let cut = CSD ~ "system\Raymoo.png";
//let minx = GetClipMinX ;
//let maxx = GetClipMaxX ;
//let miny = GetClipMinY ;
//let maxy = GetClipMaxY ;
let bgalpha = 0;	//We create a new variable so that the background can fade in smoothly.
let bgangle = 0;	//Angle for the overlayed BG.
let boss =  GetCurrentScriptDirectory ~ "system\raymoosprite.png" ;


@Initialize
{
LoadUserShotData( shot ) ;
cutin("NAZRIN", "Spirit Sign "\""Fantasy Shoot"\" ,cut,0,0,552,620);
//CutinSP("TIREI",20,-50,8000000,60,cut,0,0,384,512);
//CutinSP2(-275,-10,GetCurrentScriptDirectory~".\spell\1.png",0,0,384,32,255,255,255);
SetScore( 2500000 ) ;
//Timer(1,0);
LoadGraphic(SpellBG1);
LoadGraphic(SpellBG2);
LoadGraphic(cut);
SetX( GetCenterX ) ;
SetY( GetClipMinY + 130 ) ;
SetLife( 300 ) ;
SetTimer( 40 ) ;
SetDamageRate( 16, 10 ) ;
SetInvincibility( 180 ) ;
let frame = 0 ;
hpb(1,0,0);
MainTask ;
}

@MainLoop
{
SetCollisionA( GetX, GetY, 24 ) ;
SetCollisionB( GetX, GetY, 24 ) ;
if ( frame % 360 == 0 )
  {
  moveToPlayer( rand( 30, 100 ), rand( -50, 50 ), 60, GetClipMinX + 32, GetClipMinY + 32, GetClipMaxX - 32, GetClipMinY + 160 ) ;
  }
yield ;
frame += 1 ;
}

@DrawLoop
{
DrawText("Reimu Hakurei", 40, 35, 12, 255);
LoadGraphic(boss) ;
SetTexture(boss) ;
SetGraphicRect( 0, 0, 63, 73 ) ;
DrawGraphic( GetX, GetY ) ;

}

@Finalize
{
DeleteGraphic(boss) ;

}

task MainTask
{
loop( 60 ) { yield ; }
PlaySE(charge);
SetColor(255,0,0);
Concentration01(60);
SetColor(255,255,255);
loop( 60 ) { yield ; }
Shot1 ;
Shot2 ;
}

task Shot1
{
let id ;
loop
  {
  wait( 180 ) ;
  id = 0 ;
  loop( 8 )
    {
    CreateShotA( id, GetClipMinX + 20 + id * 48, GetClipMinY + 20, 15 ) ;
    SetShotDataA( id, 0, 0, 0, 0, 0, 0, 131 ) ;
    SetShotDataA( id, 120, rand( 0.1, 4.5 ), rand( 85, 105 ), 0, 0, NULL, NULL ) ;
    id += 1 ;
    }
  loop( 20 )
    {
    CreateShotA( id, 0, 0, 0 ) ;
    SetShotDataA( id, 0, rand( 0.1, 4.5 ), rand( 85, 105 ), 0, 0, 0, 131 ) ;
    AddShot( 100, id % 8, id, NULL ) ;
    id += 1 ;
    }
  id = 0 ;
  loop( 8 )
    {
    FireShot( id ) ;
    id += 1 ;
    }
PlaySE(shot4);  
  wait( 120 ) ;
 PlaySE(kira);
  }
}

task Shot2
{
let v ;
let v2;
let space ;
loop
  {
  wait( 120 ) ;
PlaySE(shot5);
  v = 1.5 ;
v2 = 1.5;
  loop( 10 )
    {
    NwayHavingSpace( GetX, GetY, 20, v, GapOfEtoP, 5, 1, 94, 20 ) ;
    NwayHavingSpace( GetX, GetY, 20, v, GapOfEtoP - 180, 7, 30, 93, 20 ) ;
    v += 0.35
    }
wait(120);
PlaySE(shot5);
  loop( 10 )
    {
    NwayHavingSpace( GetX, GetY, 20, v2, GapOfEtoP, 5, 1, 94, 20 ) ;
    NwayHavingSpace( GetX, GetY, 20, v2, GapOfEtoP , 7, 9, 93, 20 ) ;
    v2 += 0.35
    }
  }
}
@BackGround{

		if (bgalpha < 255){bgalpha += 5;}


SetAlpha(bgalpha);
SetGraphicScale(1.2,1.2);	//The background is scaled up so it can fill the whole screen.
SetColor(255,255,255);
SetGraphicRect(0,0,512,512);

SetTexture(SpellBG1);
DrawGraphic(GetCenterX,GetCenterY);

SetTexture(SpellBG2);
SetGraphicAngle(0,0,bgangle);
DrawGraphic(GetCenterX,GetCenterY);
	}

}