I'm in despair once again!
I'm trying to make a circle of reflecting bullets, but the best I got is a script for a very unefficient horizontal reflection.
This is what I made of the object shots:
if(frame==100){
loop(10){
circle[a]=Obj_Create(OBJ_SHOT);
Obj_SetPosition(circle[a],GetX,GetY);
Obj_SetSpeed(circle[a],2);
Obj_SetAngle(circle[a],-30+angle);
ObjShot_SetBombResist(circle[a],true);
ObjShot_SetGraphic(circle[a],RED01);
angle+=36;
a+=1;
}
}
if(frame>100){
a=0;
loop(10){
if(Obj_GetX(circle[a])<GetClipMinX) {
Obj_SetAngle(circle[a],180-Obj_GetAngle(circle[a]) );
Obj_SetX(circle[a],Obj_GetX(circle[a])+0.1);
}
if(Obj_GetX(circle[a])>GetClipMaxX) {
Obj_SetAngle(circle[a], 180-Obj_GetAngle(circle[a]) );
Obj_SetX(circle[a],Obj_GetX(circle[a])-0.1);
}
if(Obj_GetY(circle[a])<GetClipMinY) {
Obj_SetAngle(circle[a],180-Obj_GetAngle(circle[a]) );
Obj_SetY(circle[a],Obj_GetY(circle[a])+0.1);
}
if(Obj_GetY(circle[a])>GetClipMaxY) {
Obj_SetAngle(circle[a], 180-Obj_GetAngle(circle[a]) );
Obj_SetY(circle[a],Obj_GetY(circle[a])-0.1);
}
a+=1;
}
}
Or the whole script:
#TouhouDanmakufu
#Title[*** (Lunatic)]
#Text[(***)]
#Player[FREE]
#Image[script\Images\Faces\.png]
#ScriptVersion[2]
script_enemy_main {
let circle=[0,1,2,3,4,5,6,7,8,9,10,11,12,13];
let angle=0;
let a=0;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let timercount=0;
let cx=GetCenterX;
let cy=GetCenterY;
let enemylife=0;
let lowhealth1=("script\SoundEffects\lowhealth1.wav");
let lowhealth2=("script\SoundEffects\lowhealth2.wav");
let timeout1=("script\SoundEffects\timeout1.wav");
let timeout2=("script\SoundEffects\timeout2.wav");
let BG1=("\script\Images\BackgroundLayers\kurumi1.png");
let Portrait=("\script\Images\Faces\TomokoNorm1.png");
let Boss=("\script\Images\CharacterSprites\KurumiNorm.png");
@Initialize{
LoadUserShotData("script\shots\Shots1Pos1.txt");
LoadGraphic(Boss);
LoadGraphic(BG1);
LoadGraphic(Portrait);
LoadSE(lowhealth1);
LoadSE(lowhealth2);
LoadSE(timeout1);
LoadSE(timeout2);
CutIn(YOUMU,""\"""\",Portrait,0,0,200,520);
SetScore(500000);
SetLife(500);
SetTimer(50);
SetGraphicRect(0,0,96,96);
SetInvincibility(30);
SetDamageRate(10,10);
SetEnemyMarker(true);
MagicCircle(true);
SetColor(255,160,200);
Concentration01(60);
Concentration02(60);
SetColor(255, 255, 255);
SetEffectForZeroLife(60,100,1);
SetMovePosition02(cx,cy-100,50);
// LastSpell;
}
@MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
SetShotAutoDeleteClip(64,64,64,64);
if(frame==100){
loop(10){
circle[a]=Obj_Create(OBJ_SHOT);
Obj_SetPosition(circle[a],GetX,GetY);
Obj_SetSpeed(circle[a],2);
Obj_SetAngle(circle[a],-30+angle);
ObjShot_SetBombResist(circle[a],true);
ObjShot_SetGraphic(circle[a],RED01);
angle+=36;
a+=1;
}
}
if(frame>100){
a=0;
loop(10){
if(Obj_GetX(circle[a])<GetClipMinX) {
Obj_SetAngle(circle[a],180-Obj_GetAngle(circle[a]) );
Obj_SetX(circle[a],Obj_GetX(circle[a])+0.1);
}
if(Obj_GetX(circle[a])>GetClipMaxX) {
Obj_SetAngle(circle[a], 180-Obj_GetAngle(circle[a]) );
Obj_SetX(circle[a],Obj_GetX(circle[a])-0.1);
}
if(Obj_GetY(circle[a])<GetClipMinY) {
Obj_SetAngle(circle[a],180-Obj_GetAngle(circle[a]) );
Obj_SetY(circle[a],Obj_GetY(circle[a])+0.1);
}
if(Obj_GetY(circle[a])>GetClipMaxY) {
Obj_SetAngle(circle[a], 180-Obj_GetAngle(circle[a]) );
Obj_SetY(circle[a],Obj_GetY(circle[a])-0.1);
}
a+=1;
}
}
time++;
frame++;
if(GetLife<50 && (time-3)%4==0){ enemylife=GetLife; }
if(GetLife<enemylife && (time-0)%4==0){ PlaySE(lowhealth1);
}
if(GetLife<enemylife && (time-2)%4==0){ PlaySE(lowhealth2);
}
if(GetTimer<=10 && GetTimer>3 && time%60==0){ PlaySE(timeout1); }
if(GetTimer<=3 && time%60==0 && timercount<3){ PlaySE(timeout2);
timercount+=1; }
}
@BackGround{
if(bgfade<70){bgfade+=5;}
SetGraphicRect(0,0,512,512);
SetGraphicScale(1.5,1.5);
SetTexture(BG1);
SetAlpha(50);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,-(time/3));
DrawGraphic(cx,cy);
}
@DrawLoop{
SetGraphicRect(1,1,96,96);
SetGraphicScale(1,1);
SetTexture(Boss);
SetGraphicAngle(0, 0, 0);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, 0);
if(usespell>0){SetGraphicRect(288,0,384,96);
DrawGraphic(GetX, GetY);}
if(usespell==0){if(GetSpeedX==0){SetGraphicRect(0,0,96,96);}
else if(GetSpeedX>0){SetGraphicRect(192,0,288,96);}
else if(GetSpeedX<0){SetGraphicRect(96,0,192,96);}
DrawGraphic(GetX, GetY);}}
}
@Finalize{
DeleteGraphic(Portrait);
DeleteGraphic(Boss);
DeleteSE(lowhealth1);
DeleteSE(lowhealth2);
DeleteSE(timeout1);
DeleteSE(timeout2);
}
}
I also would like to know how you can let arrays fill themselves for easy mass modifying. Because "let circle=[0,1,2,3,4,5,6,7,8,9,10...etc" doesn't look very neat, and if you want to have more than 300 bullets on the screen at once, doing it this way will take forever.