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

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #870 on: October 10, 2009, 01:30:27 PM »
Since there are no functions for that in Danmakufu, something like this, as discussed in P.24 of the thread, would be helpful.

Code: [Select]
#TouhouDanmakufu
#Title[MENU FTW]
#Text[This is the description. Did you know that? Oh, sorry.]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let number = 0;
    let orange = [255, 142, 78];
    let white = 255;
    let r1 = 0; let g1 = 0; let b1 = 0;
    let r2 = 0; let g2 = 0; let b2 = 0;
    let r3 = 0; let g3 = 0; let b3 = 0;
    @Initialize {
        SetLife(1);
    }

    @MainLoop {
    //////////////////////////////////
    ForbidBomb(true); ForbidShot(true);
    ///////////////////////////////////
    if(number == 0) {
    r1 = white; g1 = white; b1 = white;
    r2 = orange[0]; g2 = orange[1]; b2 = orange[2];
    r3 = orange[0]; g3 = orange[1]; b3 = orange[2];
    }
    if(number == 1) {
    r2 = white; g2 = white; b2 = white;
    r1 = orange[0]; g1 = orange[1]; b1 = orange[2];
    r3 = orange[0]; g3 = orange[1]; b3 = orange[2];
    }
    if(number == 2) {
    r3 = white; g3 = white; b3 = white;
    r1 = orange[0]; g1 = orange[1]; b1 = orange[2];
    r2 = orange[0]; g2 = orange[1]; b2 = orange[2];
    }
    ///////////////////////////////////
    if(number < 0) {
    number = 0;
    }
    if(number > 2) {
    number = 2;
    }
    if(GetKeyState(VK_UP) == KEY_PUSH) {
    number--;
    }
    if(GetKeyState(VK_DOWN) == KEY_PUSH) {
    number++;
    }
    //////////////////////////////////
    if(GetKeyState(VK_SHOT)==KEY_PUSH) {
      VanishEnemy;
    //Here you put stuff that happens depending what the variable "number" finally is, blah, blah, blah
    }
    }
    @DrawLoop {
               SetFontColor(r1, g1, b1, r1, g1, b1);
   DrawText("The first choice", 40, 45, 20, 255);
               SetFontColor(r2, g2, b2, r2, g2, b2);
   DrawText("Choice 2", 40, 65, 20, 255);
               SetFontColor(r3, g3, b3, r3, g3, b3);
   DrawText("Choice 3", 40, 85, 20, 255);
    }

    @Finalize {
    ForbidBomb(false); ForbidShot(false);
    SetPlayerX(GetCenterX); SetPlayerY(GetClipMaxY-75);
    }
}

This shows three options. put something similar to this in a stage script would be OK.
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Lawence Codye

  • The Nine Tails of Subconscious...
  • Come & your desires shall all become reality...
Re: Danmakufu Q&A/Problem Thread
« Reply #871 on: October 10, 2009, 02:36:39 PM »
...I meant for #TouhouDanmakufu[player] scripts...
Options that follow the player character around...how to make it so that there is 4 of those Options?
...I'm trying to make ReimuC from MoF...
I am the Nine Tails of Subconscious...

Come & your greatest desires will be reality...

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #872 on: October 10, 2009, 09:37:17 PM »
Darnit, why can't I get this thing down?


Alright, what I'm trying to do is make the bullets shoot bullets, so when the first pair of bullets hits the edge of the screen (min/max X Y coordinate), another pair of bullets fires in the opposite direction, and doesn't come back when it leaves the screen.

(Fujiwara "Flaw of Forgiving Shrine" is the best spellcard I can describe it as.  I'm making mine different, but same basic concept.)

AddShot isn't working for me because that's controlled by frames, and the second pair of bullets' coordinates fired will not be on the edge like I want it, if the boss that's firing the first pair of bullets moves a few pixels.  What to do?

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread
« Reply #873 on: October 10, 2009, 09:54:24 PM »
Use object bullets.

Here is an example code for a shot that creates some more shots after reaching the edge of the screen.

Code: [Select]
task bullet(x,y,angle)
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj,x,y);
Obj_SetAngle(obj,angle);
Obj_SetSpeed(obj,2);
ObjShot_SetGraphic(obj,BLUE56);
ObjShot_SetBombResist(obj,true);
ObjShot_SetDelay(obj,10);

while(Obj_GetX(obj) > GetClipMinX+16 && Obj_GetX(obj) < GetClipMaxX-16 && Obj_GetY(obj) > GetClipMinY+16 && Obj_GetY(obj) < GetClipMaxY-16) //While still in bounds, yield.
{yield;}

CreateShot01(Obj_GetX(obj),Obj_GetY(obj),1.5,angle+190,PURPLE56,10);
CreateShot01(Obj_GetX(obj),Obj_GetY(obj),1.5,angle+170,PURPLE56,10);



Obj_Delete(obj);

}

Remember to yield in your @MainLoop or else most of the code will be ignored!

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #874 on: October 10, 2009, 11:17:11 PM »
alright.

One question though, why does the yield in there have to be in brackets?


Whoops, nevermind.  Found it.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #875 on: October 11, 2009, 01:07:43 AM »
Code: [Select]
SetShotDirectionType(PLAYER);doesn't work with object bullets.  What can I use?  I'm not looking for
Code: [Select]
GetAngleToPlayer that is only useful for getting the boss's coordinates to the player, and is useless if I spawn the object shot away from the boss.
« Last Edit: October 11, 2009, 01:22:02 AM by Fujiwara no Mokou »

Re: Danmakufu Q&A/Problem Thread
« Reply #876 on: October 11, 2009, 03:24:28 AM »
@Fujiwara No Mokou:
Don't know how many times I've posted this:
atan2(Player's Y coordinate - Bullet's Y coordinate, Player's X coordinate - Bullet's X coordinate) will get the angle from the bullet (or any point) to the player.
Thus:
atan2(GetPlayerY - Obj_GetY(obj), GetPlayerX - Obj_GetX(obj))


@Aphid:
@naut.
I've also found out something while making a diffrent script yesterday. If I could replace the task in the script I presented then with a function it could probably solve everything. For example, here is a master script with two slave scripts. The second slave runs significantly slower than the primary (which I'm using now) whilst what I'm doing is exactly the same. The cinch? I used a task. Seems NuclearCheese was right about those tasks being poorly coded  :).

Eh, I know tasks will slow down your computer. Running @MainLoop copies a couple hundred times per frame versus only once? Yeah, I know. My argument was for coding basic attacks, in which case the slowdown is so negligable that it didn't matter since you would only have at most half a dozen tasks running, maybe a few more if you've got a few object bullets floating around (of which the object bullets still take more processing power than the actual tasks, as far as I can tell). Granted, I'm not very good at taking tasks out of anything, so... Yeah. My bad anyway. Also, why did you use tasks in the first place if you could just use the function command? The only useful thing about tasks is the use of yield;, so if you didn't need it...

I still should've taken a look at what you were actually doing with your object bullets, since if you could just make them as regular bullets then this problem would've been solved much faster. Should've known, argh!


@pikaguy900:
I'm still not seeing how throwing an ObjEffect over your ObjShot explosion as well as the bullets wouldn't solve everything. Why can't you do this?


@UltimaRepman:
@Naut
Thanks, that solved the problem...

I skimmed over that code tidbit quite a few times before noticing it. I could see how you were running in to problems, heh.

now...another question, anybody.  Is there a way to have 4 options on screen instead of just 2...cause if so, I need to ask how to go about doing this?

The exact same way you spawn two, just repeat two more times. If you're going by Stuffman's tutorial, just make if(position=="BLAH"){ do shit }, if(position=="LOL"){ do more shit }. Or something to that effect.
« Last Edit: October 11, 2009, 03:52:29 AM by Naut »

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #877 on: October 11, 2009, 04:47:13 AM »
If I use DrawGraphic(x,y); to draw an image, does the (0,0) of the image correspond to the (x,y) of the Danmakufu Window?
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Johnny Walker

  • Perdition Crisis~
Re: Danmakufu Q&A/Problem Thread
« Reply #878 on: October 11, 2009, 05:05:23 AM »
If I use DrawGraphic(x,y); to draw an image, does the (0,0) of the image correspond to the (x,y) of the Danmakufu Window?

Yes, my lord!

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #879 on: October 11, 2009, 06:06:16 AM »
Yes, my lord!
Isn't the middle of the image drawn on (x, y) not (0, 0)?

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #880 on: October 11, 2009, 07:22:58 AM »
Isn't the middle of the image drawn on (x, y) not (0, 0)?
I'm thinking of this also: in drawtext, (0,0) of the text -> (x,y)
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Johnny Walker

  • Perdition Crisis~
Re: Danmakufu Q&A/Problem Thread
« Reply #881 on: October 11, 2009, 10:30:10 AM »
Isn't the middle of the image drawn on (x, y) not (0, 0)?

Oh, you're right. I misunderstood the question.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #882 on: October 11, 2009, 06:23:35 PM »
Alright, I've learned a lot here.  I've asked this question once before, but I might as well ask it again and rephrase it, seeing there are so many things you can do with danmakufu.


The magic circle that revolves around the boss, is there a way to change it?  Say, to a ripped sprite from one of the games, or your own?  I tried using my own circle, but it just wasn't...right.  It looks as if Danmakufu takes a flat, straight line and repeats it several times, and bends it into a circle. And reduces the area of that circle as time runs out, without changing the "height" of the image itself, except unless you either loose a life or use a bomb.  But I don't have the slightest clue how to do this.

Also, the cubes that revolve around the main boss. Can those be changed?  Or do I have to set up my own?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #883 on: October 11, 2009, 06:33:19 PM »
Both of them can be replaced by saving an exterior file with the same name. I can't exactly remember where they're supposed to be positioned or the filename, though.

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

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #884 on: October 11, 2009, 07:46:20 PM »
Both of them can be replaced by saving an exterior file with the same name. I can't exactly remember where they're supposed to be positioned or the filename, though.

Well, looks like I'll have a lot of searching to do. Uh, can it be done manually though, like I asked?

Re: Danmakufu Q&A/Problem Thread
« Reply #885 on: October 11, 2009, 08:08:36 PM »
system.png has all the default graphics on it, (pathname /system/system.png if I remember correctly), includes things like the cut-in bar, the magic circle and those fucking squares. There were one or two of us trying to decipher where they were located on the image, so hopefully one of them strolls by to inform us.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #886 on: October 11, 2009, 10:58:18 PM »
Yeah. That cut-in bar is so annoying. I really hope they do find this.

Re: Danmakufu Q&A/Problem Thread
« Reply #887 on: October 12, 2009, 03:36:57 AM »
Ah shit, double posting in two threads. Great. Well, yield; goes in the @MainLoop, not the @DrawLoop, canobiecrazy.

Ah we deleted his post, lovely.
« Last Edit: October 12, 2009, 06:06:27 PM by Naut »

Hat

  • Just an unassuming chapeau.
  • I will never be ready.
Re: Danmakufu Q&A/Problem Thread
« Reply #888 on: October 12, 2009, 04:06:05 PM »
Is there actually a way to bend a linear graphic into a circle? It doesn't seem possible, but I'm just curious (I don't particularly need it for anything, unless I choose to come after the Magic Circle and make a replacement function).

And yeah, lol, I'm still alive.

PT8Sceptile

  • All hail Giant Catfish!
Re: Danmakufu Q&A/Problem Thread
« Reply #889 on: October 12, 2009, 05:08:10 PM »
Karfloozly, for the graphic bending thing, effect objects with a huge amount of vertices might work. If you place effect object vertices in the field in a different formation than how they are placed on the image, the image seemingly bends. A test I made:

Code: [Select]
task asdf() {
let objeff = Obj_Create(OBJ_EFFECT);
ObjEffect_SetTexture(objeff, GetCurrentScriptDirectory~"\Yingyang.png");
ObjEffect_SetRenderState(objeff, ALPHA);
ObjEffect_SetLayer(objeff, 3);
ObjEffect_CreateVertex(objeff, 10);
ObjEffect_SetPrimitiveType(objeff,PRIMITIVE_TRIANGLEFAN);
ObjEffect_SetVertexUV(objeff, 0, 40, 40);
ObjEffect_SetVertexUV(objeff, 1, 0, 0);
ObjEffect_SetVertexUV(objeff, 2, 0, 40);
ObjEffect_SetVertexUV(objeff, 3, 0, 80);
ObjEffect_SetVertexUV(objeff, 4, 40, 80);
ObjEffect_SetVertexUV(objeff, 5, 80, 80);
ObjEffect_SetVertexUV(objeff, 6, 80, 40);
ObjEffect_SetVertexUV(objeff, 7, 80, 0);
ObjEffect_SetVertexUV(objeff, 8, 40, 0);
ObjEffect_SetVertexUV(objeff, 9, 0, 0);
while(!Obj_BeDeleted(objeff)) {
ObjEffect_SetVertexXY(objeff, 0, GetCenterX, GetCenterY);
ObjEffect_SetVertexXY(objeff, 1, GetCenterX - 80, GetCenterY - 20);
ObjEffect_SetVertexXY(objeff, 2, GetCenterX, GetCenterY - 30);
ObjEffect_SetVertexXY(objeff, 3, GetCenterX + 80, GetCenterY - 20);
ObjEffect_SetVertexXY(objeff, 4, GetCenterX + 70, GetCenterY);
ObjEffect_SetVertexXY(objeff, 5, GetCenterX + 60, GetCenterY + 30);
ObjEffect_SetVertexXY(objeff, 6, GetCenterX, GetCenterY + 20);
ObjEffect_SetVertexXY(objeff, 7, GetCenterX - 60, GetCenterY + 30);
ObjEffect_SetVertexXY(objeff, 8, GetCenterX -70, GetCenterY);
ObjEffect_SetVertexXY(objeff, 9, GetCenterX - 80, GetCenterY - 20);
yield;
}
}

Which results in:



(Text edited in afterwards.)

So, since effect objects can apparently bend an object in weird shapes, you could in theory create a huge amount of vertices on the edge of the image you want to curve and place the curved edges on two circles. Or something like that, hopefully you get the idea. However, I'm not exactly sure on this, since the ball in the above image has only 10 vertices, a curved surface would need a lot more to look decent, and I'm not sure how much computing time would some hundreds of vertices require. You can try it out, though.
« Last Edit: October 12, 2009, 05:10:08 PM by PT8Sceptile »

Re: Danmakufu Q&A/Problem Thread
« Reply #890 on: October 12, 2009, 06:08:18 PM »
Clipping the image using tan theta(?) would be better, but Danmakufu seems to hide that function from us.

Hat

  • Just an unassuming chapeau.
  • I will never be ready.
Re: Danmakufu Q&A/Problem Thread
« Reply #891 on: October 12, 2009, 06:27:26 PM »
*single tear* ... I was hoping that I wouldn't have to set a zillion vertices... Oh, well.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #892 on: October 12, 2009, 07:56:52 PM »
Only way to decypher system.png is to create a large sheet perhaps 256x256 or 512x512  with numbered grids which are 32x32. So you can like probably figure out most of them.

The question is, how to make a grid like that :V

Grid made quickly in photoshop, the bomb icon is half a 1c and the enemy marker is 1f en 2f. (non pattern zone)
The player invincible circle seems to be at 1f till 4f (thin zebra pattern) on the X-axis and till bottom of the sheet ( which is missing 16 pixels ) so i.

Cannot figure out the lifebar yet :V seems to be in the non-pattern zone of the sheet as it appears clean.

PS edit: The enemy circle seems to be outside the 512x512 zone. That is interesting.
« Last Edit: October 12, 2009, 08:27:07 PM by Helepolis »

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #893 on: October 13, 2009, 12:22:07 AM »
How can you (and me) decypher system.png?

Just save a system.png there would be OK?
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #894 on: October 13, 2009, 05:19:06 AM »
One more question.

I have a lot of stuff working in my scripts, the spellcards work, everything is coming out nicely.


I even made my own effect for when the boss blows up.  Problem is, though, that it won't load @Finalize.

It's an arrange of effect objects that I cooked up.  But I don't know how to get the X,Y coordinates from the boss when it blows up, and pass it on to a separate enemy script/file, which spawns just where the boss blows up (GetX, GetY).

The main boss is called in the stage script repeatedly. Each time it's defeated, a new one comes up after the blow-up, and resurrection effect.  (I had to do this so the health bar rises in sync with the "resurrection".)

I don't know if doing it through child enemy scripts were the best way to do it, but it worked out nicely so far.


So, can anyone help me with my problem?

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #895 on: October 13, 2009, 05:27:52 AM »
Code: [Select]
@Finalize{
SetCommonData("EnemyX",GetX);
SetCommonData("EnemyY",GetY);
...

Next script:
Code: [Select]
@Initialize{
SetX(GetCommonData("EnemyX");
SetY(GetCommonData("EnemyY");
...

Use Common Data whenever you have to pass variables between scripts.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #896 on: October 13, 2009, 05:33:41 AM »
How can you (and me) decypher system.png?

Just save a system.png there would be OK?

Any sheet you place in danmakufu\img and which is named System.png will automatically replace the system sprites ingame. Once we know which image is located where on the sheet, we can make templates.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #897 on: October 13, 2009, 05:34:21 AM »
Haha wow it's so obvious... I've spent hours working my way around for it, and still couldn't get it, while you cook up a solution for it in less than a minute.
Is there anything you don't know?

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #898 on: October 13, 2009, 06:21:59 AM »
Quote
Is there anything you don't know?
How the fuck CtC works.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread
« Reply #899 on: October 13, 2009, 03:56:31 PM »
How the fuck CtC works.
Mmmmmm, I hacked my copy to let me play Phantasm stage. I also hacked it so that it extends my player's lives by 1 every time Reimu (PH) moves. (insert colon + capital V here)