Author Topic: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m [Closed, read last post!]  (Read 184955 times)

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #840 on: November 15, 2014, 08:23:39 PM »
LoadUserShotData("shotdatapath"); for load the shot data and use the shot ID (set in the shot file) instead of the default shot's RED01 ?
Something like:

CreateShot01(x,y,speed,angle,1,delay); for spawn the shot with the ID=1.

Seems simple enough. Someone should put this to danmakufu wiki. There was nothing mentioned about this (like I said before). On that note someone should also make a tutorial about 3D drawing. I had a lot of trouble getting started because there was no documentation. Just a brief explanation on each function.

For the animation, do you use frame1 and frame2 in the mainloop?
To make this I do somthing like that (adapted from ph3 so functions are not necessary good but is almost the same way in 0.12m):
Code: [Select]
<code cut>The animation frames on the boss graphic file are 32x32 squares. And the "anim" variable horizontally shift the GraphicRect by 32 to shift to the next square.
I think you can also use a task instead of the drawloop.

Hmm... Maybe that's more reliable than inputting values manually. I'll have to test this way later since I'm on my laptop now and I'm too lazy to open my pc just to test this.

Edit: for the enemy script problem, CDS is not defined in the script.

...And once again there is a function I "adapt" as a part of danmakufu. This once happened to me with the wait(); function too...

And enemy have no life (it die immediatly after being created)

Didn't I set the enemy's life to 200 in @Initialize { }?

Just as a by the way question: Is it possible to draw multiple sprites in @DrawLoop { }? One "main sprite" and some "trailing sprites" that disappear after a specific time.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #841 on: November 15, 2014, 09:41:09 PM »
Seems simple enough. Someone should put this to danmakufu wiki. There was nothing mentioned about this (like I said before). On that note someone should also make a tutorial about 3D drawing. I had a lot of trouble getting started because there was no documentation. Just a brief explanation on each function.

The problem with that is that ph3 has vastly different capabilities, and not many people are willing to go back to 0.12m. I made 3D backgrounds in 0.12m but didn't understand 90% of what I was doing, and even now, I only have a partial understanding of how they work despite having made about a dozen of them already.

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #842 on: November 16, 2014, 12:12:13 AM »
Quote
Didn't I set the enemy's life to 200 in @Initialize { }?
Mmh. I miss that. But even with this the enemy spawn, die immediatly, spawn bullets and the script end (but maybe it's due to the VanishEnemy in the main task ><. So it's not a problem in fact. It's just me.).

Quote
Is it possible to draw multiple sprites in @DrawLoop { }? One "main sprite" and some "trailing sprites" that disappear after a specific time.
Yeh. I think. I made it in a player script.


SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #843 on: November 16, 2014, 10:52:45 AM »
Mmh. I miss that. But even with this the enemy spawn, die immediatly, spawn bullets and the script end (but maybe it's due to the VanishEnemy in the main task ><. So it's not a problem in fact. It's just me.).

Right now it doesn't matter if it dies immeniately. I just want to get it working. I did some changes to the enemy script, but it's still crashing danmakufu.
New enemy script: http://pastebin.com/GQHA3680

I was starting to wonder if the issue is in the stage script, so I'll post it here too: http://pastebin.com/DYS2W2Sp
I removed the background because it works fine. Danmakufu crashes as soon as I add the CreateEnemyFromFile commands.

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #844 on: November 16, 2014, 11:19:16 AM »
Can't load enemies or make an effect object without waiting at least one frame.
« Last Edit: November 16, 2014, 11:22:18 AM by Drake »

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

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #845 on: November 16, 2014, 11:34:13 AM »
Okay. It's not the enemy script that makes danmakufu crash. It's the first CreateEnemyFromFile in your mainTask. You can't use CreateEnemyFromfile in @initialize and this first is called in the same time IE in the @initialize.
So, like Drake say, you must use at least a wait(1) before the first CreateEnemyFromFile in your mainTask ;)
There is other functions that can't be used in initialize (but I don't remember what function exactly) so be careful (and check the function list if you have some problems with that. Maybe it's just a function used at the bad place).

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #846 on: November 16, 2014, 12:20:05 PM »
The script works fine now. The only thing is that @Finalize seems to ignore wait times. Any way around this?

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #847 on: November 16, 2014, 12:34:57 PM »
Hum @Finalize is not a loop. When the script come to @Finalize it do the stuff in it one time and the script end. Nothing other. Or if it's a way I never find it.

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #848 on: November 16, 2014, 12:52:20 PM »
But shouldn't it get "stuck" in the while loop for a while that I have there?

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #849 on: November 16, 2014, 03:39:09 PM »
It does go through the while loop, it will just "ignore" yields, in a sense, because @MainLoop stops. You'll never be yielding to a routine that lets the frame end, just currently-running tasks that eventually yield back to @Finalize.

Code: [Select]
Start frame
@Finalize start
loop:
    @Finalize yield
    task1 go, task1 yield, task2 go, task2 yield, ...
    @Finalize go
end loop
@Finalize end

This also has the unwanted behaviour that currently-running tasks get run many extra times on the frame @Finalize runs. Since you can't do what you want anyways, just act as though @Finalize ignores yields and never put them in, so you never have to worry about this side-effect.
« Last Edit: November 16, 2014, 03:44:39 PM by Drake »

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

7636kei

  • The Stardust Jannisary
  • You hear about that thing down in Samothrace?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #850 on: November 16, 2014, 04:16:39 PM »
Perhaps this is a bit twisted, but is there any reserved constant danmakufu use to express e (as in, that 2,718 bla bla bla) (like how pi is reserved)? Because if there isn't, I'll have to make do with approximations.
« Last Edit: November 16, 2014, 04:25:22 PM by Goldstein-Izayoi »

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #851 on: November 16, 2014, 10:21:00 PM »
Nope, gotta define it.

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

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #852 on: November 17, 2014, 10:18:57 AM »
It does go through the while loop, it will just "ignore" yields, in a sense, because @MainLoop stops. You'll never be yielding to a routine that lets the frame end, just currently-running tasks that eventually yield back to @Finalize.

Code: [Select]
Start frame
@Finalize start
loop:
    @Finalize yield
    task1 go, task1 yield, task2 go, task2 yield, ...
    @Finalize go
end loop
@Finalize end

This also has the unwanted behaviour that currently-running tasks get run many extra times on the frame @Finalize runs. Since you can't do what you want anyways, just act as though @Finalize ignores yields and never put them in, so you never have to worry about this side-effect.

Maybe it's best to just make the enemy shoot the pattern. Or if it's possible to spawn enemy in @Finalize, spawn invisible enemy that doesn't have a hitbox that fires the shots and then vanishes.

Is there any better way of making a trailing effect than this:

Code: [Select]
SetTexture(Enemy1);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1, 1);
SetGraphicAngle(0, 0, 0);
SetGraphicRect(0, 0, 63, 63);

DrawGraphic(GetX, GetY);

SetTexture(Enemy1);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1, 1);
SetGraphicAngle(0, 0, 0);
SetGraphicRect(64, 0, 127, 63);

DrawGraphic(GetX-GetSpeedX*15, GetY-GetSpeedY*15);

SetTexture(Enemy1);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1, 1);
SetGraphicAngle(0, 0, 0);
SetGraphicRect(128, 0, 191, 63);

DrawGraphic(GetX-GetSpeedX*25, GetY-GetSpeedY*25);

SetTextureEnemy1);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1, 1);
SetGraphicAngle(0, 0, 0);
SetGraphicRect(192, 0, 255, 63);

DrawGraphic(GetX-GetSpeedX*30, GetY-GetSpeedY*30);

The only issue with this is that every time I have enemy with different speed, I need to re-calculate the multiplications to get the trailing with a suitable length.

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #853 on: November 17, 2014, 12:28:34 PM »
Code: [Select]
let drawstack = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1], [-1, -1, -1]];
let frame = 0;

@DrawLoop{

    SetTexture(Enemy1);
    let rect = // calculate which animation frame you want
// in this case 0, 1, 2, 3 are options, corresponding to the alt/case
    drawstack[0] = [rect, GetX, GetY];

    descent(i in 0..length(drawstack)){ // descent makes the last frames draw first (below the others)
        alternative(drawstack[i][0])
        case(0){ SetGraphicRect(0, 0, 63, 63); }
        case(1){ SetGraphicRect(64, 0, 127, 63); }
        case(2){ SetGraphicRect(128, 0, 191, 63); }
        case(3){ SetGraphicRect(192, 0, 255, 63); }

        DrawGraphic(drawstack[i][1], drawstack[i][2]);

        if(frame == 10 && i > 0){
            drawstack[i] = drawstack[i-1]; // move animation frames down the stack
        }
    }

    frame++;
    if(frame >= 10){ frame = 0; }

}

Something like this? Main question is if you want each trailing sprite to use the same rect as when it was originally drawn (which is what I assume in the above code) or if you have specific sprites for the trailing sprites.
« Last Edit: November 18, 2014, 04:34:45 AM by Drake »

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

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #854 on: November 17, 2014, 02:20:40 PM »
Main question is if you want each trailing sprite to use the same rect as when it was originally drawn (which is what I assume in the above code) or if you have specific sprites for the trailing sprites.

Each trailing sprite has same rect for easier SetGraphicRect calculation, but the sprites itself are smaller the further away it is from the enemy it is trailing.
Here is an image of the enemy:


BTW, can someone explain how SetMovePositionHermite(); works? It's supposed to move in curve, but no matter what values I use the enemies always fly in a straight line.
« Last Edit: November 17, 2014, 02:38:22 PM by Baka94 »

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #855 on: November 18, 2014, 04:34:20 AM »
If that's the case why don't you just use SetGraphicScale()?

Code: [Select]
let drawstack = [[-1, -1], [-1, -1], [-1, -1], [ -1, -1]]; // only need x and y positions if you only use one sprite
let frame = 0;

@DrawLoop{

    SetTexture(Enemy1);
    SetGraphicRect(0, 0, 63, 63);
    drawstack[0] = [GetX, GetY];

    descent(i in 0..length(drawstack)){ // descent makes the last frames draw first (below the others)
        SetGraphicScale(1 - i/6);
        DrawGraphic(drawstack[i][0], drawstack[i][1]);

        if(frame == 10 && i > 0){
            drawstack[i] = drawstack[i-1]; // move animation frames down the stack
        }
    }

    frame++;
    if(frame >= 10){ frame = 0; }

}

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

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #856 on: November 18, 2014, 05:17:57 AM »
If that's the case why don't you just use SetGraphicScale()?

I think someone once said that SetGraphicScale() sucks. I tried your code, but I'm not getting a trail.

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #857 on: November 18, 2014, 05:51:40 AM »
It sucks for detailed sprites, but if you just have a blob or are making effects then it isn't a big deal.

Anyways, its just that I check for frame's value but it never reaches 10. Just move the if(frame >= 10) above the line before it. I never tested this, I sort of expected you to play with it. The important part is working with the frame stack to store previous locations.
« Last Edit: November 18, 2014, 05:58:37 AM by Drake »

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

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #858 on: November 18, 2014, 08:03:00 AM »
I never tested this, I sort of expected you to play with it.

It's probably useless to play with it if I don't understand what kind of logic you are going for. I'm sure you know that it's not guranteed that others understand your code as well as you do. I might get it working, but if I don't understand how the code works it's nearly useless. Only thing I can do is just copy paste it and if it doesn't work I have no idea what to do. This might not be so big issue in Danmakufu,  but in some other languages like 6502 it's very likely that you don't understand someone else's code if they don't explain the logic they are going for.

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #859 on: November 18, 2014, 10:26:29 AM »
That's why I wrote some comments, and I agree. On the flip side, I'm the one taking my time trying to help: if you just reply that it didn't work, and you don't tell me what you tried to do or that you don't understand how it's supposed to work, then I can't really help you either. It'd be more useful for both of us if you asked for elaboration if you didn't understand; I'm not going to assume you don't know what I'm writing unless it's something particularly strange, and you didn't seem put off by the first post, so I expected that you were okay with what I gave you. I don't think that's unreasonable.

The drawstack variable here is an array of positions (which are themselves 2-length arrays, for x and y). Every frame you store the current xy position to the first entry of the array. Then it goes through a descent loop, drawing the sprite at each position stored in the array (with shrinking scale, depending on i). The important bit is that every 10 frames (counted by the frame variable and reset to 0 after it hits 10)*, it sets each entry in the array to the one before it (except the first), which means the array stores the current position, and the positions the enemy was at 10, 20 and 30 frames ago. As written in the comments, I used a descent loop instead of an ascent so the last position gets drawn first then the more recent positions are drawn overtop.

* Maybe I should have just written frame = frame % 10 + 1; instead of the last two lines

All that aside, did you get it to work? It should have if you swapped those lines like I said, or if you use the one line above.
« Last Edit: November 18, 2014, 10:43:38 AM by Drake »

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

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #860 on: November 19, 2014, 02:28:23 PM »
All that aside, did you get it to work? It should have if you swapped those lines like I said, or if you use the one line above.

Not working yet. For some reason I have a feeling that either i or stack is not getting updated properly.

Code: [Select]
@DrawLoop {
SetTexture(Enemy1);
SetGraphicRect(0, 0, 63, 63);
stack[0] = [GetX, GetY];

descent(i in 0..length(stack)) {
SetGraphicScale(1-i/6, 1-i/6);
DrawGraphic(stack[i][0], stack[i][1]);
}

if(frame == 10 && i > 0){
stack[i] = stack[i-1];
}

if(frame >= 10) {
frame = 0;
}

frame++;
}

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #861 on: November 19, 2014, 02:54:59 PM »
if(frame == 10 && i > 0){  stack[i] = stack[i-1];  } goes inside the descent loop.

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

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #862 on: November 19, 2014, 05:10:06 PM »
It works now. I also added alpha fade for the sprites to make it look smoother. I also had to update the stack every frame because the trail wasn't moving smoothly enough otherwise.

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #863 on: November 20, 2014, 05:46:19 PM »
Well, I am having some troubles with stage enemies images. I am using Blargel's animation library and enemies created on  boss scripts work fine, and even the boss themselves work fine with the library, but I cannot get the enemies to get their image drawn on stage scripts. Below I am providing the relevant scripts:

http://pastebin.com/NWi9iXzj
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #864 on: November 23, 2014, 09:40:13 AM »
I'm having a small issue with a new background. The issue is that I want the texture Pillar to move so that it starts inside the fog (-850) and moves along the wall until it's out of view (-150) and then "jumps" back to the fog. However the pillar is not moving. I tried a starting value of -350 (which is on the view) but it's not going anywhere for some reason. I'm using variable slide2 to control the pillar's movement.

Code: [Select]
@BackGround {
SetTexture(Floor);
SetGraphicRect(0, 0+slide, 256, 256*3+slide);
SetGraphicAngle(0, 0, 0);
SetViewFrom(180, 90, 90);
SetViewTo(0, 0, 0);
SetFog(500, 900, 0, 0, 0);
DrawGraphic3D(GetClipMinX-30, -350, 100);

SetTexture(Wall);
SetGraphicRect(0+slide, 0, 256*3+slide, 256);
SetGraphicAngle(0, 90, 90);
DrawGraphic3D(GetClipMinX-155, -350, -30);
DrawGraphic3D(GetClipMinX+95, -350, -30);

SetTexture(Ceiling);
SetGraphicRect(0, 0+slide, 256, 256*3+slide);
SetGraphicAngle(0, 0, 0);
DrawGraphic3D(GetClipMinX-30, -350, -150);

SetTexture(Pillar);
SetGraphicRect(0, 0, 32, 290);
SetGraphicAngle(-45, 90, 90);
DrawGraphic3D(GetClipMinX-165, slide2, -30);

if(slide2 <= -150) { slide2 = -850; }

slide-=15;
slide2+=15;

}

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #865 on: November 23, 2014, 11:46:52 AM »
What happens if you comment out the slide variable counters and add multiple pillars with different static values. Do these appear in different locations?

« Last Edit: November 23, 2014, 02:19:31 PM by Helepolis »

SusiKette

  • @MainLoop { yield; }
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #866 on: November 24, 2014, 05:19:21 AM »
If this is what you meant, then yes they appear in different locations.

EDIT: I fixed it now. My next question is that is it possible to make background "events" so that whenever I change a value in variable something else that 0, @BackGroud {} will execute a backgeound event, such as turn left or turn right. The stage is supposed to be sort of a maze, so it would be nice to get some turns too. What would be even more awesome is that you could take one or more routes to the end of the stage and you could choose which way to go (Similarly how you choose between stage 6a and stage 6b in Imperishable Night).
« Last Edit: November 24, 2014, 05:36:36 AM by Baka94 »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #867 on: November 24, 2014, 06:45:02 AM »
...My next question is that is it possible to make background "events"...
Yes it is possible as long it is all scripted inside the @BG loop.

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #868 on: December 09, 2014, 03:02:21 AM »
http://pastebin.com/dby3EWXM
ehhh something is wrong with this bomb and i'm not sure what but i think i messed up somewhere inside the tasks...
when triggered, the bomb is declared properly, but nothing happens, aside gaining 300 frames of invincibility  :V
...any clues?? :T

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #869 on: December 09, 2014, 04:27:01 AM »
bullet() is a task, so as soon as it yields, End() is called.

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