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

DgBarca

  • Umineko fuck yeah
  • Spoilers ?
Re: Danmakufu Q&A/Problem Thread
« Reply #630 on: September 01, 2009, 04:59:14 PM »
This is too strange...HELP I can't show it to my friends >_<

Also I have made a [url+http://www.mediafire.com/download.php?guzchdqmymw]New Version[/url] (with normal mode, comment on my topic :3) and it is still desync.
[21:16] <redacted> dgbarca makes great work
[21:16] <redacted> i hope he'll make a full game once

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #631 on: September 01, 2009, 07:01:37 PM »

~ combines stuff. Use it to add items into arrays.

eg.
let array1 = [a]
array2 = array1 ~ "b"

Now array2 is ["a", "b"]


If you want to mass add stuff, use ascent.

eg.
let array1 = []
ascent(i in 0.. 10){
    array1= array1 ~ i
    }

Now array1 is [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].


I find that way hard to understand without a sample. x_x
I've looked into tuturials such as this http://dmf.shrinemaiden.org/wiki/index.php?title=Nuclear_Cheese%27s_Shot_Object_Tutorial , but the example script given is way too complicated to get a grip on.

I can somehow only make one bullet change properties, but when trying the same with multiple bullets, none respond to the changes.

I have this small test script here:

Code: [Select]
enemy=Obj_Create(OBJ_SHOT);
Obj_SetPosition(enemy,GetClipMinX+100,GetClipMinY+100);
Obj_SetSpeed(enemy,3);
Obj_SetAngle(enemy,90);
ObjShot_SetGraphic(enemy,RED01);
Obj_SetAutoDelete(enemy,true);
enemies = enemies ~ [enemy];

if(Obj_GetY(enemies)==200){
Obj_SetAngle(enemies,270);
}

But what I really want is:
-Have a new shot appear every X time or when an old one is deleted.
-Have them change direction so they move around the edges of the screen.
-Have them shoot stuff at you. :3
-The ability to individually make a change.

Yet all it can do now is making a long stream on bullets that only go downwards.
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Nuclear Cheese

  • Relax and enjoy the danmaku.
    • My homepage
Re: Danmakufu Q&A/Problem Thread
« Reply #632 on: September 02, 2009, 12:17:44 AM »

~ combines stuff. Use it to add items into arrays.

eg.
let array1 = [a]
array2 = array1 ~ "b"

Now array2 is ["a", "b"]


If you want to mass add stuff, use ascent.

eg.
let array1 = []
ascent(i in 0.. 10){
    array1= array1 ~ i
    }

Now array1 is [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].


I find that way hard to understand without a sample. x_x
I've looked into tuturials such as this http://dmf.shrinemaiden.org/wiki/index.php?title=Nuclear_Cheese%27s_Shot_Object_Tutorial , but the example script given is way too complicated to get a grip on.

I can somehow only make one bullet change properties, but when trying the same with multiple bullets, none respond to the changes.

I have this small test script here:

Code: [Select]
enemy=Obj_Create(OBJ_SHOT);
Obj_SetPosition(enemy,GetClipMinX+100,GetClipMinY+100);
Obj_SetSpeed(enemy,3);
Obj_SetAngle(enemy,90);
ObjShot_SetGraphic(enemy,RED01);
Obj_SetAutoDelete(enemy,true);
enemies = enemies ~ [enemy];

if(Obj_GetY(enemies)==200){
Obj_SetAngle(enemies,270);
}

But what I really want is:
-Have a new shot appear every X time or when an old one is deleted.
-Have them change direction so they move around the edges of the screen.
-Have them shoot stuff at you. :3
-The ability to individually make a change.

Yet all it can do now is making a long stream on bullets that only go downwards.


In the code you have there, I presume that enemies is an array meant to hold a list of object shots you want to manipulate, correct?

You can't use the Obj_GetY, Obj_SetAngle, etc. commands on an array.  Rather, you need to grab each item in the array and use the commands on each individually.


Within the tutorial you linked above, I gave a framework for using arrays of object shots.  To translate it to the code example you have above, it would be something like this:

Code: [Select]
let enemies = [];

// stuff

@Initialize
{
   // stuff
}

@MainLoop
{
   // stuff
   if (we_should_spawn_a_shot)
   {
      let enemy=Obj_Create(OBJ_SHOT);
      Obj_SetPosition(enemy,GetClipMinX+100,GetClipMinY+100);
      Obj_SetSpeed(enemy,3);
      Obj_SetAngle(enemy,90);
      ObjShot_SetGraphic(enemy,RED01);
      Obj_SetAutoDelete(enemy,true);
      enemies = enemies ~ [enemy];
   }

   let i = 0;
   while (i < length(enemies))
   {
      if (Obj_BeDeleted(enemies[i]))
      {
         enemies= erase(enemies, i);
         i--;
      }
      else
      {
         let obj = enemies[i];
         // Do object processing for the object identified by obj
         if(Obj_GetY(obj)==200){
            Obj_SetAngle(obj, 270);
         }
      }
      i++;
   }
}

(Disclaimer: I didn't actually test this code; I only wrote in the relevant parts.  Given the rest of a script around it, it should work)

The important part here, in order to get each bullet to process correctly, is where it says
let obj = enemies[ i ];

This pulls each object's ID from the array, so we can work with that individual object.


Also, another thing which is an issue in your code is the comparison itself:
if(Obj_GetY(obj)==200)

I'm pretty certain Danmakufu uses floating point numbers for positions.  Floating point numbers can be prone to error due to rounding and such, so it is possible that the Y position of the bullet never hits exactly 200, but rather hits something like 199.999999 - in this case the if will never trigger because it will pass right by 200.

In fact, with the values you've given, the Y coordinate will probably never hit 200 exactly.  I believe GetClipMinY returns the value 0, so you're starting your bullet at the Y coordinate of 100, moving straight downwards at 3 pixels per frame.  If you do the math, the Y coordinate of the bullet is, per frame:
100, 103, 106, 109 ... 187, 190 193, 196, 199, 202
At this rate, even if floating point error doesn't come into play you're still never going to hit 200 exactly.

There is a better way to handle this condition.  Since your bullets start off moving downward, and reverse direction once they hit Y = 200 (to go upwards), you can simply change the if to check if the Y position is at least 200:
if(Obj_GetY(obj)>=200)

With this, even if the bullet doesn't hit Y=200 exactly, it will still reverse direction.



Hopefully, this'll help you get going.



(PS - that array example in the Object Shot tutorial is meant more to give people a framework to throw their object shot processing code into, rather than as a tutorial on arrays themselves.  Perhaps another tutorial is in order?)
to quote Naut:
"I can see the background, there are too many safespots."
:V

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #633 on: September 02, 2009, 10:35:10 AM »
Thanks! I tried it out, and it works like a charm!


I don't think any of the wiki's have a clear explanation on ascent/descent, their uses are quite puzzling.

Small simple sample scripts (try saying that 3 times) of important parts of danmakufu would be a great addition to the wiki. Many existing samples are a bit too overwhelming/complex for newbies. And it's those kind of people who need the wiki!
If it's an okay idea, I can help. I'm rather new, so I can point out what needs more clarification and what things are too confusing.



On a side-note. There's no square root function, is there?
I thought up a way to make squares instead of circles, but Pythagoras' theorem can't do much without square roots.
I wonder how other people did square shots, because I've seen it before in a video.
Well, I can calculate the angle/speed for each bullet with a bit of time, but...

Edit: Nevermind that. I think this will do the job of making a square:

Code: [Select]
if(frame%80==0 && frame>60){
let angle=0;
let direction=0;
let shape=4;   //changeable -- the number of edges. 3 is a triangle, 4 is a square, etc.
let centerspeed=2;   //changeable -- the speed in the center of the square. (each edge is 1.41 times this speed)
let size=5;   //changeable -- number of bullets on each half of a side of the square
let shapeloop=360/shape;
let variablespeed=0;
let side=(shapeloop/2)/size;
loop(size){
variablespeed+=(1.41421356/shapeloop)*side;
angle+=side;
loop(shape){
CreateShot01(GetX,GetY,centerspeed+variablespeed,direction+angle,RED01,0);
CreateShot01(GetX,GetY,centerspeed+variablespeed,direction-angle,RED01,0);
direction+=shapeloop;
}
}
loop(shape){
CreateShot01(GetX,GetY,centerspeed,direction,RED01,0);
direction+=shapeloop;
}
}

This makes any shape, including square, but the edges are slightly curved.
« Last Edit: September 02, 2009, 06:26:57 PM by puremrz »
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Re: Danmakufu Q&A/Problem Thread
« Reply #634 on: September 02, 2009, 02:02:13 PM »
On a side-note. There's no square root function, is there?

Square root = ^0.5

4^0.5 = 2.
16^0.5 = 4.

Cubic root = ^(1/3) (inaccurate)

27^(1/3) = 3.

Quartic root = ^0.25

16^0.25 = 2.

Etc.

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #635 on: September 02, 2009, 05:17:50 PM »
On a side-note. There's no square root function, is there?

Square root = ^0.5

4^0.5 = 2.
16^0.5 = 4.

Cubic root = ^(1/3) (inaccurate)

27^(1/3) = 3.

Quartic root = ^0.25

16^0.25 = 2.

Etc.

Oh, I had no idea that worked too!
The script I just posted works, but the sides are slightly curved. Which makes a nice pattern too, but I guess I really need to use that square root then.
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Re: Danmakufu Q&A/Problem Thread
« Reply #636 on: September 04, 2009, 11:38:11 PM »
yay! another question from some one whocan rarely figure things out by himself  :-\
is there a way to recreate Okuu's Nuclear Bullets?, ive read the User Bullets tutorial, and i dont understand it, bt i kno i is an animated bullet...any sugesions?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #637 on: September 05, 2009, 01:18:05 PM »
@demonbman You mean the big mofo red bullets?

It is not an animated bullet. They are two sprites covering eachother having a ALPHA and ADD value I think making it "glow". You need to first rip the sprite for it from SA then create your own shotscript in order to add the bullet to your shotdata.

After that you can use it for your Object Bullet to imitate it like making it shrink or grow. Tackle it 1 by 1. First go rip the bullet and add it as a custom shot (user bullet / shotdata)

-----------------

I got a question regarding commondata as whatever I do. It doesn't seems to be right. Here is the deal:

I got this object Laser which starts at the bottom of the screen. I want to influence the Y position by an task inside a familiar. Therefor using commondata is here required I believe. How can I store an variabel inside a CommonData and call that variabel inside a task? I had this as a startout:
Code: [Select]
---------------- declared in Enemy Main
let laserY = 430;
SetCommonData("rising",laserY);

-------------- A task inside the familiar
some task{
      let x = 0;
      while(x<100){
           SetCommonData("rising",laserY-x);
            x++;
      }
      yield;
}

---------- somewhere inside the Obj Laser
      Obj_SetY(obj,GetCommonData("rising",laserY);

I am doing something terribly wrong I believe.

Re: Danmakufu Q&A/Problem Thread
« Reply #638 on: September 05, 2009, 10:18:00 PM »
Yes, mostly because you don't seem to know the parameters of the CommonData functions! SetCommonData needs you to name the common data and then set a value to it. GetCommonData only needs you to mention the name of the common data you're getting.

Thus:

SetCommonData("awesome", 2);

later on....

CreateShot01(GetX, GetY, GetCommonData("awesome"), GetAngleToPlayer, RED01, 0);

Shoots a bullet with a velocity of 2 at the player.

Other useful information about common data.

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #639 on: September 06, 2009, 08:51:58 AM »
So I want to create an attack that uses familiars that can be shot. Shooting the is supposed to destroy them and damage the parent enemy. So I put SetDamageRateEx(50, 50, 50, 25); into the script of the familiar and summoned him with CreateEnemyFromFile. Everything about the familiar works as intended, save for one thing:

Even though the boss has no sort of invincibility and can be harmed by your shots like normal, shooting the familiar doesn't damage the boss and I have no idea why. Does SetDamageRateEx only work correctly with enemies summoned with CreateEnemyFromScript, maybe? I have no idea.
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."

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #640 on: September 06, 2009, 09:28:16 AM »
So I want to create an attack that uses familiars that can be shot. Shooting the is supposed to destroy them and damage the parent enemy. So I put SetDamageRateEx(50, 50, 50, 25); into the script of the familiar and summoned him with CreateEnemyFromFile. Everything about the familiar works as intended, save for one thing:

Even though the boss has no sort of invincibility and can be harmed by your shots like normal, shooting the familiar doesn't damage the boss and I have no idea why. Does SetDamageRateEx only work correctly with enemies summoned with CreateEnemyFromScript, maybe? I have no idea.

Incidentally, I created such a script a few days ago. It goes like this:

-The familiar has a common data in its main loop:
Code: [Select]
SetCommonData(1,GetHitCount);
You can make more than one familiar/enemy:
Code: [Select]
SetCommonData(2,GetHitCount);

-And the actual boss has this:
Code: [Select]
AddLife(-(GetCommonData(1)/2));
If you're using more enemies, write it like this:
Code: [Select]
AddLife(-((GetCommonData(1)+GetCommonData(2))/2));
You might want to change the "divided by 2" at the end by another number, because familiars would deal different amounts of damage than normal shots would. But increasing the health meter works too.
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #641 on: September 06, 2009, 10:19:22 AM »
So there is a function for something that doesn't do what it is supposed to do so you have to work around it?
...
Well, its danmakufu. Figures...  :V

Thanks for the advice.
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 #642 on: September 06, 2009, 01:46:20 PM »
Yes, mostly because you don't seem to know the parameters of the CommonData functions! SetCommonData needs you to name the common data and then set a value to it. GetCommonData only needs you to mention the name of the common data you're getting.

Thus:

SetCommonData("awesome", 2);

later on....

CreateShot01(GetX, GetY, GetCommonData("awesome"), GetAngleToPlayer, RED01, 0);

Shoots a bullet with a velocity of 2 at the player.

Other useful information about common data.

Yay, so that is how it is done. And I was like smashing my desk and pulling out my hair while the solution was frikken simple. =.=
I read the wiki but I was puzzled. I even looked at examples in other people's scripts and still was puzzled. Seriously the Wiki has such fuzzy examples and explanation. . .

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #643 on: September 06, 2009, 02:43:21 PM »
Oh goody, I walked past Effect Objects before, and quickly ran when I saw words like
ObjEffect_SetVertexXY and ObjEffect_SetPrimitiveType.
But now I need to use them!

All I really want is a normal image of a 1:1 scale to appear on screen.
But there doesn't seem to be a normal coordinates command like SetGraphicRect(0,0,144,144);
I've looked through Nuclear Cheese's tutorial, which somewhat helped me. But like hell I can understand this part:

Code: [Select]
          ObjEffect_SetTexture(objid, imagefile);

          ObjEffect_SetPrimitiveType(objid, PRIMITIVE_TRIANGLELIST);

          ObjEffect_CreateVertex(objid, 3);

          ObjEffect_SetVertexXY(objid, 0, -20, -20);
          ObjEffect_SetVertexUV(objid, 0, 0, 0);

          ObjEffect_SetVertexXY(objid, 1, 20, 0);
          ObjEffect_SetVertexUV(objid, 1, 255, 127);

          ObjEffect_SetVertexXY(objid, 2, -20, 20);
          ObjEffect_SetVertexUV(objid, 2, 127, 255);

I applied that to the code I have now, and it works, but it makes a shape of it that I'm not looking for. How can I make it a regular square of 144x144?

This is what I have now:

Code: [Select]
let broom=(Obj_Create(OBJ_EFFECT));
Obj_SetPosition(broom,GetX,GetY);
ObjEffect_SetLayer(broom,3);
ObjEffect_SetAngle(broom,0,0,0);
ObjEffect_SetTexture(broom,broom1); (it's properly linked to an image)

if(frame>60){
ObjEffect_SetAngle(broom,0,0,time*3);
}

Just as a test, I wanted this to start spinning after 60 frames.

But when I paste NC's sample in the code I have now, I get this:


(She's already sitting on a broom, but that's just the enemy's graphic, not the broom I want to spin around)

-It keeps creating more and more images.
-And they're definitely not square. D:


How can I fix this, and how exactly do those vertices options change the shape of the graphic?


(By the way, I edited ObjEffect_SetLayer in the wiki. Layer 8 draws over the frame while layer 7 still draws below. Useful too, especially when I get the answer to the question above. :P)



Edit: Nevermind that anymore, I somehow figured it out. The wiki needs a better explanation for this! Really!

So if anyone wants a sample on how to draw a square with Object Effects:

Code: [Select]
if(frame==30){
broom=(Obj_Create(OBJ_EFFECT));

Obj_SetPosition(broom,cx,cy-16);
ObjEffect_SetLayer(broom,3);
ObjEffect_SetAngle(broom,0,0,0);
ObjEffect_SetTexture(broom, broom1);

ObjEffect_SetPrimitiveType(broom,PRIMITIVE_TRIANGLEFAN);

ObjEffect_CreateVertex(broom,4);

ObjEffect_SetVertexXY(broom,3,72,72);
ObjEffect_SetVertexUV(broom,0,0,0);

ObjEffect_SetVertexXY(broom,2,-72,72);
ObjEffect_SetVertexUV(broom,1,144,0);

ObjEffect_SetVertexXY(broom,1,72,-72);
ObjEffect_SetVertexUV(broom,2,0,144);

ObjEffect_SetVertexXY(broom,0,-72,-72);
ObjEffect_SetVertexUV(broom,3,144,144);
}
« Last Edit: September 06, 2009, 07:09:14 PM by puremrz »
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread
« Reply #644 on: September 06, 2009, 03:42:18 PM »
here's soemthing i've worked on for a couple of weeks:

How would you imitate Koishi's 反応「妖怪ポリグラフ」? (the polygraph one.)

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #645 on: September 06, 2009, 03:49:41 PM »
Give me an hour...
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."

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #646 on: September 06, 2009, 04:03:01 PM »
here's soemthing i've worked on for a couple of weeks:

How would you imitate Koishi's 反応「妖怪ポリグラフ」? (the polygraph one.)
Fairly easily, I would think. Bombproof C Lasers that rotate, and faster depending on the time. Then some simple trig based on the player's position and copied to the rest of the lasers, and spawn bullets based on that, which delete themselves after a while.

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

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #647 on: September 06, 2009, 04:20:03 PM »
Done. I'm fairly shure that there will be some error-causing typoes in there, but as I don't have Japanese settings on I can't test it right now without rebooting. Might fix any errors inside later today...

Edit: Fixed the errors. It is still somewhat different, but I think I know how to fix that. Just give me another 30-60 minutes...

Edit2: There you have it. The only remaining differences should be minor number juggling and of course SA having way superior graphics and effects which I can't replicate.  :V

Code: [Select]
#TouhouDanmakufu
#Title[Stuff 94 - polygraph]
#Text[bla]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let BossImage = "script\img\ExRumia.png";
    let BossCutIn = "script\img\ExRumia.png";

    let frame = -300;
    let angv=0;

    let color1 = [RED11, BLUE11, RED11, BLUE11, RED11, BLUE11, RED11, BLUE11];
    let color2 = [RED23, BLUE23, RED23, BLUE23, RED23, BLUE23, RED23, BLUE23];

    @Initialize {
        LoadGraphic(BossImage);
        SetLife(2500);
        SetDamageRate(0, 0);
        SetTimer(60);
        SetMovePosition02(GetCenterX,GetCenterY,60);
        SetEnemyMarker(true);
        SetDurableSpellCard;
    }

    @MainLoop {

        SetCollisionA(GetX, GetY, 24);
        SetCollisionB(GetX, GetY, 24);


        if(frame==-120){
           ascent(k in 0..8){ Tlaser(22.5+45*k, color1[k], color2[k]); }
        }

        if(frame==0){ angv=1/5; }

        if(frame>0){ angv+=0.000125; }

        frame++;

        yield;
    }

    @DrawLoop {

if(GetSpeedX()==0){SetGraphicRect(64,1,127,64);}
else if(GetSpeedX()>0){SetGraphicRect(192,1,255,64);}
else if(GetSpeedX()<0){SetGraphicRect(128,1,191,64);}
        SetTexture(BossImage);
        DrawGraphic(GetX, GetY);
       
    }

    @Finalize {
    }

    task Tlaser(ang, graph1, graph2){
        let obj=Obj_Create(OBJ_LASER);
        Obj_SetPosition(obj, GetCenterX, GetCenterY);
        Obj_SetAngle(obj, ang);
        Obj_SetSpeed(obj, 0);
        ObjShot_SetGraphic(obj, graph1);
        ObjLaser_SetLength(obj, 1000);
        ObjLaser_SetWidth(obj, 16);


        let timer=-180;
        let distance;
        let px;
        let py;

        while(Obj_BeDeleted(obj)==false){

            yield;
            timer++;

            Obj_SetAngle(obj, Obj_GetAngle(obj)-angv);

            if(timer>0&&timer%7==0){
                distance=( (GetPlayerX-GetCenterX)^2 + (GetPlayerY-GetCenterY)^2 )^0.5;

                px=GetCenterX+distance*cos(Obj_GetAngle(obj));
                if(px<GetClipMinX+8){ px=GetClipMinX+8; }
                if(px>GetClipMaxX-8){ px=GetClipMaxX-8; }

                py=GetCenterY+distance*sin(Obj_GetAngle(obj));
                if(py<GetClipMinY+8){ py=GetClipMinY+8; }
                if(py>GetClipMaxY-8){ py=GetClipMaxY-8; }

                CreateShotA(1, px, py, 1);
                SetShotDataA(1, 0, 0, Obj_GetAngle(obj)-90, 0, 0, 0, graph2);
                SetShotKillTime(1, ceil(45/angv)-2);
                FireShot(1);

            }
        }
       
    }

}

Shows yet again that the difficult part is not to script your patterns but to think of patterns to script.
...damn...
« Last Edit: September 06, 2009, 04:59:46 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."

Nuclear Cheese

  • Relax and enjoy the danmaku.
    • My homepage
Re: Danmakufu Q&A/Problem Thread
« Reply #648 on: September 06, 2009, 08:43:18 PM »
Oh goody, I walked past Effect Objects before, and quickly ran when I saw words like
ObjEffect_SetVertexXY and ObjEffect_SetPrimitiveType.
But now I need to use them!

All I really want is a normal image of a 1:1 scale to appear on screen.
But there doesn't seem to be a normal coordinates command like SetGraphicRect(0,0,144,144);
I've looked through Nuclear Cheese's tutorial, which somewhat helped me. But like hell I can understand this part:

Code: [Select]
          ObjEffect_SetTexture(objid, imagefile);

          ObjEffect_SetPrimitiveType(objid, PRIMITIVE_TRIANGLELIST);

          ObjEffect_CreateVertex(objid, 3);

          ObjEffect_SetVertexXY(objid, 0, -20, -20);
          ObjEffect_SetVertexUV(objid, 0, 0, 0);

          ObjEffect_SetVertexXY(objid, 1, 20, 0);
          ObjEffect_SetVertexUV(objid, 1, 255, 127);

          ObjEffect_SetVertexXY(objid, 2, -20, 20);
          ObjEffect_SetVertexUV(objid, 2, 127, 255);

I applied that to the code I have now, and it works, but it makes a shape of it that I'm not looking for. How can I make it a regular square of 144x144?

This is what I have now:

Code: [Select]
let broom=(Obj_Create(OBJ_EFFECT));
Obj_SetPosition(broom,GetX,GetY);
ObjEffect_SetLayer(broom,3);
ObjEffect_SetAngle(broom,0,0,0);
ObjEffect_SetTexture(broom,broom1); (it's properly linked to an image)

if(frame>60){
ObjEffect_SetAngle(broom,0,0,time*3);
}

Just as a test, I wanted this to start spinning after 60 frames.

But when I paste NC's sample in the code I have now, I get this:

<picture>
(She's already sitting on a broom, but that's just the enemy's graphic, not the broom I want to spin around)

-It keeps creating more and more images.
-And they're definitely not square. D:


How can I fix this, and how exactly do those vertices options change the shape of the graphic?


(By the way, I edited ObjEffect_SetLayer in the wiki. Layer 8 draws over the frame while layer 7 still draws below. Useful too, especially when I get the answer to the question above. :P)



Edit: Nevermind that anymore, I somehow figured it out. The wiki needs a better explanation for this! Really!

So if anyone wants a sample on how to draw a square with Object Effects:

Code: [Select]
if(frame==30){
broom=(Obj_Create(OBJ_EFFECT));

Obj_SetPosition(broom,cx,cy-16);
ObjEffect_SetLayer(broom,3);
ObjEffect_SetAngle(broom,0,0,0);
ObjEffect_SetTexture(broom, broom1);

ObjEffect_SetPrimitiveType(broom,PRIMITIVE_TRIANGLEFAN);

ObjEffect_CreateVertex(broom,4);

ObjEffect_SetVertexXY(broom,3,72,72);
ObjEffect_SetVertexUV(broom,0,0,0);

ObjEffect_SetVertexXY(broom,2,-72,72);
ObjEffect_SetVertexUV(broom,1,144,0);

ObjEffect_SetVertexXY(broom,1,72,-72);
ObjEffect_SetVertexUV(broom,2,0,144);

ObjEffect_SetVertexXY(broom,0,-72,-72);
ObjEffect_SetVertexUV(broom,3,144,144);
}


It seems my Effect Object tutorial could use a bit of clarification ... hmm ...


But, to be honest, wouldn't it just be easier to draw the broom using the simple drawing commands?  Something like:

Code: [Select]
SetGraphic("broom.png");
SetGraphicAngle(0, 0, rotation);
SetGraphicRect(0, 0, 144, 144);
DrawGraphic(broom_x, broom_y);
(Note: the above code would be placed in your script's @DrawLoop)

If you just want to draw a square/rectangular graphic, I think that should do what you need sufficiently.  Unless you're going for some effect that I'm not seeing at the moment ...



Effect objects are very complicated beasts ... I sure as hell wouldn't have understood them if it wasn't for the face that I've already worked with 3D graphics programming for a while.  Their use is probably unnecessary for most things; mainly, you'd want to use them for drawing irregular shapes and such.
to quote Naut:
"I can see the background, there are too many safespots."
:V

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #649 on: September 06, 2009, 09:04:54 PM »
I figured it out now. :3
The main reason I need to do it this way is so I can choose which layer I will draw on. Because there are a few cases where I want stuff to appear above the player, and sometimes even above the subscreen frame.
Unfortunately, you can't pick the layer by using the DrawGraphic method, it always appears below the player and enemy.
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #650 on: September 07, 2009, 06:10:15 PM »
Something totally out of the question but =P

What is Danmakufu in japanese?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #651 on: September 07, 2009, 06:27:41 PM »
弾幕風 = bullet curtain "method". Or style or function or whatever.

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 #652 on: September 07, 2009, 06:41:10 PM »
Ah, now I can put this in front of my touhou moves + tags. =) Thanks Drake.

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #653 on: September 08, 2009, 03:34:30 AM »
This will probably be a difficult thing for anyone to help me with, but I'd appreciate some help...

Suwako Player (Everything but cutin drawn by yours truly, and yes, that other Suwako is freaking huge- it's the original, and I'm keeping it for massive laughs later on...)

Okay, the problem is simple- the frogs fire normally. No problem! Well, until you start moving around and bringing them out of synch. Eventually, some of them will take TWICE as long to finish exploding. That is, the explosions will fully animate twice before finally vanishing. I don't know if this is due to the explosions getting spawned twice or what, but I know that it's not what should be happening, and it actually doesn't happen normally, as far as I know...

(Also, I know that when they leave the play area, the explosions appear in semi-random positions... I'm more worried about fixing this double-explosion problem than putting checks for if they're out of the playfield when they explode. I'm also not concerned with the fact that I have six tasks. I'm not going to put them into one until all this works perfectly.)


(and yes, the explosions DO appear when the frogs hit the enemy. It was much easier than you'd think, too, just make them appear when the frog vanishes... No need to do any silly Collision checks with other objects...)

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #654 on: September 08, 2009, 03:45:47 AM »
Yes, yes, let's all laugh at Drake for trying to find a extraordinary difficult solution to an easy problem.

;_;

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

Re: Danmakufu Q&A/Problem Thread
« Reply #655 on: September 08, 2009, 03:57:50 AM »
So the shots are supposed to go out of sync? You just want the bomb animation to not play a trillion times? Make each section of the bomb animation a different bullet graphic. Instead of:

Code: [Select]
ShotData
{
id = 3
render = ADD
alpha=210
angular_velocity = 0
AnimationData
{
animation_data = (3, 176, 28, 228, 77)
animation_data = (3, 235, 28, 287, 77)
animation_data = (3, 299, 28, 351, 77)
animation_data = (3, 358, 28, 410, 77)
animation_data = (3, 421, 28, 473, 77)
animation_data = (3, 482, 28, 534, 77)
animation_data = (3, 535, 28, 587, 77)
}
}

Have something like:
Code: [Select]
ShotData
{
id = 3
render = ADD
alpha=210
angular_velocity = 0
rect = (3, 176, 28, 228)
}
ShotData
{
id = 4
render = ADD
alpha=210
angular_velocity = 0
rect = (3, 235, 28, 287)
}
ShotData
{
id = 5
render = ADD
alpha=210
angular_velocity = 0
rect = (3, 299, 28, 351)
}
....//etc.

And in your froggy tasks, have them appear for so many frames. Like so:

Code: [Select]
loop(3){
ObjShot_SetGraphic(Explo6, 3);
yield;
}
loop(3){
ObjShot_SetGraphic(Explo6, 4);
yield;
}
loop(3){
ObjShot_SetGraphic(Explo6, 5);
yield;
}
...//etc...

I have an example script if this isn't clear.
This way the task will just be suspended when you die or something, and the animation will stop until you respawn and the task can continue. Looks wierd, but you can try it to see if you like it more.

Yes, yes, let's all laugh at Drake for trying to find a extraordinary difficult solution to an easy problem.

;_;

Sorry brah, meant no offense ;_;

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #656 on: September 08, 2009, 04:10:03 AM »
Alright, Naut, I'll try that... and oddly enough, I was THINKING about it earlier...

Drake: I wasn't even laughing in my head. :> In fact, as I was posting it, the only think related to you I was thinking of was "Hey wait, now this solves Drake's problem! Awesome! :D" And I mean that in a GOOD way!

EDIT: Well, the code you told me to use is fine, but... The stuff now ALWAYS animates twice, but only if I hold the shot button. In fact, it'll loop like this if I do that:

1. Animate twice, stop a few frames into a third
2. Vanish without an explosion upon refiring
3. Repeat

However, if I merely PRESS the shot key and immediately release it, it animates once, but if I try to press it before it will refire, but at a time where it'll fire again before the "shotCount" resets to -1, when the next set fires, they'll go too far- all the way to the enemy, from the bottom of the screen! The next shots after that mess up, too- some explode immediately, but LOWER than where the frogs should start... They'd explode right about where the player is. The others still explode sooner than they should (less than a second afterward), but not immediately. This is seriously perplexing.
« Last Edit: September 08, 2009, 04:25:33 AM by pikaguy900 »

Re: Danmakufu Q&A/Problem Thread
« Reply #657 on: September 08, 2009, 04:24:00 AM »
How do i make the effect that a white orb moves across the screen firing bullets, like the ones in Flan's Cranberry Trap, would i have to make a enemy script that goes across the screen or what?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #658 on: September 08, 2009, 04:27:18 AM »
You just need a position, an enemy isn't needed. Make it an object bullet that follows an x and y coordinate each frame, and just make instructions for the x and y positions.

Or you could use CreateShotA_XY instead and fire off AddShots.

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 #659 on: September 08, 2009, 08:37:16 AM »
Question, I am probably going to get Yukari gapped for this crazy method but let us see. Here is the case:

CASE SOLVED - Thanks Naut on IRC


- I am using a familiar which is spawned from a file "fam.txt"

- However, the boundaries for the GraphicRect and texture are passed to the file by a seperate Function file ("famfunction.txt"). The famfunction.txt contains basicly a task which is called inside your main file with parameters.

- Here is the deal. The boundaries work fine but somehow I cannot seem to pass the texture path for it.

-------------------- In the main file
let famimg = CSD ~ <path>;
fammer(<parameters>,famimg,<parameters>);   <--- this is a function task declared in famfunction.txt
#include_function famfunction.txt   <---- logical else you cannot call the function

-------------------- in the function file
function fammer(<parameters>,img,<parameters>){
let getImg = img <-- retreiving from the parameters
SetCommonData("leftBoundary",left);   <--- retreiving parameters etc for all 4 values

CreateEnemyFromFile(CSD~"fam.txt", GetX, GetY, 0, 0, getImg);  <-- ! Note the argument!
}


-------------------- Inside fam.txt
script_enemy_main {
    let familiarImg = GetArgument;  <--- ! Note here the argument from create is get!
#include_function famfunction.txt   <---- logical else it wouldn't know

~~~~~~~~

Problem: the image is not being get. And Danmakufu doesn't likes GetCommonData here, it makes it instantly crash
« Last Edit: September 08, 2009, 01:39:40 PM by Helepolis »