#東方弾幕風
#Title[テストスクリプト]
#Text[テストスクリプト]
#ScriptVersion[2]
script_enemy_main {
let imgBoss = "script\img\ExRumia.png";
let wIni = 120;
@Initialize {
SetMovePosition02(GetCenterX, GetClipMinY + 120, wIni);
SetLife(2000);
LoadGraphic(imgBoss);
SetTexture(imgBoss);
SetGraphicRect(0, 0, 63, 63);
TNway;
TMove;
}
@MainLoop {
SetCollisionA(GetX, GetY, 24);
SetCollisionB(GetX, GetY, 24);
yield;
}
@DrawLoop {
DrawGraphic(GetX, GetY);
}
@Finalize {
DeleteGraphic(imgBoss);
}
task TNway {
let angleBase = 90;
yield;
loop(wIni) { yield; }
loop {
loop(30) { yield; }
nway(angleBase, 3, 10, YELLOW01);
angleBase += 8;
loop(30) { yield; }
nway(angleBase, 5, 5, WHITE01);
angleBase += 8;
}
}
task TMove {
yield;
loop(wIni) { yield; }
loop {
loop(120) { yield; }
moveToPlayer(rand(40, 80), rand(-40, 40), 60,
GetClipMinX + 32, GetClipMinY + 32,
GetClipMaxX - 32, GetClipMinY + 160);
}
}
function nway(dir, way, span, color) {
let radius = 32;
let angle = dir - (way - 1) / 2 * span;
loop(way) {
let x = GetX + offsetX(radius, angle);
let y = GetY + offsetY(radius, angle);
CreateShot01(x, y, 1, angle, color, 0);
angle += span;
}
}
function offsetX(radius, angle) {
return radius * cos(angle);
}
function offsetY(radius, angle) {
return radius * sin(angle);
}
function moveToPlayer(xMove, yAdd, frame, left, top, right, bottom) {
let x;
let y;
if(GetPlayerX < GetX) {
x = GetX - xMove;
if(x < left) {
x = GetX + xMove;
}
} else {
x = GetX + xMove;
if(right < x) {
x = GetX - xMove;
}
}
y = GetY + yAdd;
if(y < top) {
y = top;
} else if(bottom < y) {
y = bottom;
}
SetMovePosition02(x, y, frame);
}
}