I have a question regarding reflecting bullets.
I set up this piece of script:
if(Obj_GetX(obj)<=GetClipMinX) {
Obj_SetAngle(obj,180-Obj_GetAngle(obj));
Obj_SetX(obj,Obj_GetX(obj)+0.1);
}
if(Obj_GetX(obj)>=GetClipMaxX) {
Obj_SetAngle(obj,180-Obj_GetAngle(obj));
Obj_SetY(obj,Obj_GetY(obj)-0.1);
}
//The above reflect horizontally. Below is supposed to do it vertically, except it doesn't.
if(Obj_GetY(obj)<=GetClipMinY) {
Obj_SetAngle(obj,180+Obj_GetAngle(obj));
Obj_SetY(obj,Obj_GetY(obj)-0.1);
}
if(Obj_GetY(obj)>=GetClipMaxY) {
Obj_SetAngle(obj,180+Obj_GetAngle(obj));
Obj_SetX(obj,Obj_GetX(obj)+0.1);
}
I tried doing all sorts of stuff to enable vertical reflection, but whatever I try, the outcome it either:
-The bullets sink into the top/bottom of the screen upon contact.
Or -They reflect, but in the exact opposite direction for both Y and X, and not just Y alone.
What did I do wrong?
As for the whole script, it goes something likes this...:
#TouhouDanmakufu
#Title[Test 2]
#Text[(***)]
#Player[FREE]
#Image[script\Images\Faces\.png]
#ScriptVersion[2]
script_enemy_main {
let angle=0;
let shift=0;
let enemies=[];
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\KurumiNorm1.png");
let Boss=("\script\Images\CharacterSprites\KurumiNorm.png");
@Initialize{
LoadUserShotData("script\shots\Shots1Pos.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-170,50);
// LastSpell;
}
@MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
SetShotAutoDeleteClip(64,64,64,64);
if(frame%80==0 && frame>60){
loop(30){
let enemy=Obj_Create(OBJ_SHOT);
Obj_SetPosition(enemy,cx,cy);
ObjShot_SetGraphic(enemy,RED01);
Obj_SetSpeed(enemy,2);
Obj_SetAngle(enemy,shift+angle);
Obj_SetAutoDelete(enemy,true);
enemies=enemies~[enemy];
angle+=360/30;
}
cx=rand(GetClipMinX+50,GetClipMaxX-50);
cy=rand(GetClipMinY+50,GetClipMaxY-200);
shift+=1;
}
let i=0;
while (i<length(enemies)){
if(Obj_BeDeleted(enemies[i])){
enemies=erase(enemies,i);
i--;
}
else{
let obj=enemies[i];
if(Obj_GetX(obj)<=GetClipMinX) {
Obj_SetAngle(obj,180-Obj_GetAngle(obj));
Obj_SetX(obj,Obj_GetX(obj)+0.1);
}
if(Obj_GetX(obj)>=GetClipMaxX) {
Obj_SetAngle(obj,180-Obj_GetAngle(obj));
Obj_SetY(obj,Obj_GetY(obj)-0.1);
}
if(Obj_GetY(obj)<=GetClipMinY) {
Obj_SetAngle(obj,180+Obj_GetAngle(obj));
Obj_SetY(obj,Obj_GetY(obj)-0.1);
}
if(Obj_GetY(obj)>=GetClipMaxY) {
Obj_SetAngle(obj,180+Obj_GetAngle(obj));
Obj_SetX(obj,Obj_GetX(obj)+0.1);
}
}
i++;
}
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);
}
}
Which reminds me of my 2nd question:
What do I need to do to make each sepparate bullet take another action after a certain amount of frames of existance?