Author Topic: Danmakufu Q&A/Problem thread number 4  (Read 207061 times)

Sejha

  • I think Im a game dev. And Musician.
I've evolved a lot. When did I make this account again?

Zerro

  • ERRORS,
  • ERRORS EVERYWHERE
Re: Danmakufu Q&A/Problem thread number 4
« Reply #451 on: October 10, 2010, 05:38:38 PM »
I have question.

I wanna shoot a stream of bullets at where the player is but not have it move if the player does.
Like, I guess, get the player's location one frame and shoot the stream to that location.

I dunno if I worded that right...
Life's a shmup, play on lunatic.

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem thread number 4
« Reply #452 on: October 10, 2010, 05:43:54 PM »
I have question.

I wanna shoot a stream of bullets at where the player is but not have it move if the player does.
Like, I guess, get the player's location one frame and shoot the stream to that location.

I dunno if I worded that right...
Code: [Select]
task ShootLine(x, y, tx, ty, v, graph, n, t){
    let tang = atan2(ty-y, tx-x);
    loop(n){
        CreateShot01(x, y, v, tang, graph, 0);
        loop(t){ yield; }
    }
}

Should be self explanatory.
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."

Formless God

Re: Danmakufu Q&A/Problem thread number 4
« Reply #453 on: October 10, 2010, 10:53:44 PM »
Not sure if I missed the function for it but .... how do I hide the default health bar ?

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem thread number 4
« Reply #454 on: October 10, 2010, 11:11:46 PM »
Create the boss as a normal enemy, not as a boss. You'll have to make custom functions for a lot of other things if you do that, though.
Alternatively, just cover it up with your own health bar.

GenericTouhouFailure

  • WHAT DO YOU MEAN IT'S NOT CALLED UNL? *boom*
Re: Danmakufu Q&A/Problem thread number 4
« Reply #455 on: October 10, 2010, 11:13:07 PM »
Not sure if I missed the function for it but .... how do I hide the default health bar ?
Not possible.
you can mask it by drawing effect objects over it which is what most people do.
If not you may want to spawn the boss as a regular enemy and then use CreateEnemyFromFile to go to the next file
Code: [Select]
task SPFinalize{
CreateEnemyFromFile(CSD~"spell1.txt",GetX,GetY,0,0,0);

loop(30){
let a = rand(0,360);
let x = rand(30,60)*sin(a);
let y = rand(30,60)*cos(a);
CreateMOFItem("POINT",GetX+x,GetY+y);

}
}
Replace SPFinalize with @Finalize or something
SPFinalize was just a finalize function that spawns the next enemy 60 frames before vanishing current enemy
Quote
Warning - while you were typing a new reply has been posted. You may wish to review your post.
Dammit I hate you

Sejha

  • I think Im a game dev. And Musician.
Re: Danmakufu Q&A/Problem thread number 4
« Reply #456 on: October 11, 2010, 01:44:13 AM »
Just anothr quick question.

Say I wanted to make it so that upon reaching X value of Graze, Point value increases by a value of Y. How would I go about doing this exactly? I understand the ideas behind it very easily, but I lack the knowledge of DNH's more complex functions and commands.
I've evolved a lot. When did I make this account again?

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem thread number 4
« Reply #457 on: October 11, 2010, 01:51:48 AM »
Code: [Select]
let lastgraze=0;
@MainLoop{
  if(GetGraze>=x&&lastgraze<x){
    AddPoint(1000);
  }
  lastgraze=GetGraze;
}
This will run the AddPoint code a single time once your graze counter reaches x. It checks if your graze counter is greater than or equal to x, but your graze counter last frame wasn't.

Sejha

  • I think Im a game dev. And Musician.
Re: Danmakufu Q&A/Problem thread number 4
« Reply #458 on: October 11, 2010, 02:29:32 AM »
Code: [Select]
let lastgraze=0;
@MainLoop{
  if(GetGraze>=x&&lastgraze<x){
    AddPoint(1000);
  }
  lastgraze=GetGraze;
}
This will run the AddPoint code a single time once your graze counter reaches x. It checks if your graze counter is greater than or equal to x, but your graze counter last frame wasn't.
Awesome. Thanks.
I've evolved a lot. When did I make this account again?

Formless God

Re: Danmakufu Q&A/Problem thread number 4
« Reply #459 on: October 13, 2010, 12:34:15 AM »
Yes, thanks to you both. I got it working now :3



I'm using this code from Mitori's script to draw the right-hand display, but there are a few parts I don't understand. What happens if a yield; is placed at the top ? And why doesn't the infinite loop freeze DMF ?
Code: [Select]
SetDefaultStatusVisible(false);

task PlayerOther{
        let sys=csd~"img\SystemA.png";
LoadGraphic(sys);
yield;

        let oLife0 = []; let oLife = [];

        loop{
                 ascent(let p in 0..8){
                        oLife0 = oLife0 ~ [p];
                        oLife0[p] = Obj_Create(OBJ_EFFECT);
ObjEffect_SetPrimitiveType(oLife0[p], PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(oLife0[p], 4);
ObjEffect_SetTexture(oLife0[p],sys);
ObjEffect_SetLayer(oLife0[p],8);

ObjEffect_SetVertexXY(oLife0[p], 0, -8, -8);
ObjEffect_SetVertexXY(oLife0[p], 1, -8,  8);
ObjEffect_SetVertexXY(oLife0[p], 2,  8, -8);
ObjEffect_SetVertexXY(oLife0[p], 3,  8,  8);

ObjEffect_SetVertexUV(oLife0[p], 0,  80, 2);
ObjEffect_SetVertexUV(oLife0[p], 1,  80, 18);
ObjEffect_SetVertexUV(oLife0[p], 2,  96,2);
ObjEffect_SetVertexUV(oLife0[p], 3,  96,18);

Obj_SetPosition(oLife0[p],x + p * 16,y);
                }
                ascent(let q in 0..GetPlayerLife){
                        oLife = oLife ~ [q];
                }
                ascent(let p in 0..length(oLife)-1) {
                        oLife[p] = Obj_Create(OBJ_EFFECT);
ObjEffect_SetPrimitiveType(oLife[p], PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(oLife[p], 4);
ObjEffect_SetTexture(oLife[p],sys);
ObjEffect_SetLayer(oLife[p],8);

ObjEffect_SetVertexXY(oLife[p], 0, -8, -8);
ObjEffect_SetVertexXY(oLife[p], 1, -8,  8);
ObjEffect_SetVertexXY(oLife[p], 2,  8, -8);
ObjEffect_SetVertexXY(oLife[p], 3,  8,  8);

ObjEffect_SetVertexUV(oLife[p], 0,  0, 2);
ObjEffect_SetVertexUV(oLife[p], 1,  0, 18);
ObjEffect_SetVertexUV(oLife[p], 2,  16,2);
ObjEffect_SetVertexUV(oLife[p], 3,  16,18);

Obj_SetPosition(oLife[p],x + p * 16,y);
                }

                yield;

                if (OnPlayerMissed) { Obj_Delete(oLife[length(oLife)-1]); }

                ascent(let p in 0..length(oLife0)){
Obj_Delete(oLife0[p]);
}
                ascent(let p in 0..length(oLife)){
Obj_Delete(oLife[p]);
}
       }
}

Re: Danmakufu Q&A/Problem thread number 4
« Reply #460 on: October 13, 2010, 12:37:18 AM »
I'm using this code from Mitori's script to draw the right-hand display, but there are a few parts I don't understand. What happens if a yield; is placed at the top ? And why doesn't the infinite loop freeze DMF ?
[codez]

The yield at the top prevents the effect objects from being made during the first frame, which is the cause of some bugs. There is no infinite loop, the yield near the bottom allows the loop to escape and resume every frame.

Formless God

Re: Danmakufu Q&A/Problem thread number 4
« Reply #461 on: October 13, 2010, 12:50:13 AM »
So the yield; there does the same thing as a break; ?

Re: Danmakufu Q&A/Problem thread number 4
« Reply #462 on: October 13, 2010, 02:15:23 AM »
Break would exit the loop completely, never to return. Yield will resume the loop the next frame. Yield is covered in the intermediate tutorial.

Drake

  • *
Re: Danmakufu Q&A/Problem thread number 4
« Reply #463 on: October 13, 2010, 02:41:56 AM »
Yield means "go do other shit and come back when you're done". Code hits yield, does other stuff, resumes where yield is, hits loop and goes over again.

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

Formless God

Re: Danmakufu Q&A/Problem thread number 4
« Reply #464 on: October 13, 2010, 07:11:53 AM »
Oh ... I get it now. (yield has always been bugging me because people seem to just throw it all over the place and their codes would still work >_>)



I'm trying to use a render target to re-draw my background. I've been following Azure's tutorial but the result was pretty messed up. Did I do it wrong somewhere ?
Code: [Select]
@Initialize {
    LoadImages;

    CreateRenderTarget("bg",384,448);
    SetRenderTarget("bg");

    //SetTexture and stuff, which I assume is just copying stuff from @BackGround ?
    SetGraphicAngle(0,0,0);
    SetGraphicScale(1,1);
    SetTexture(bgb);
    SetGraphicRect(bgscr,-bgscr,512-bgscr,512-bgscr);
    DrawGraphic(GetCenterX,GetCenterY);
    SetTexture(bgt);
    SetAlpha(224);
    SetGraphicRect(0,0,256,256);
    SetGraphicScale(1.5,1.76);
    SetGraphicAngle(0,0,0);
    bgscr-=3;
    DrawGraphic(GetCenterX,GetCenterY);

    SetRenderTarget("DEFAULT");
(by the way, the bgscr variable is used to scroll the image and changes every frame, but AFAIK @Initialize only runs each line once. Do I need to move the bgscr-=3; line into a loop ?)

Code: [Select]
@DrawLoop {
        SetTexture("bg");
        SetGraphicRect(0,0,384,448);
        DrawGraphic(GetCenterX,GetCenterY);
}

Code: [Select]
@Finalize {
        DeleteImages;
        ClearRenderTarget("bg");
    }

GenericTouhouFailure

  • WHAT DO YOU MEAN IT'S NOT CALLED UNL? *boom*
Re: Danmakufu Q&A/Problem thread number 4
« Reply #465 on: October 13, 2010, 12:57:32 PM »
Oh ... I get it now. (yield has always been bugging me because people seem to just throw it all over the place and their codes would still work >_>)



I'm trying to use a render target to re-draw my background. I've been following Azure's tutorial but the result was pretty messed up. Did I do it wrong somewhere ?
Code: [Select]
@Initialize {
    LoadImages;

    CreateRenderTarget("bg",384,448);
    SetRenderTarget("bg");

    //SetTexture and stuff, which I assume is just copying stuff from @BackGround ?
    SetGraphicAngle(0,0,0);
    SetGraphicScale(1,1);
    SetTexture(bgb);
    SetGraphicRect(bgscr,-bgscr,512-bgscr,512-bgscr);
    DrawGraphic(GetCenterX,GetCenterY);
    SetTexture(bgt);
    SetAlpha(224);
    SetGraphicRect(0,0,256,256);
    SetGraphicScale(1.5,1.76);
    SetGraphicAngle(0,0,0);
    bgscr-=3;
    DrawGraphic(GetCenterX,GetCenterY);

    SetRenderTarget("DEFAULT");
(by the way, the bgscr variable is used to scroll the image and changes every frame, but AFAIK @Initialize only runs each line once. Do I need to move the bgscr-=3; line into a loop ?)

Code: [Select]
@DrawLoop {
        SetTexture("bg");
        SetGraphicRect(0,0,384,448);
        DrawGraphic(GetCenterX,GetCenterY);
}

Code: [Select]
@Finalize {
        DeleteImages;
        ClearRenderTarget("bg");
    }
I didn't check the code but.
Code: [Select]
3 Parameters
    1) The name of the render-target texture you want to create
    2) The width of the render target to be created, must be a power of 2 (2, 4, 8, 16, 32, 64, 128, 256, ...)
    3) The height of the render target to be created, must be a power of 2
and i'm pretty damn sure that 384 and 448 are not powers of 2 unless my math fails really hard.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem thread number 4
« Reply #466 on: October 13, 2010, 01:01:31 PM »
and i'm pretty damn sure that 384 and 448 are not powers of 2 unless my math fails really hard.

256 + 128 = 384.

Drake

  • *
Re: Danmakufu Q&A/Problem thread number 4
« Reply #467 on: October 13, 2010, 02:45:26 PM »
That isn't the problem, render targets just need to be explained a bit 'better'.

First of all, think of a render target as two things:
-A render target has the same use as any other image you load into DNH. However, instead of loading an image from a directory, you create it within the script and build it bottom-up.
-A render target is also the same as an entirely new DrawLoop or BackGround. You pile images on it it drawing order to make a picture, then the next frame you redo it. The exception, is that if you don't change it or reset it per frame, it will stay the same.

The example Azure used created the target in Initialize simply for demonstration. You don't need to create it in Initialize, but if you're using said target right away, you obviously need to create the target before you use it, so if you're using the exact same image the whole time in a single spell script, go right ahead. Otherwise, you can easily write a task to reupdate the target every frame. Backgrounds in particular easy to do this with, although you could really just use BackGround for it and considering you aren't doing any huge modifying to the target, there isn't much use for it. Good for practice though.

task RENDER_background{
   let bgscr = 0;
   CreateRenderTarget("bg",384,448);   //Only need to do this once.
   loop{
      ClearRenderTarget("bg");   //This resets the render target every frame. Otherwise, you'd be drawing more stuff on the stuff already there.
      SetRenderTarget("bg");

      SetTexture(bgb);
      SetGraphicRect(bgscr, -bgscr, bgscr+512, -bgscr+512);   //Diagonal up-right.
            //Clearly label this stuff and I suggest writing it like this instead. Ambiguous value first, then add the unchanging rect values.
      SetGraphicAngle(0,0,0);
      SetGraphicScale(1,1);
      DrawGraphic(GetCenterX,GetCenterY);

      SetTexture(bgt);
      SetAlpha(224);
      SetGraphicRect(0, 0, 256, 256);
      SetGraphicAngle(0,0,0);
      SetGraphicScale(1.5,1.76);
      DrawGraphic(GetCenterX,GetCenterY);

      bgscr-=3;
      SetRenderTarget("DEFAULT");      //Done drawing the image, switch back to normal drawing.
      yield;   //Do other stuff.
   }
}


Call this in Initialize or at some other significant point and it should do what you want.

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

GenericTouhouFailure

  • WHAT DO YOU MEAN IT'S NOT CALLED UNL? *boom*
Re: Danmakufu Q&A/Problem thread number 4
« Reply #468 on: October 14, 2010, 08:14:12 AM »
How do i use danmakufu's 3d drawing functions?
(I suck terrible balls at making backgrounds)

Drake

  • *
Re: Danmakufu Q&A/Problem thread number 4
« Reply #469 on: October 14, 2010, 07:40:10 PM »
NC's drawing tutorial covers 3D drawing. As for making backgrounds, it's pretty similar to 2D but the best way to learn is by trial and error.

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

Chau

  • Warning! Incoming Engrish post!
Re: Danmakufu Q&A/Problem thread number 4
« Reply #470 on: October 17, 2010, 10:34:10 AM »
Is it better to use CreateEnemyFromFile instead of CreateEnemyFromScript? Are there any advantages or disadvantages?

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem thread number 4
« Reply #471 on: October 17, 2010, 10:41:05 AM »
With CreateEnemyFromFile, you don't have to put everything into the same script file. That way the code becomes easier to read. On the other hand, if you already have a lot of files in the parent script folder, you may want to keep the number of files low, so in that case it would be helpful to use CreateEnemyFromScript instead.

It is a matter of organisation, mostly.

Although, if you use CreateEnemyFromScript, danmakufu has a little problem that can get annoying:
You can use #include_function for any specific function only once per script. This means if you want to include a certain universal script block in both the parent and the child enemies, you can't include it with #include_function in both script parts when they are in the same file. In that case, you would have to use CreateEnemyFromFile.

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."

8lue Wizard

  • Cobalt Magician
  • (Apparently)
Re: Danmakufu Q&A/Problem thread number 4
« Reply #472 on: October 18, 2010, 01:30:09 AM »
This just in: Danmakufu's 3d coordinate system makes absolutely no logical sense whatsoever. And why the hell is my fog changing when I'm not even moving the camera?

After some slightly more level-headed experimentation (not to mention a couple face-palms), the system is proving at least sensible, if not intuitive internally consistent. However, fog  remains opaque as ever (literally). Can someone explain to me why this is causing my bg to completely fade out within ~200 frames?
Code: [Select]
    @BackGround{
        SetViewTo(0, 0, 0);
        SetViewFrom(-200, 0, 0);
        SetFog(0,500,0,0,0);
        SetGraphicAngle(90, 0, 0);
        SetTexture(bg_floor);
        SetGraphicRect(0, 0, 2400, 450);
        DrawGraphic3D(600-(frame%1280)/2,-50,0);
    }

Commenting out SetFog fixes it btw.
« Last Edit: October 18, 2010, 02:44:24 AM by Bluely Blue »

Formless God

Re: Danmakufu Q&A/Problem thread number 4
« Reply #473 on: October 18, 2010, 02:55:45 AM »
With CreateEnemyFromFile, you don't have to put everything into the same script file. That way the code becomes easier to read. On the other hand, if you already have a lot of files in the parent script folder, you may want to keep the number of files low, so in that case it would be helpful to use CreateEnemyFromScript instead.
So to create a child enemy in the same script, I just put another script_enemy_main name {} after the first @Finalize ?

Although, if you use CreateEnemyFromScript, danmakufu has a little problem that can get annoying:
You can use #include_function for any specific function only once per script. This means if you want to include a certain universal script block in both the parent and the child enemies, you can't include it with #include_function in both script parts when they are in the same file. In that case, you would have to use CreateEnemyFromFile.
Uh, if they are both already in the same file, you would only need to call #include_function once at the top, wouldn't you ? :/

And while we're talking about CreateXFromScript, when is CreateShotFromScript actually needed ? (it doesn't seem to be any better than normal object shots)

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem thread number 4
« Reply #474 on: October 18, 2010, 03:13:34 AM »
And while we're talking about CreateXFromScript, when is CreateShotFromScript actually needed ? (it doesn't seem to be any better than normal object shots)
It's the same type of thing as object familiars and enemy familiars. They each have different advantages, and different amounts of "connection" to the boss script. Shot objects just happen to be able to do things more efficiently most of the time, because shots don't need their own hitboxes/health/etc like familiars sometimes need.

Re: Danmakufu Q&A/Problem thread number 4
« Reply #475 on: October 18, 2010, 03:43:41 AM »
I have the basic stuff drawn for my script, but I want to know how to make 3D trees, I had trouble placing the simple stuff, this kind of stuff is gonna give me a headache X_X

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem thread number 4
« Reply #476 on: October 18, 2010, 10:53:30 AM »
So to create a child enemy in the same script, I just put another script_enemy_main name {} after the first @Finalize ?
Uh, if they are both already in the same file, you would only need to call #include_function once at the top, wouldn't you ? :/
You have to put the script_enemy ENEMY_NAME{} of the child enemy after the closing bracket of the script_enemy_main{} of the script. That also means that the #include_function won't be included in the child script. But since it is still the same file, a clause probably meant to prevent infinite loops during the script loading prevents the same #include_function from working more than once.

Quote
And while we're talking about CreateXFromScript, when is CreateShotFromScript actually needed ? (it doesn't seem to be any better than normal object shots)
I have no idea.  :derp:
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 number 4
« Reply #477 on: October 18, 2010, 11:33:14 AM »
And while we're talking about CreateXFromScript, when is CreateShotFromScript actually needed ? (it doesn't seem to be any better than normal object shots)

It was made obsolete some time ago by tasks and object shots. I personally like the idea of being able to set your own collision and whatnot with bullet scripts, but each bullet is like spawning another enemy, and 2000 enemies floating around the screen is :(

Chau

  • Warning! Incoming Engrish post!
Re: Danmakufu Q&A/Problem thread number 4
« Reply #478 on: October 21, 2010, 05:47:12 PM »
Code: [Select]
@BackGround{
SetViewTo(0,0,0);
}

The error message shows that there is something wrong with SetViewTo. Is there really a mistake or is that because I try to draw 3D stuff in Single scripts? I've already used SetScore in @Initialize so that I can use @BackGround.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem thread number 4
« Reply #479 on: October 21, 2010, 06:20:10 PM »
Code: [Select]
@BackGround{
SetViewTo(0,0,0);
}

The error message shows that there is something wrong with SetViewTo. Is there really a mistake or is that because I try to draw 3D stuff in Single scripts? I've already used SetScore in @Initialize so that I can use @BackGround.

Correct me if I am wrong, but that is a stage function right? My question: Is that a stage script you are trying to make?