Author Topic: Danmakufu Q&A/Problem Thread  (Read 172166 times)

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #210 on: July 06, 2009, 05:11:12 PM »
Code: [Select]
@DrawLoop{
SetTexture(c~"pl00.png");
SetAlpha(255);
SetGraphicScale(1,1);

//Draw player
SetGraphicAngle(0,0,0);
if(IsPressRight()==true){
SetGraphicRect(228, 102, 260, 146);
}else if(IsPressLeft()==true){
SetGraphicRect(230, 53, 261, 97);
}else{
if(drawcount<10){SetGraphicRect(5, 3, 38, 51);}
if(drawcount>=10 && drawcount<20){SetGraphicRect(37, 3, 70, 51);}
if(drawcount>=20 && drawcount<30){SetGraphicRect(69, 3, 102, 51);}
if(drawcount>=30 && drawcount<40){SetGraphicRect(101, 3, 134, 51);}
if(drawcount>=40 && drawcount<50){SetGraphicRect(134, 3, 165, 51);}
if(drawcount>=50 && drawcount<60){SetGraphicRect(165, 3, 198, 51);}
if(drawcount>=60 && drawcount<70){SetGraphicRect(198, 3, 229, 51);}
if(drawcount>=70 && drawcount<80){SetGraphicRect(228, 3, 262, 51);}
}
DrawGraphic(GetPlayerX, GetPlayerY);

drawcount++;
if(drawcount>=80){drawcount=0;}
Here's a sample of Reimu's DrawLoop. Hope it helps.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #211 on: July 06, 2009, 06:24:26 PM »
That certainly helped alot thanks Iryan and Drake. I was using only the first part of the if statement and forgetting the "<" framecount to keep it animated within those frames. Now I just need to find a smooth speed for the animation. I am very satisfied with my Afro boss, perhaps I'll continue to create a mini plural script (though I am quite bad at pattern creating =.=)

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #212 on: July 06, 2009, 08:52:19 PM »
I need some help here... I'm trying to make an attack where the boss fires a ring of eight object bullets around itself, and when it hits the edges of the screen, these bullets are deleted and replaced with two object bullets that go back in the direction the original one came from, but at opposite 45-degree angles. Like this:

_ <-- Wall

| <-- Bullet

 |
 |
V
_
/\ <-- New bullets spawned when the original hits the wall

Am I making it clear enough? Anyways, when I took the code I already had for reflecting bullets and made new object bullets spawn into the same array of bullets, the game suddenly froze when one of the original bullets hit the walls.

Code: [Select]
task MirrorLaser
{
let i = 0;
while (i < length(Fate))
{
if (Obj_BeDeleted(Fate[i]))
{
Fate = erase(Fate, i);
i--;
}
else
{
if(Obj_GetX(Fate[i]) <= GetClipMinX() || Obj_GetX(Fate[i]) >= GetClipMaxX())
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 180) + 45);
Obj_SetSpeed(obj, 2);
ObjShot_SetGraphic(obj, AQUA05);
Fate = Fate ~ [obj];

let obj2 = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj2, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 180) - 45);
Obj_SetSpeed(obj2, 2);
ObjShot_SetGraphic(obj2, AQUA05);
Fate = Fate ~ [obj2];
}
if(Obj_GetY(Fate[i]) <= GetClipMinY() || Obj_GetY(Fate[i]) >= GetClipMaxY())
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 270) + 45);
Obj_SetSpeed(obj, 2);
ObjShot_SetGraphic(obj, AQUA05);
Fate = Fate ~ [obj];

let obj2 = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj2, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 270) - 45);
Obj_SetSpeed(obj2, 2);
ObjShot_SetGraphic(obj2, AQUA05);
Fate = Fate ~ [obj2];
}
}
i++;
}
}

(I wanted to make it a laser to begin with, but since I'm not comfortable with moving object lasers manually, I'm just going to make a custom bullet and make it long like a laser.)

Please help.

Re: Danmakufu Q&A/Problem Thread
« Reply #213 on: July 06, 2009, 09:25:00 PM »
I know this is a really simple question, but how do I properly use arrays?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #214 on: July 06, 2009, 09:52:41 PM »
let arr = [1, 5, 7];

and then access each with arr[number]. arr[2] would equal 5.

EDIT: I just realized Obj_IsIntersected just detects if the object is in line with the enemy. How would I go about testing bullet collision?
EDIT: Enumerating every enemy and using Collision_Obj_Obj(obj, enemy) doesn't work either because en enemy is not an object.
EDIT: Neither does enumerating every enemy, finding each ID and checking (obj, enemyID).
EDIT: Neither does activating Obj_SetCollisionToObject.
« Last Edit: July 06, 2009, 10:33:29 PM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Danmakufu Q&A/Problem Thread
« Reply #215 on: July 07, 2009, 12:44:58 AM »
Okay. Then how would I be able to fire a bullet, say, with a randomized angle of either -10, 0, or 10, but ONLY one of those numbers, using an array?


What I am trying to do here is apparently invalid:

Code: [Select]
#TouhouDanmakufu
#Title[Laser Test]
#Text[Test script]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
let ImgBoss = "script\thC\IMAGE\CHAR\DOT\boss_remilia.png";

let count = -60;
let count2 = 0;
let a = 0;
let b = 0;
let c = [-10, 0, 10];

@Initialize {
SetLife(2000);
SetTimer(60);
SetScore(10000000);
LoadUserShotData(GetCurrentScriptDirectory~"UserShotData.txt");

SetEnemyMarker(true);

SetMovePosition02(225, 160, 60);

LoadGraphic(ImgBoss);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 100, 100);
}

@MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

if(count == 10) {

PlaySE("script\Remilia Spell Cards\sfx\Laser2.wav");

CreateLaser01(GetX, GetY, 6, GetAngleToPlayer + c[rand(1, 2, 3)], 80, 20, RED04, 10);
CreateLaser01(GetX, GetY, 6, GetAngleToPlayer - 30 + c[rand(1, 2, 3)], 80, 20, BLUE04, 10);
CreateLaser01(GetX, GetY, 6, GetAngleToPlayer + 30 + c[rand(1, 2, 3)], 80, 20, BLUE04, 10);
CreateLaser01(GetX, GetY, 6, GetAngleToPlayer - 90 + c[rand(1, 2, 3)], 80, 20, GREEN04, 10);
CreateLaser01(GetX, GetY, 6, GetAngleToPlayer + 90 + c[rand(1, 2, 3)], 80, 20, GREEN04, 10);

count=0
}




if(count2 == 120){
loop(2){
CreateShot01(GetX, GetY, 3, a+180, GREEN31, 10);
CreateShot01(GetX, GetY, 3, b, GREEN31, 10);

a += 360/2;
a += 7;

b += 360/2;
b -= 7;
}



count2 = 117;
}
count++;
count2++;
}

@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss);
}
}

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #216 on: July 07, 2009, 12:54:03 AM »
Frazer: Rand doesn't work that way. You use it like this:


rand([lowest number you want], [highest number you want])

However, you want rand_int, not rand. Why? Rand returns not just whole numbers, but decimals, too. This will mess up your arrays... rand_int is forced to be a whole number.

Also, access arrays by starting with 0. So, the first entry is Entry 0, and the third is Entry 2. Therefore, what you want is this:

CreateLaser01(GetX, GetY, 6, GetAngleToPlayer + c[rand_int(0, 2)], 80, 20, RED04, 10);

That should get the randomization working.

Re: Danmakufu Q&A/Problem Thread
« Reply #217 on: July 07, 2009, 02:52:59 AM »
@Pikaguy:

Post your whole script please, I can't really see what's wrong other than it contains no yield; function. Also, something you might want to try before I get back to you is to make the bullets your spawning their own task, so instead of inside the object bullet you start making others, you could have two different tasks that just call upon eachother. Gets rid of dicking around, anyway. Like this:

task Bullet{
let obj = ....
....
....
while(! Obj_BeDeleted(obj)){
if(obj_GetX(obj) <= GetClipMinX || Obj_GetX >= GetClipMinX){
  Reflector(Obj_GetAngle(obj));
  Reflector2(Obj_GetAngle(obj));
  Obj_Delete(obj); //or whatever this function is called...
}
yield;
}
}

task Reflector(a){
 let obj = ...
...
Obj_SetAngle(obj, a - 45);
...
while blah blah, object bullet shit.{
}
}

task Reflector2(aa){
 let obj = ...
...
Obj_SetAngle(obj, a + 45);
...
while blah blah, more object bullet shit.{
}
}



...


@Drake:
You're trying to detect collision between an enemy and a bullet? If you're just trying to have the bullet damage the enemy:



If you're trying to have something else happen when an enemy and a bullet collide, you could make the enemies Objects and animate them with verticies, have them spawn bullets and move around using the while(!Obj_BeDeleted(obj)) loop and so on, then detect collision between two objects. Otherwise, I haven't the slightest.

And uh, arr[2] = 7.

<3


....



@Frazer:

(rand_int(-1, 1))*10 = -10, 0 or 10.

CreateShot01(GetX, GetY, 3, GetAngleToPlayer + (rand_int(-1, 1)*10), RED01, 0);

For any other random sets of numbers, use arrays, as pikaguy900 and Drake have already explained.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #218 on: July 07, 2009, 05:19:58 AM »
And uh, arr[2] = 7
wait fuck


And of course I'd be able to just have it damage the enemy, I just use Obj_SetDamage, lol. I'm animating the bullets once they hit a target. Upon hitting the enemy the bullet slows down, changes graphic, alpha settings, etcetcetc. I have most of the effects done; the only thing is I can't get exactly how it hits the target. I can't use objects because I want the character to be usable in most scripts.

Although you have given me a plausible idea.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #219 on: July 07, 2009, 07:23:01 AM »
Hmmm there seems to be something wrong with my animating sprites. It animates correctly but in between certain images I see it "flickering" like an unwanted GraphicRect sprite but there is no incorrect coordinates.

I cannot post the code atm =S

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #220 on: July 07, 2009, 02:52:05 PM »
Naut: It works perfectly fine without a yield. I use this code every time I deal with arrays of objects, it has NEVER given me any problems in RUNNING what is in it. Why should it have a yield? It ends the minute it is done checking the array, which is what is supposed to happen...

Also, I can't really seperate them, because I'll be spawning two more object bullets when the new ones hit walls! Therefore, I eventually run back into the same situation I'm in right now... (Also, before you ask, no, I am NOT intending for them to split infinitely, I just want to get the splitting to work, first of all...)

In any case:

Code: [Select]
#TouhouDanmakufu
#Title[Reflection of a Fate Sealed with Scarlet]
#Text[]
#Image[]
#BackGround[Default]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
let BossImage = GetCurrentScriptDirectory ~ "boss_remilia.png";
let BossCutIn = GetCurrentScriptDirectory ~ "Remilia.png";
let frame = -100;
let frame2 = -100;
let anim_frame = 0;
let Angle = 0;
let ShotSFX = "script\sfx\shot.wav";
let LaserSFX = "script\sfx\laser.wav";
let Fate = [];
let Mirror = [];
let ang = 0;

task RotMirror
{
let i = 0;
while (i < length(Mirror))
{
if (Obj_BeDeleted(Mirror[i]))
{
Mirror = erase(Mirror, i);
i--;
}
else
{
}
i++;
}
}

task MirrorLaser
{
let i = 0;
while (i < length(Fate))
{
if (Obj_BeDeleted(Fate[i]))
{
Fate = erase(Fate, i);
i--;
}
else
{
if(Obj_GetX(Fate[i]) <= GetClipMinX() || Obj_GetX(Fate[i]) >= GetClipMaxX())
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 180) + 45);
Obj_SetSpeed(obj, 2);
ObjShot_SetGraphic(obj, AQUA05);
Fate = Fate ~ [obj];

let obj2 = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj2, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 180) - 45);
Obj_SetSpeed(obj2, 2);
ObjShot_SetGraphic(obj2, AQUA05);
Fate = Fate ~ [obj2];
}
if(Obj_GetY(Fate[i]) <= GetClipMinY() || Obj_GetY(Fate[i]) >= GetClipMaxY())
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 270) + 45);
Obj_SetSpeed(obj, 2);
ObjShot_SetGraphic(obj, AQUA05);
Fate = Fate ~ [obj];

let obj2 = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj2, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 270) - 45);
Obj_SetSpeed(obj2, 2);
ObjShot_SetGraphic(obj2, AQUA05);
Fate = Fate ~ [obj2];
}
}
i++;
}
}

@Initialize
{
shotinit;
LoadGraphic(BossImage);
SetLife(400);
SetDamageRate(0,0);
SetTimer(72);
SetInvincibility(30);
SetDurableSpellCard();
CutIn(YOUMU, "Reflection of a Fate Sealed with Scarlet", BossCutIn, 0, 0, 256, 320);
SetScore(70000);
SetEnemyMarker(true);
MagicCircle(true);
SetMovePosition02(GetCenterX,130,30);
}

@MainLoop
{
MirrorLaser;
anim_frame++;
SetCollisionA(GetX(),GetY(),32);
SetCollisionB(GetX(),GetY(),24);
if(frame == 0)
{
loop(8)
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, GetX, GetY);
Obj_SetAngle(obj, Angle);
Obj_SetSpeed(obj, 2);
ObjShot_SetGraphic(obj, AQUA04);
Fate = Fate ~ [obj];
Angle += 45;
}
//PlaySE(LaserSFX);

}
frame++;
frame2++;
}

@DrawLoop
{
SetTexture(BossImage);
if(anim_frame >= 0 && anim_frame < 8)
{
if(GetSpeedX()==0)
{
SetGraphicRect(31,31,95,94);
}
else if(GetSpeedX()>0)
{
SetGraphicRect(286,415,352,478);
}
else if(GetSpeedX()<0)
{
SetGraphicRect(286,159,348,222);
}
}
if(anim_frame >= 8 && anim_frame < 16)
{
if(GetSpeedX()==0)
{
SetGraphicRect(31,159,95,222);
}
else if(GetSpeedX()>0)
{
SetGraphicRect(286,415,352,478);
}
else if(GetSpeedX()<0)
{
SetGraphicRect(286,159,348,222);
}
}
if(anim_frame >= 16 && anim_frame < 24)
{
if(GetSpeedX()==0)
{
SetGraphicRect(31,287,95,350);
}
else if(GetSpeedX()>0)
{
SetGraphicRect(286,415,352,478);
}
else if(GetSpeedX()<0)
{
SetGraphicRect(286,159,348,222);
}
}
if(anim_frame >= 24 && anim_frame < 32)
{
if(GetSpeedX()==0)
{
SetGraphicRect(31,415,95,478);
}
else if(GetSpeedX()>0)
{
SetGraphicRect(286,415,352,478);
}
else if(GetSpeedX()<0)
{
SetGraphicRect(286,159,348,222);
}
}
if(anim_frame >= 32)
{
anim_frame = 0;
}
DrawGraphic(GetX, GetY);
}

@Finalize
{
DeleteGraphic(BossImage);
}
}

I love keeping secrets. :( Also, the Mirror task is because my plan is to have 4 large objects, mirrors, spinning around the boss, and have the bullets reflect off THOSE instead of the walls. So basically, the point is that the mirrors will continually split the bullets, and if any bullets slip through the cracks, you get to dodge... I'll find a way to make it balanced so things actually come towards you instead of away from you consistently...

Re: Danmakufu Q&A/Problem Thread
« Reply #221 on: July 07, 2009, 03:20:12 PM »
@Drake:
And of course I'd be able to just have it damage the enemy, I just use Obj_SetDamage, lol.


Didn't think you were talking about a player script, my bad.

I'm animating the bullets once they hit a target. Upon hitting the enemy the bullet slows down, changes graphic, alpha settings, etcetcetc. I have most of the effects done; the only thing is I can't get exactly how it hits the target. I can't use objects because I want the character to be usable in most scripts.

Player scripts ruin my possible solution... Augh. I've no idea.

Although you have given me a plausible idea.

Glad I helped in some way at least.


@pikaguy900:
Naut: It works perfectly fine without a yield. I use this code every time I deal with arrays of objects, it has NEVER given me any problems in RUNNING what is in it. Why should it have a yield? It ends the minute it is done checking the array, which is what is supposed to happen...

Shows how much I know about arrays.

I could be completely wrong, but according to what I see:
The bullet (Fate) hits the wall, the task checks if the bullet (Fate) hits the wall, the bullet creates two more bullets on the same position under that same array (Fate) as instructed by the task, the task continues to check if Fate is colliding with the wall and sees that there are two more bullets colliding with it and then continues to spawn more bullets on top of the new ones in an endless loop. Something like that?

Anyways, here's working code. I delete Fate the same frame that it hits the wall, but after I spawn the new bullets because I don't want the task to keep enumerating Fate, but I also want the new bullets to not be spawned in a bad zone (GetClipMinY + 1, etc.) as well as be able to get the coordinates of Fate. Uh... It should make sense when you see it in code:

Code: [Select]
#TouhouDanmakufu
#Title[Reflection of a Fate Sealed with Scarlet]
#Text[]
#Image[]
#BackGround[Default]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
   #include_function "lib\SHOT_REPLACE\shot_replace.dnh"
   let BossImage = GetCurrentScriptDirectory ~ "boss_remilia.png";
   let BossCutIn = GetCurrentScriptDirectory ~ "Remilia.png";
   let frame = -100;
   let frame2 = -100;
   let anim_frame = 0;
   let Angle = 0;
   let ShotSFX = "script\sfx\shot.wav";
   let LaserSFX = "script\sfx\laser.wav";
   let Fate = [];
   let Mirror = [];
   let ang = 0;

   task RotMirror
   {
      let i = 0;
      while (i < length(Mirror))
      {
         if (Obj_BeDeleted(Mirror[i]))
         {
            Mirror = erase(Mirror, i);
            i--;
         }
         else
         {
         }
         i++;
      }
   }

   task MirrorLaser
   {
      let i = 0;
      while (i < length(Fate))
      {
         if (Obj_BeDeleted(Fate[i]))
         {
            Fate = erase(Fate, i);
            i--;
         }
         else
         {
            if(Obj_GetX(Fate[i]) <= GetClipMinX())
            {
               let obj = Obj_Create(OBJ_SHOT);
               Obj_SetPosition(obj, GetClipMinX + 1, Obj_GetY(Fate[i]));
               Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 180) + 45);
               Obj_SetSpeed(obj, 2);
               ObjShot_SetGraphic(obj, AQUA05);

               let obj2 = Obj_Create(OBJ_SHOT);
               Obj_SetPosition(obj2, GetClipMinX + 1, Obj_GetY(Fate[i]));
               Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 180) - 45);
               Obj_SetSpeed(obj2, 2);
               ObjShot_SetGraphic(obj2, AQUA05);
   Obj_Delete(Fate[i]);
               Fate = Fate ~ [obj];
               Fate = Fate ~ [obj2];
            }
if(Obj_GetX(Fate[i]) >= GetClipMaxX())
{
               let obj = Obj_Create(OBJ_SHOT);
               Obj_SetPosition(obj, GetClipMaxX - 1, Obj_GetY(Fate[i]));
               Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 180) + 45);
               Obj_SetSpeed(obj, 2);
               ObjShot_SetGraphic(obj, AQUA05);

               let obj2 = Obj_Create(OBJ_SHOT);
               Obj_SetPosition(obj2, GetClipMaxX - 1, Obj_GetY(Fate[i]));
               Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 180) - 45);
               Obj_SetSpeed(obj2, 2);
               ObjShot_SetGraphic(obj2, AQUA05);
   Obj_Delete(Fate[i]);
               Fate = Fate ~ [obj];
               Fate = Fate ~ [obj2];
}
            if(Obj_GetY(Fate[i]) <= GetClipMinY())
            {
               let obj = Obj_Create(OBJ_SHOT);
               Obj_SetPosition(obj, Obj_GetX(Fate[i]),GetClipMinY + 1);
               Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 180) + 45);
               Obj_SetSpeed(obj, 2);
               ObjShot_SetGraphic(obj, AQUA05);

               let obj2 = Obj_Create(OBJ_SHOT);
               Obj_SetPosition(obj2, Obj_GetX(Fate[i]), GetClipMinY + 1);
               Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 180) - 45);
               Obj_SetSpeed(obj2, 2);
               ObjShot_SetGraphic(obj2, AQUA05);
   Obj_Delete(Fate[i]);
               Fate = Fate ~ [obj];
               Fate = Fate ~ [obj2];
            }
if(Obj_GetY(Fate[i]) >= GetClipMaxY())
{
               let obj = Obj_Create(OBJ_SHOT);
               Obj_SetPosition(obj, Obj_GetX(Fate[i]), GetClipMaxY - 1);
               Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 180) + 45);
               Obj_SetSpeed(obj, 2);
               ObjShot_SetGraphic(obj, AQUA05);

               let obj2 = Obj_Create(OBJ_SHOT);
               Obj_SetPosition(obj2, Obj_GetX(Fate[i]), GetClipMaxY - 1);
               Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 180) - 45);
               Obj_SetSpeed(obj2, 2);
               ObjShot_SetGraphic(obj2, AQUA05);
   Obj_Delete(Fate[i]);
               Fate = Fate ~ [obj];
               Fate = Fate ~ [obj2];
}
         }
         i++;
      }
   }

   @Initialize
   {
      shotinit;
      LoadGraphic(BossImage);
      SetLife(400);
      SetDamageRate(0,0);
      SetTimer(72);
      SetInvincibility(30);
      SetDurableSpellCard();
      CutIn(YOUMU, "Reflection of a Fate Sealed with Scarlet", BossCutIn, 0, 0, 256, 320);
      SetScore(70000);
      SetEnemyMarker(true);
      MagicCircle(true);
      SetMovePosition02(GetCenterX,130,30);
   }

   @MainLoop
   {
      MirrorLaser;
      anim_frame++;
      SetCollisionA(GetX(),GetY(),32);
      SetCollisionB(GetX(),GetY(),24);
      if(frame == 0)
      {
         loop(8)
         {
            let obj = Obj_Create(OBJ_SHOT);
            Obj_SetPosition(obj, GetX, GetY);
            Obj_SetAngle(obj, Angle);
            Obj_SetSpeed(obj, 2);
            ObjShot_SetGraphic(obj, AQUA04);
            Fate = Fate ~ [obj];
            Angle += 45;
         }
         //PlaySE(LaserSFX);

      }
      frame++;
      frame2++;
   }

   @DrawLoop
   {
      SetTexture(BossImage);
      if(anim_frame >= 0 && anim_frame < 8)
      {
         if(GetSpeedX()==0)
         {
            SetGraphicRect(31,31,95,94);
         }
         else if(GetSpeedX()>0)
         {
            SetGraphicRect(286,415,352,478);
         }
         else if(GetSpeedX()<0)
         {
            SetGraphicRect(286,159,348,222);
         }
      }
      if(anim_frame >= 8 && anim_frame < 16)
      {
         if(GetSpeedX()==0)
         {
            SetGraphicRect(31,159,95,222);
         }
         else if(GetSpeedX()>0)
         {
            SetGraphicRect(286,415,352,478);
         }
         else if(GetSpeedX()<0)
         {
            SetGraphicRect(286,159,348,222);
         }
      }
      if(anim_frame >= 16 && anim_frame < 24)
      {
         if(GetSpeedX()==0)
         {
            SetGraphicRect(31,287,95,350);
         }
         else if(GetSpeedX()>0)
         {
            SetGraphicRect(286,415,352,478);
         }
         else if(GetSpeedX()<0)
         {
            SetGraphicRect(286,159,348,222);
         }
      }
      if(anim_frame >= 24 && anim_frame < 32)
      {
         if(GetSpeedX()==0)
         {
            SetGraphicRect(31,415,95,478);
         }
         else if(GetSpeedX()>0)
         {
            SetGraphicRect(286,415,352,478);
         }
         else if(GetSpeedX()<0)
         {
            SetGraphicRect(286,159,348,222);
         }
      }
      if(anim_frame >= 32)
      {
         anim_frame = 0;
      }
      DrawGraphic(GetX, GetY);
   }

   @Finalize
   {
      DeleteGraphic(BossImage);
   }
}

Keep in mind that because the new bullets are created under the same array (Fate), once they hit walls and the angle they produce is a bad angle (when their angle +- 45 still throws them into walls, which will happen often) they will start spawning a multitude of bullets in the same direction every frame, which will cause your computer to slow down and crash. However, since you said you're going to make them collide with lasers, this shouldn't be a problem (interestingly enough, it still might make more bullets than you expect, be careful). So, this script doesn't really work correctly, but once you change it for lasers it should be pretty close.



@Helepolis:
Check to make sure your operators don't overlap or skip a frame (<= and >), as this will create a brief one frame flicker. If you're positive they're accurate, post the code as soon as you're able and we'll see what we can do.
« Last Edit: July 07, 2009, 03:25:58 PM by Naut »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #222 on: July 07, 2009, 03:59:02 PM »
@Helepolis:
Check to make sure your operators don't overlap or skip a frame (<= and >), as this will create a brief one frame flicker. If you're positive they're accurate, post the code as soon as you're able and we'll see what we can do.

Nope I am sure I didn't overlap any frames. Or my eyes gone bad =.=
The flickering is this image:


And the code. I posted full drawloop as there are also spellcircle animations in there.
Code: [Select]
   
@DrawLoop {
// spellcircle animation
SetTexture(spellcircle);
SetGraphicRect(385,337,512,464);
SetAlpha(255);
SetGraphicAngle(0,0,draai);
SetGraphicScale(p,p);
DrawGraphic(GetX, GetY);

SetTexture(spellcircle2);
SetGraphicRect(0,0,128,128);
SetAlpha(155);
        //SetColor(255,0,255);
SetGraphicAngle(0,0,-draai2);
SetGraphicScale(2.5,2.5);
DrawGraphic(GetX, GetY);

SetTexture(spellcircle3);
SetGraphicRect(128,0,256,128);
SetAlpha(155);
        //SetColor(255,0,255);
SetGraphicAngle(0,0,draai2);
SetGraphicScale(3,3);
DrawGraphic(GetX, GetY);

draai+=3;
draai2+=5;

if(s==0){p+=0.01; if(p>2.00){s=1;} }
if(s==1){p-=0.01; if(p<1.50){s=0;} }

if(draai>360){draai=0;}
if(draai2>360){draai2=0;}

// Afro drawing + animation
SetTexture(CSD~ "system\arap.png");
SetAlpha(255);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetRenderState(ALPHA);

if(int(GetSpeedX())==0){
if(attack==0){
if(arapanm2<10){SetGraphicRect(0,0,82,112);}
if(arapanm2>10 && arapanm2<15){SetGraphicRect(82,0,162,112);}
if(arapanm2>20 && arapanm2<25){SetGraphicRect(162,0,242,112);}
if(arapanm2>25){SetGraphicRect(242,0,322,112);}
}
if(attack==1){SetGraphicRect(242,224,318,335);}
}
if(GetSpeedX()>0){
if(arapanm<10){SetGraphicRect(0,112,64,223);}
if(arapanm>10 && arapanm<20){SetGraphicRect(64,112,128,223);}
if(arapanm>20 && arapanm<30){SetGraphicRect(128,112,192,223);}
if(arapanm>30 && arapanm<40){SetGraphicRect(192,112,256,223);}
if(arapanm>40 && arapanm<50){SetGraphicRect(256,112,320,223);}
if(arapanm>50 && arapanm<60){SetGraphicRect(320,112,384,223);}
if(arapanm>60 && arapanm<70){SetGraphicRect(384,112,448,223);}
if(arapanm>70){SetGraphicRect(448,112,512,223);}
}
if(GetSpeedX()<0){
if(arapanm<10){SetGraphicRect(0,112,64,223);}
if(arapanm>10 && arapanm<20){SetGraphicRect(64,112,128,223);}
if(arapanm>20 && arapanm<30){SetGraphicRect(128,112,192,223);}
if(arapanm>30 && arapanm<40){SetGraphicRect(192,112,256,223);}
if(arapanm>40 && arapanm<50){SetGraphicRect(256,112,320,223);}
if(arapanm>50 && arapanm<60){SetGraphicRect(320,112,384,223);}
if(arapanm>60 && arapanm<70){SetGraphicRect(384,112,448,223);}
if(arapanm>70){SetGraphicRect(448,112,512,223);}
}
if(GetSpeedY()<0){
if(arapanm<10){SetGraphicRect(0,112,64,223);}
if(arapanm>10 && arapanm<20){SetGraphicRect(64,112,128,223);}
if(arapanm>20 && arapanm<30){SetGraphicRect(128,112,192,223);}
if(arapanm>30 && arapanm<40){SetGraphicRect(192,112,256,223);}
if(arapanm>40 && arapanm<50){SetGraphicRect(256,112,320,223);}
if(arapanm>50 && arapanm<60){SetGraphicRect(320,112,384,223);}
if(arapanm>60 && arapanm<70){SetGraphicRect(384,112,448,223);}
if(arapanm>70){SetGraphicRect(448,112,512,223);}
}
        DrawGraphic(GetX, GetY);
arapanm++;
if(arapanm>80){arapanm=0;}
arapanm2+=0.5;
if(arapanm2>25){arapanm2=0;}
}

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #223 on: July 07, 2009, 04:09:46 PM »
Naut: Okay, I get what you said... Yeah, it happened. And sadly, I want to avoid this, 'cause I'm pretty sure it WILL happen when I try the mirrors thing. Oh well, nothing I can do about it. I wish I had a way I could avoid this, but I don't want to spawn the bullets in the exact same directions each time, I want it to be based on where the bullet is going...and still split. Do you have any ideas, even if they require rethinking how I code this? As it is right now, I just know that eventually, a bullet is going to go at such an angle that it will spawn a bullet that shoots right back at the mirrors, just like with the wall right now.

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #224 on: July 07, 2009, 04:39:17 PM »
@ Helepolis:

Found it!


         if(arapanm2<10){SetGraphicRect(0,0,82,112);}
         if(arapanm2>10 && arapanm2<15){SetGraphicRect(82,0,162,112);}
         if(arapanm2>20 && arapanm2<25){SetGraphicRect(162,0,242,112);}
         if(arapanm2>25){SetGraphicRect(242,0,322,112);}


If arapanm2 is between 15 and 20, the last set GraphicRect is used, which is 
   SetGraphicRect(128,0,256,128);
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #225 on: July 07, 2009, 05:04:57 PM »
@ Helepolis:

Found it!

         if(arapanm2<10){SetGraphicRect(0,0,82,112);}
         if(arapanm2>10 && arapanm2<15){SetGraphicRect(82,0,162,112);}
         if(arapanm2>20 && arapanm2<25){SetGraphicRect(162,0,242,112);}
         if(arapanm2>25){SetGraphicRect(242,0,322,112);}

If arapanm2 is between 15 and 20, the last set GraphicRect is used, which is 
   SetGraphicRect(128,0,256,128);

Nope it is still flickering and there is nothing in between. The sprite moves 80 xcoordinates in the range. It is only mere 4 sprites. But the same happens for  X < and X > or Y > <  movements. While those have no gaps in them.

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #226 on: July 07, 2009, 05:26:35 PM »
Well, the human eye usually cannot recognize single pictures at a rate of 60 per second. Pictures with a rate of (60/4)=15 per second on the other hand can easily be perceived. That may explain why the flickering isn't recognized then.


Ummm, in the code you posted there is a one frame gap between every different animation, as you used only "<X" and ">X", which means that for a value equal to X, there won't be a proper graphic rect.

Instead of...
    if(frame<10){ A; }
    if(frame>10&&frame<20){ B; }
    etc.
...you should type...
    if(frame<=10){ A; }
    if(frame>10&&frame<=20){ B; }
    etc.
« Last Edit: July 07, 2009, 05:39:12 PM by Iryan »
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #227 on: July 07, 2009, 06:12:11 PM »
According to Naut he said not to overlap operators. And the flickering is not the image dissapearing but as shown above in the image: As if a wrong GraphicRect coordinates are given but infact there is not.

I'll still try it out, as it does looks like that is the problem.


Edit: My eyes must be turning bad. As I guess Naut tried to point out same thing but Iryan's explanation was easier to understand? Ohwell. It works like a charm now, perfect animation. Now I can finally focus on the spellcard instead of details =P
« Last Edit: July 07, 2009, 06:21:14 PM by Helepolis »

Re: Danmakufu Q&A/Problem Thread
« Reply #228 on: July 07, 2009, 06:32:11 PM »
Yeah, that's what I meant. Iryan isn't overlapping them by the way... But as long as you understand then it's all good.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #229 on: July 07, 2009, 06:35:49 PM »
Overlapping operators would be like x>=25 and x<=25. Both will check for 25 and suicide.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #230 on: July 07, 2009, 08:20:31 PM »
Ah overlapping like that. Now I fully get it. Damn how much I was cursing my self for two days trying to figure out a way to animate this proper as the solution was actually extremely easy =.=


Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #231 on: July 08, 2009, 02:25:26 AM »
First of all,



Second of all,

Code: [Select]
task Target{
let f = 0;
ascent(enemy in EnumEnemyBegin..EnumEnemyEnd){
let enemyID = EnumEnemyGetID(enemy);
let target = Obj_Create(OBJ_SHOT);
Obj_SetX(target, GetEnemyInfo(enemyID, ENEMY_X));
Obj_SetY(target, GetEnemyInfo(enemyID, ENEMY_Y));
Obj_SetSpeed(target, 0);
Obj_SetCollisionToPlayer(target, false);
ObjShot_SetBombResist(target, true);
ObjShot_SetGraphic(target, 101);
while(!Obj_BeDeleted(target)){
Obj_SetX(target, GetEnemyInfo(enemyID, ENEMY_X));
Obj_SetY(target, GetEnemyInfo(enemyID, ENEMY_Y));
f++;
if(f>2){Obj_Delete(target);}
yield;
}
}
}

I'm a sneaky little bastard :D (thanks naut btw)

I'll change the graphic to something different and make it invisible, of course. My problem now is that I'm not quite sure how I would increase the size of the object depending on the boss' bullet collision hitbox. I'll probably need to make it an effect object and use ObjEffect_SetScale, but I'm not quite sure.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Danmakufu Q&A/Problem Thread
« Reply #232 on: July 08, 2009, 02:42:32 AM »
First of all,
[hiitobakusu.png]

Delicious.

(thanks naut btw)

Anytime brah.

I'll change the graphic to something different and make it invisible, of course. My problem now is that I'm not quite sure how I would increase the size of the object depending on the boss' bullet collision hitbox. I'll probably need to make it an effect object and use ObjEffect_SetScale, but I'm not quite sure.

I'm not following where you're going with this, but yes. Very yes.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #233 on: July 08, 2009, 02:54:15 AM »
The above code spawns a nullified object shot on top of an enemy and follows it around. (Actually up to now it only gets one enemy at a time, will need to fix that)

I want to make a graphic that changes sizes depending on SetCollisionA. This way, I check if player bullets contact with the targeting object with SetCollision_Obj_Obj. This way, I can tell exactly when the bullets hit the boss and animate the bullets accordingly.

tl;dr I need to make a circle that changes sizes depending on SetCollisionA.

EDIT: rage danmaq
« Last Edit: July 08, 2009, 03:27:46 AM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Danmakufu Q&A/Problem Thread
« Reply #234 on: July 08, 2009, 03:06:25 AM »
I need to make a circle that changes sizes depending on SetCollisionA.

As far as I know, you can't change something based on it's size because it's not information that you can get. The only way I can think of getting this information is to make a function that will copy the enemy's script into a text string, then enumerate the characters inside the text file up until it reaches "SetCollisionA", delete everything beforehand in the text string, then enumerate again until it reaches a number, delete everything before the number, copy the number into another string, convert it from a string to a value and then base your graphic expansion on the number yielded. This sounds like alot to do every frame though, not to mention is probably not possible.

You can get if SetCollisionA exists though, because Reimu_A's homing amulets will only target enemies with hitboxes, but God only knows what fucking function gets this information.
« Last Edit: July 08, 2009, 03:08:56 AM by Naut »

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #235 on: July 08, 2009, 11:40:53 AM »
Maybe I'm not understanding what you're trying to do, but can't you just make a variable and use it to set SetCollisionA's value, and just have the object check that variable too?

As for scaling a shot to fit it, you could make it a laser instead of a shot and just give it equal height and width, but I forget how object lasers work and whether that would look weird or not. If that's no good yeah you should just use an effect object.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #236 on: July 08, 2009, 05:14:14 PM »
Object laser will work better than my method, thanks.

But the problem with setting a variable to SetCollisionA is that all this is a player script. So I would have to somehow access the variable in the enemy script from the player script, which doesn't work without CommonData. And either way I'd have to edit the enemy script, which is what I'm trying to avoid. I'm trying to make this character as accessible as possible.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Danmakufu Q&A/Problem Thread
« Reply #237 on: July 08, 2009, 08:01:23 PM »
I have yet another question (and I always have many).


I tried making a new style of attack (although somewhat similar to Mokou's).

Code: [Select]
#TouhouDanmakufu
#Title[New Spellcard]
#Text[Test script]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
let ImgBoss = "script\thC\IMAGE\CHAR\DOT\boss_remilia.png";

let count = -60;
let count2 = 0;
let x = 30;
let y = 20;
let a = 0;
let b = 0;

@Initialize {
SetLife(2000);
SetTimer(60);
SetScore(10000000);
LoadUserShotData(GetCurrentScriptDirectory~"UserShotData.txt");

SetEnemyMarker(true);

SetMovePosition02(225, 160, 60);

LoadGraphic(ImgBoss);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 100, 100);
}

@MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

if(count == 2) {

SetShotDirectionType(PLAYER);

CreateShotA(1, x, y, 10);
SetShotDataA(1, 0, 0, 0, 0, 0, 0, GREEN04);
SetShotDataA(1, 11, 0, NULL, 0, 0.025, 3, GREEN04);


if(x == 30 && y == 20){
x += 5;
y += 0;
}

if(x == 410 && y == 20){
x += 0;
y += 5;
}

if(x == 410 && y == 460){
x -= 5;
y += 0;
}

if(x == 30 && y == 460){
x += 0;
y -= 5;
}


FireShot(1);


count=0
}




if(count2 == 120){
loop(2){
CreateShot01(GetX, GetY, 3, a+180, GREEN31, 10);
CreateShot01(GetX, GetY, 3, b, GREEN31, 10);

a += 360/2;
a += 10;

b += 360/2;
b -= 10;
}



count2 = 117;
}
count++;
count2++;
}

@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss);
}
}


Code: [Select]
if(x == 30 && y == 20){
x += 5;
y += 0;
}

if(x == 410 && y == 20){
x += 0;
y += 5;
}

if(x == 410 && y == 460){
x -= 5;
y += 0;
}

if(x == 30 && y == 460){
x += 0;
y -= 5;
}


The x += and y += cancel each other out even though none of the other conditions are met. How come this is happening? What would be the proper way for this to work correctly?

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #238 on: July 08, 2009, 08:23:49 PM »
Unless I am missing something, on the first main loop the condition x == 30 && y == 20 is true, causing x to become 35. From then on, none of if-brackets will ever be performed.


Maybe you are looking for ">=" and "<=" instead of "=="?
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

Re: Danmakufu Q&A/Problem Thread
« Reply #239 on: July 08, 2009, 08:59:58 PM »
Oh, right. I forgot about that (that in this case, only the first main loop counts).

I apologize.