#TouhouDanmakufu
#Title[HI]
#ScriptVersion[2]
script_enemy_main{
let CSD = GetCurrentScriptDirectory;
let imgBoss = CSD ~ "img\ExRumia.png";
@Initialize{
SetLife(1000);
SetTimer(600);
SetInvincibility(30);
SetMovePosition01(GetCenterX,GetCenterY,5);
LoadGraphic(imgBoss);
mainTask;
}
@MainLoop{
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,16);
yield;
}
@DrawLoop{
SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(64,1,127,64);
SetGraphicScale(01,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);
}
@BackGround{
SetTexture(NULL);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,500,500);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);
}
@Finalize{
DeleteGraphic(imgBoss);
}
task mainTask{
loop{ //loop causes it to constantly run. Without it, it only runs once.
mainFire;
SetMovePosition01(GetCenterX+rand(-50,50),120+rand(-20,20),5); //Just planted "movement" here and changed it because calling this every few frames with the same movement is redundant.
loop(50){yield;} //You definitely do not want everything run every frame.
}
}
//movement task deleted for simplicity
task mainFire{
let count = 0;
loop(20){
spock(GetEnemyX,GetEnemyY,3,count+90,RED31,0); //sin gets the y position of the angle on a circle of radius 1. Read up on your trig, maybe?
count+=3; //I'm guessing you want this too.
yield; //stops a frame before firing the next spock, just gives a different effect
}
}
task spock(x,y,v,dir,graphic,delay){
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj, v);
Obj_SetAngle(obj,dir);
ObjShot_SetGraphic(obj,graphic);
ObjShot_SetDelay(obj,delay);
ObjShot_SetBombResist(obj,true);
while(!Obj_BeDeleted(obj)){
if(Obj_GetY(obj) > GetClipMaxY){
Obj_SetAngle(obj,-dir); //yay for bouncing
}
yield;
}
}
}
function wait(w){
loop(w){yield;}
}
}
On first glance I was wondering what you were doing, then realized you were imitating Hele's tutorial. This should work regardless.