But why does it crash when I put in
angle+=(angle+0.05); ?
Initially, the angle is 0. (it's loaded @initialize and has error if deleted).
So first loop should be
It already has the angle loaded, which is 0, then angle is called at the bullet's fire, so it shouldn't run an error. Then near the end of the loop, it should run angle+=angle+(0.05);
in this case, angle=0+(0.05) , the 0 got from @Initialize like used in the bullets.
So angle should be left 0.05.
And repeat the loop.
So at the beginning of the new loop, it should load
angle=0.05, which is used for the next arrange of bullets looped
and near the end of the loop, it should add 0.05 to itself (thus making angle=0.1) , so after the bullet is fired and reads
angle+=(angle+(0.05)), it should read (angle=0.05+(0.05). So after the statement, it should conclude angle=0.1
And likewise, third loop, it should use 0.1 as the angle for the bullets and all.
then near the end of the loop, it adds angle+=(angle+0.05). In this case, angle=(0.1+0.05)
and conclude angle=0.15
and repeat so on.
Why the crash?
Here's an example.
#TouhouDanmakufu
#Title[Waves]
#Text[Using INIT to spawn bullets in a circular pattern.]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main
{
let imgExRumia="script\ExRumia\img\ExRumia.png";
let frame = 0;
let frame2 = 0;
let angle=0;
let radius = 60;
let angleAcc=0;
@Initialize{
SetLife(1500);
SetTimer(60);
SetInvincibility(30);
LoadGraphic(imgExRumia);
SetMovePosition02(GetCenterX, GetCenterY - 100, 120);
hitit;
}
@MainLoop{
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
yield;
SetPlayerInvincibility(20000);
}
@DrawLoop{
SetColor(255,255,255);
SetRenderState(ALPHA);
SetTexture(imgExRumia);
SetGraphicRect(64,1,127,64);
DrawGraphic(GetX,GetY);
}
@Finalize
{
DeleteGraphic(imgExRumia);
}
task hitit{
loop(120){yield;}
loop(1){
loop{
CreateShot01(GetX + radius*cos(angle), GetY + radius*sin(angle), 3, angle, BLUE12, 12);
angle += (angle+5); loop(3){yield;}
}
}
}
}
}
It works for a little while, and will work longer when the yield is looped more. But it will "crash", if you only loop yield once. See for yourself.