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

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread v3
« Reply #810 on: May 21, 2010, 01:11:27 AM »
Sorry if this has been asked before (i looked through this thread first and nothing about it showed up)
Newbie/mathematical question:
how does one make a circle of bullets (that spawns around the player) that follow the circle's circumference (and stay there) without using tasks? i hope its possible, because i've been experimenting with CreateShotA, SetShotDataA and SetShotDataA_XY for the past 3 days and nothing >.>  I get the spawning circle part right....i just can't seem to get the bullets to go along the circle's circumference. I'm sure it works with atan2 or something like that, but i fail at math D: can someone explain please  :derp:?

Code: [Select]
let pi = 3.14159265;

@MainLoop
{
SetCollisionA(GetX, GetY, 31);
SetCollisionB(GetX, GetY, 31);

count++;
angle++;
circle++;

if(count==200)
{
loop(6)
{
CreateShotA(1, GetPlayerX + 100*cos(angle), GetPlayerY + 100*sin(angle), 15);
SetShotDataA(1, 0, 1, angle+90, 360/(200*pi), 0, 0, 213);
angle += 360/6;
FireShot(1);
}
angle = 0;
count = 0;
}
}
The bullet must make a 360 degree turn in the amount of time it takes to travel the length of the circumference, so I used 360/(200*pi) for the bullet's curve per frame. Remember that it must scale with the speed in order to work with faster bullets.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #811 on: May 21, 2010, 02:02:20 AM »
Thank you Onthenet^^ it worked perfectly.

Quote
Elementoid: Is there any particular reason you don't want to use tasks?

i was curious :p (and tasks still make me cry  :ohdear:)

Furienify

  • Yeehaw!
  • Equestrian Fansubber
    • Youtube Channel
Re: Danmakufu Q&A/Problem Thread v3
« Reply #812 on: May 21, 2010, 02:45:11 AM »
In a similar vein, I've been wondering how ZUN produces all the pretty patterns he does. His bullet control is astounding, I'm not sure where I could even begin replicating his patterns.

Kappa's Porocora comes to mind, for starters, and the similar version of it Kanako uses in MoF's extra. Another would be Wriggle's "Night Bug Storm" (I think?) where he manages to shoot out the bullets and make them align in a circle.

Man. How does he do it?

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread v3
« Reply #813 on: May 21, 2010, 02:50:27 AM »
Practice, patience, trial-and-error, and lots and lots of trig. Some of the patterns are simpler than they look as long as you can figure out the math behind it.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread v3
« Reply #814 on: May 21, 2010, 06:40:43 AM »
**Problem solved**

Careless use of case in Header BackGround

Hooray to psuedo-English

However, in a stage script the @DrawLoop doesn't seem to work  :ohdear:
« Last Edit: May 21, 2010, 07:47:23 AM by Henry »
Old/Forgotten member.

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

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #815 on: May 21, 2010, 08:20:44 AM »
@DrawLoop doesn't work in stage scripts. All background drawing must be done with @BackGround
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread v3
« Reply #816 on: May 21, 2010, 08:41:59 AM »
Oh...

Now with the @BackGround and @DrawLoop, the same background can scroll within the stage (only if no other @BackGround is used)
Old/Forgotten member.

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

SparklingOrange

  • Is a scrub.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #817 on: May 21, 2010, 04:15:28 PM »
You have to call LoadMusic(path) before calling PlayMusic(path).

Yep, I've done that when I called it as a variable, but it didn't work (I could've sworn the bgm thing worked before when I was using Helepolis' tutorials, but it was a different mp3 file). Do you still need to use LoadMusic() when calling it in as a directory? I kinda scripted it the way it is right now  'cause I was analyzing Stuffman's PoSR game script.

And I'm still not sure how to implement customizable game frames...it's not in the tutorials in the forum. Does it have to be drawn in the script like everything else?

EDIT: Tried what you suggested, but it's still not working.
Code: [Select]
@Initialize{
LoadMusic(get~".\bgm\st1.mp3");
Stage();
}
@MainLoop{yield;}
@Finalize{
}

task Stage{
PlayMusic(get~".\bgm\st1.mp3");
.....
Is there something I'm doing wrong? Arrgh....
« Last Edit: May 21, 2010, 04:25:11 PM by SparklingOrange »

Re: Danmakufu Q&A/Problem Thread v3
« Reply #818 on: May 21, 2010, 04:40:37 PM »
Do you still need to use LoadMusic() when calling it in as a directory?

Everything needs to be loaded before it can be played, with the exception of sound effects, which are so small that they are automatically loaded upon a PlaySE() call.

Is there something I'm doing wrong? Arrgh....

Remove the .\ from the path name. Both .\ and GetCurrentScriptDirectory do the same thing under different circumstances, so just remove on of them. If that doesn't work, check your pathnames and try to re-encode your .mp3, sometimes shit just doesn't play due to variable bitrates and whatever else.

And I'm still not sure how to implement customizable game frames...it's not in the tutorials in the forum. Does it have to be drawn in the script like everything else?

If you just want your own personal game frame that only you can see (or anybody else that uses your copy of th_dnh), you can place a 640x480 .png image called STG_Frame.png in the root img folder, pathname "~\img" (meaning that you create a folder called img in the same folder as th_dnh.exe, and place the image there). If you want other people to see your game frame during your script, you can either tell people to put this certain image in their img folder (which people probably will not do), or you can draw a layer 8 OBJ_EFFECT over top of the game frame. Keep in mind that redrawing such a large image every frame can get costly, and if you spawn it inside an enemy script it will delete itself once the enemy dies. You'll need to create the object in a stage script and just have it sit over top of the game window. You'll also need to redraw the score, life, bomb and graze counters, since they will be covered by your image. It's probably not worth your time unless you're making a very large script, like a full game.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #819 on: May 21, 2010, 09:27:30 PM »
Could someone explain @DrawTopObject and @DrawBottomObject ?
I've seen them in some scripts like the TH08 Phantasm (the one with Yukarin and Flan).

SparklingOrange

  • Is a scrub.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #820 on: May 22, 2010, 03:49:45 AM »
Everything needs to be loaded before it can be played, with the exception of sound effects, which are so small that they are automatically loaded upon a PlaySE() call.

Remove the .\ from the path name. Both .\ and GetCurrentScriptDirectory do the same thing under different circumstances, so just remove on of them. If that doesn't work, check your pathnames and try to re-encode your .mp3, sometimes shit just doesn't play due to variable bitrates and whatever else.

If you just want your own personal game frame that only you can see (or anybody else that uses your copy of th_dnh), you can place a 640x480 .png image called STG_Frame.png in the root img folder, pathname "~\img" (meaning that you create a folder called img in the same folder as th_dnh.exe, and place the image there). If you want other people to see your game frame during your script, you can either tell people to put this certain image in their img folder (which people probably will not do), or you can draw a layer 8 OBJ_EFFECT over top of the game frame. Keep in mind that redrawing such a large image every frame can get costly, and if you spawn it inside an enemy script it will delete itself once the enemy dies. You'll need to create the object in a stage script and just have it sit over top of the game window. You'll also need to redraw the score, life, bomb and graze counters, since they will be covered by your image. It's probably not worth your time unless you're making a very large script, like a full game.

I gave up and converted the mp3 files into wav, which is costly in size, but it works nonetheless...so it looks to be a file problem then...

As for the frame thing, the default root file method is exactly what I wanted to do. Thanks for the tip. Drawing it would be pretty cool too, but since you've mentioned the disadvantages, maybe it could be done in another time...

KrackoCloud

  • I don't mean to be greedy...
  • ... but white rice is my favorite food.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #821 on: May 22, 2010, 04:37:55 AM »
How would one use Shot11 or Shot12 in combination with sunburst patterns? For example, creating a firework-like sunburst in which the bullets start to fall.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #822 on: May 22, 2010, 04:41:50 AM »
You couldn't, you would have to use SetShotData_XY for that kind of pattern

KrackoCloud

  • I don't mean to be greedy...
  • ... but white rice is my favorite food.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #823 on: May 22, 2010, 04:54:47 AM »
Hm. Then, how do I set the arguments to give the bullets the initial angles of the burst?

Re: Danmakufu Q&A/Problem Thread v3
« Reply #824 on: May 22, 2010, 05:00:43 AM »
Set Them to go straight verticle with a little random horizontal with a little verticle decreasement but not enought to make the bullets stop or back track, yet , then after a while, have the increase the decreasement of the bullets as well as the randomness of the horizontal movements.

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread v3
« Reply #825 on: May 22, 2010, 05:41:28 AM »
How would one use Shot11 or Shot12 in combination with sunburst patterns? For example, creating a firework-like sunburst in which the bullets start to fall.

actually...
Code: [Select]
function fireworks(x, y){
    let angle=rand(0, 359);
    ascent(i in 0..12){
        CreateShot12(x, y, cos(angle+i*30)+rand(-0.0033, 0.0033), sin(angle+i*30)+rand(-0.003, 0.003), 0.0003*-cos(angle+i*30), rand(0.01, 0.02), 0.001*cos(angle+i*30), rand(1, 2), RED01, 10);
    }
}
You can edit it a bit to fit your speed, but that's basically it :V (I made it slow cause when it was fast, it went out of the screen :derp:)....... you can make it spawn really fast but slow down fast too or something...
« Last Edit: May 22, 2010, 05:47:06 AM by Kylesky »
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Re: Danmakufu Q&A/Problem Thread v3
« Reply #826 on: May 22, 2010, 11:22:56 PM »
I'm making a curving installation laser for a player script using a 32 vertex TRIANGLEFAN rectangular object effect. It's fucking up.

My image is 128x256. There are 16 vertices on one side, 16 on the other. Here's the code for the laser task, which is called every time you hit the shot key:

Code: [Select]
let obj = Obj_Create(OBJ_EFFECT);
ObjEffect_SetTexture(obj, serpLaserImg);
ObjEffect_SetRenderState(obj, ALPHA);
ObjEffect_SetLayer(obj, 2);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(obj, 32);
let scroll = 0;
while(GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD){
let x = GetPlayerX;
let y = GetPlayerY;
scroll--;

//The coordinates of each vertex on the image. 16 vertices on one side, 16 on the other.
ascent(i in 0..16){
ObjEffect_SetVertexUV(obj, 0 + i, 0, 0 + 8*i + scroll);
ObjEffect_SetVertexUV(obj, 31 - i, 128, 0 + 8*i + scroll);
}

//Set the vertices.
ascent(i in 0..16){

//Moves the center point of each pair of vertices up, curving slightly depending on if the player is moving left or right.
if(i>0){
x+=32*cos(270 + appliedAngle*(i+1));
y+=32*sin(270 + appliedAngle*(i+1));
}

//Set the position of the vertices. Each vertex is 32 pixels perpendicular to the center point of each vertex pair (x, y) on either side (+-90 degrees).
ObjEffect_SetVertexXY(obj, i, x + 32*cos(180 + appliedAngle*(i+1)), y + 32*sin(180 + appliedAngle*(i+1)));
ObjEffect_SetVertexXY(obj, 31 - i, x + 32*cos(0 + appliedAngle*(i+1)), y + 32*sin(0 + appliedAngle*(i+1)));
}
yield;
}
Obj_Delete(obj);
}

This produces the following images. Moving right:


Moving left:


scroll just scrolls through the laser image vertically, making it look animated. appliedAngle is a global angular modifier that is based on the player moving left and right. The longer the player holds left or right, it increases or decreases by 0.15 per frame, hitting max values of [-2.5, 2.5]. From a bullet perspective, appliedAngle would be the amount that the bullet's angle changes by per frame to look like it is curving (Obj_SetAngle(obj, Obj_GetAngle(obj) + appliedAngle);). So I'm applying this angle to each set of vertices for the laser, but it's fucking up. To me, it looks like vertex 15 and 31 are joining together for some reason. Either that, or the right side of the laser is perfectly fine and the left side is fucking up hard. I'd rather it not fuck up. Any ideas?
« Last Edit: May 22, 2010, 11:33:57 PM by Naut »

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #827 on: May 22, 2010, 11:53:39 PM »
... :/


I'm having trouble wrapping my mind around how the vertexes are supposed to map the effect together. Maybe I am just tired right now (~2 a.m. here), but there may actually be something wrong there. Instead of using PRIMITIVE_TRIANGLEFAN I'd have done it using PRIMITIVE_TRIANGLESTRIP and then, instead of dividing them into i and 31-i into 2*i and 1+2*i, if you know what I mean.

I have no idea if this will fix your problem, but I'd try it anyways.
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 v3
« Reply #828 on: May 23, 2010, 12:11:41 AM »
I've prepared an image to show my TRIANGLEFAN vertex layout:



(actually I just realized I incorrectly labeled the vertices in this image. 1 through 15 should be on the right side, and 16 through 31 should be on the left)

Like I said, it appears vertex 15 and 31 are connecting in some way, and I don't know why. I think it may have something to do with me setting them last. I tried splitting the vertex setting into two different ascent/descent trees, and that was all sorts of fucked up.

I tried your TRIANGLESTRIP method Iryan, and the image doesn't even appear. I see what you mean though, and am still experimenting. Even if I get this to work via strip, I'd like to know why my fan method is screwing up.
« Last Edit: May 23, 2010, 12:13:52 AM by Naut »

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #829 on: May 23, 2010, 12:23:10 AM »
Yeah, I got that. However, to my knowledgde, with that arrangement of vertices and TRIANGLEFAN... well...

Youd divide the image in the triangles with the following points:

[0,1,2] (all on one line, therefore invisible)
[0,2,3] (all on one line, therefore invisible)
[0,3,4] (all on one line, therefore invisible)
...
...
[0,15,16] (makes up half the image)

[0,16,17] (from here on it works as intended)

Therefore half the image will not work out as intended

Or am I wrong here..?  :/


Edit: Damn I should go to sleep now, what with all the typing errors I miss. I want to know if it works out somehow before, though.
« Last Edit: May 23, 2010, 12:30:50 AM by Tin Man vs. Rust Monster Musical Act Part 1: The End »
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 v3
« Reply #830 on: May 23, 2010, 12:31:07 AM »
Not following you at all.  :ohdear:

Using your TRIANGLESTRIP method, I get the following code:
Code: [Select]
let obj = Obj_Create(OBJ_EFFECT);
ObjEffect_SetTexture(obj, serpLaserImg);
ObjEffect_SetRenderState(obj, ALPHA);
ObjEffect_SetLayer(obj, 2);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 32);
let scroll = 0;
while(GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD){
let x = GetPlayerX;
let y = GetPlayerY;
scroll--;
ascent(i in 0..16){
ObjEffect_SetVertexUV(obj, i*2, 0, 0 + 8*i + scroll);
ObjEffect_SetVertexUV(obj, 1 + i*2, 128, 0 + 8*i + scroll);
}
ascent(i in 0..16){
if(i>0){
x+=32*cos(270 + appliedAngle*(i+1));
y+=32*sin(270 + appliedAngle*(i+1));
}
ObjEffect_SetVertexXY(obj, i*2, x + 32*cos(180 + appliedAngle*(i+1)), y + 32*sin(180 + appliedAngle*(i+1)));
ObjEffect_SetVertexXY(obj, 1 + i*2, x + 32*cos(0 + appliedAngle*(i+1)), y + 32*sin(0 + appliedAngle*(i+1)));
}
yield;
}
Obj_Delete(obj);

Which has the image not even appearing. How is this screwing up?

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #831 on: May 23, 2010, 12:45:48 AM »
That last post of mine was highlighting what was wrong with your original method. TRIANGLEFAN divides the image in triangle in a way so that the first (zeroth) vertex is part of every triangle, wich in your case makes half of your triangles void because their points all lie on one line. Thus the image looks very asymmetrical when distorted in the ways you are doing it.


I have no idea what's wrong with your TRIANGLESTRIPified code, though. Did you change anything else, maybe? Accidentally?

Edit: BLARGH typoes.
« Last Edit: May 23, 2010, 12:47:56 AM by Tin Man vs. Rust Monster Musical Act Part 1: The End »
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 v3
« Reply #832 on: May 23, 2010, 12:48:15 AM »
I have no idea what's wrong with your TRIANGLESTRIPified code, though. Did you change anything else, maybe?

Only what you told me. The code is right there, and my understanding of TRIANGLESTRIP isn't yielding any errors with it either.

That last post of mine was highlighting what was wrong with your method. TRIANGLEFAN divides the image in triangle so that the first (zeroth) vertex is part of every triangle, wich in your case makes half of your triangles void because their points all lie on tone line. Thus the image looks very asymmetrical when distorted in the ways you are doing it.

This makes a shitload more sense. Let me ponder with this.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #833 on: May 23, 2010, 01:00:54 AM »
Fuck, go to bed Iryan. I got it. Your strip method worked perfectly, thanks a lot.
I moved the image to upload it but didnt move it back

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #834 on: May 23, 2010, 01:04:18 AM »
Fuck, go to bed Iryan. I got it. Your strip method worked perfectly, thanks a lot.
I moved the image to upload it but didnt move it back
BV

Glad it works now. Hopefully it looks as awesome as I imagine it to do.

G'night.
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."

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #835 on: May 23, 2010, 01:54:52 AM »
Oh man are we gonna have a WOBBLY HOMING LASER shot type in Danmakufu?

Re: Danmakufu Q&A/Problem Thread v3
« Reply #836 on: May 23, 2010, 02:15:53 AM »
Not wobbly or homing (and it's for Ijiyatsu). Curvy though :V

Re: Danmakufu Q&A/Problem Thread v3
« Reply #837 on: May 24, 2010, 03:39:30 AM »
I got another newbie question  ::):

i've been trying to fire this loop, make it stop for a while, and then fire again. I thought this could be accomplished with a while{}, but i keep crashing danmakufu ._. can someone help me with this?

here is the code:

Code: [Select]
while(count1<=125){

CreateShotA(1, GetEnemyX + 30*cos(angle), GetEnemyY + 30*sin(angle), 15);
SetShotDataA(1, 0, 0.5, angle, 0, 0, 0, 173);
FireShot(1);

}

if(count1==165){

count = 10;
}

this is all inside the mainloop, by the way.

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread v3
« Reply #838 on: May 24, 2010, 04:08:08 AM »
You're not incrementing count1, so the condition "count1<=125" is always true, and this it never exits out of the loop. I think you're just looking for if instead of while, since MainLoop automatically runs once per frame - no need to use a while loop for this situation, since it basically has one built-in.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #839 on: May 24, 2010, 04:15:45 AM »
Ah, thanks ^^. I changed the while statement to an if statement and it kinda works now. Just a few tweaks and it'll be done, thank you :)
(apparently i forgot that if statements can have other things than ==  ._.)
oh, and i forgot to put the variables++ in the quote. Sorry  :V