#TouhouDanmakufu[Stage]
#ScriptVersion[3]
#Title["stage1jam"]
#Text["stage1jam"]
#System["./my_system/My_system.txt"]
#include "script/sample/gamejam/my_system/Default_ShotConst2.txt"
#include "./enemies.txt"
#include "./3dstagespace.txt"
let objBGM = ObjSound_Create();




@Initialize
{
    TStage();
	renderStage;
	scrollStage;
	PlayTrack;

	
	  SetPlayerLife(99);
}
@MainLoop
{
if (GetPlayerState() == STATE_END) { 
wait(20); CloseStgScene(); }
    yield;
}
@Finalize
{
}
task TStage
{ wait(50);

CreateStageEnemy2(100, -2, 3, 90);
wait(5);
CreateStageEnemy1(200, -2, 3, 90);
wait(5);
CreateStageEnemy3(300, -2, 3, 90);
wait(120);
CreateStageEnemy2(100, -2, 3, 90);
wait(5);
CreateStageEnemy1(200, -2, 3, 90);
wait(5);
CreateStageEnemy3(300, -2, 3, 90);

CreateStageEnemy2(100, -2, 3, 90);
wait(5);
CreateStageEnemy1(200, -2, 3, 90);
wait(5);
CreateStageEnemy3(300, -2, 3, 90);
wait(120);
CreateStageEnemy2(100, -2, 3, 90);
wait(5);
CreateStageEnemy1(200, -2, 3, 90);
wait(5);
CreateStageEnemy3(300, -2, 3, 90);

CreateStageEnemy2(100, -2, 3, 90);
wait(5);
CreateStageEnemy1(200, -2, 3, 90);
wait(5);
CreateStageEnemy3(300, -2, 3, 90);
wait(120);
CreateStageEnemy2(100, -2, 3, 90);
wait(5);
CreateStageEnemy1(200, -2, 3, 90);
wait(5);
CreateStageEnemy3(300, -2, 3, 90);

wait(70);

CreateStageEnemy6(500, 90, 2, 180);
wait(12);
CreateStageEnemy7(500, 90, 2, 180);
wait(12);
CreateStageEnemy8(500, 90, 2, 180);
wait(12);
CreateStageEnemy6(500, 90, 2, 180);
wait(12);
CreateStageEnemy7(500, 90, 2, 180);
wait(12);
CreateStageEnemy8(500, 90, 2, 180);
wait(12);
CreateStageEnemy6(500, 90, 2, 180);
wait(12);
CreateStageEnemy7(500, 90, 2, 180);
wait(12);
CreateStageEnemy8(500, 90, 2, 180);
wait(400);
CreateStageEnemy4(200, -10, 2, 90);
wait(400);
CreateStageEnemy44(200, -10, 2, 90);

	wait(800);
	ObjSound_Stop(objBGM);
	  
	   let dir = GetCurrentScriptDirectory();
    
    let path = dir ~ "./luigiplural.txt";
    let idScript = LoadScriptInThread(path);
    loop(60){yield;}//
    StartScript(idScript);
	
  
    while(!IsCloseScript(idScript) && GetPlayerState() != STATE_END)
    {
        yield;
    }
	CloseStgScene();
}

task PlayTrack{

	ObjSound_Load(objBGM, GetCurrentScriptDirectory() ~ "./BGM/SCATMAN.mp3");
	ObjSound_SetSoundDivision(objBGM, SOUND_BGM);
	ObjSound_SetLoopEnable(objBGM, true);
	ObjSound_SetLoopTime(objBGM, 0, 60);

	ObjSound_Play(objBGM);
    }


function wait(w){
       loop(w) {
	     yield;
		 }
	}