Author Topic: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry  (Read 243898 times)

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #840 on: November 21, 2015, 07:43:21 AM »
Synchronized BGM discussion on last page
Okay I just implemented this myself out of interest. Works pretty decently. Would appreciate testers.

https://gist.github.com/drakeirving/d7ce1bf229395509025c



Hi! How can I make a bullet with a "curved" fall? Something like a parabola. Like in a free fall.
The CreateShotB series uses x-speed and y-speed parameters rather than speed and angle. In particular, CreateShotB2's usage is:
Code: [Select]
CreateShotB2(x, y, x_speed, y_speed, x_accel, y_accel, x_max_speed, y_max_speed, graphic, delay)By having any initial x/y-speeds and a positive y-acceleration you will get a gravity-like effect.

ObjMove_AddPatternB2 also works the same way if you want to modify an existing bullet rather than fire a new one:
Code: [Select]
ObjMove_AddPatternB2(obj, frame, x_speed, y_speed, x_accel, y_accel, x_max_speed, y_max_speed)

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

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #841 on: November 21, 2015, 07:14:24 PM »
First off, thank you all for replying

Your code seems like it could work with some modifications, if GetCurrentFps worked the way you wanted it to. The way you've written it, it'll only pause for one frame (theoretically) after accumulating 60 frames-worth of lag. If you wanted to wait for one frame when one frame is lost, you'd have to check (lagMemory >= 1) and subtract 1. You'd probably also want to center the timing around +/- 0 frames, so (lagMemory >= 0.5) and subtracting 1 would be better.

not quite, if I understand you correctly
Code: [Select]
task lagMusic{
lagMemory += 60-GetCurrentFps();
if(lagMemory>=1){
ObjSound_Stop(bgm);
wait(1);
ObjSound_Play(bgm);
lagMemory -= 1;
}
}
would see 59 fps for 1 frame then skip the next frame, meaning that a script running at 59fps would have music running at half speed. In my original (which is still a naive approach) would run at 59fps for 60 frames before skipping one so 61 frames of music for 60 frames of gameplay. The difference in the actual fps and the expected fps per frame is only worth 1/60 of a frame which is why I waited to get 60 of them before skipping one. Either way, this method wasn't really fleshed out, just my first blush idea.(It is less accurate the farther from 60fps your script goes now that I think more of it)

I'll try out PlaySyncBGM(path, loop_start, loop_end, skip_param) later on today, I have a few ideas and I'm sure I can induce lag if I try.
my Twitch Stream I play shmups sometimes

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #842 on: November 21, 2015, 08:19:35 PM »
Hi! How can I make a bullet with a "curved" fall? Something like a parabola. Like in a free fall.

Something like this: http://puu.sh/lta27/98a497a6a6.png

More general: http://puu.sh/lta0c/c89e578c7c.png

Thanks!

CreateShotB1 / B2.
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #843 on: November 21, 2015, 09:34:12 PM »
Thanks to both, that's exactly what I was looking for  :D

Btw, there is a guide or some script that I can use to learn how to put dialogues?
« Last Edit: November 21, 2015, 09:55:04 PM by Paty »
Paty

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #844 on: November 21, 2015, 10:39:52 PM »
Thanks to both, that's exactly what I was looking for  :D

Btw, there is a guide or some script that I can use to learn how to put dialogues?

Literally any script that has dialogue.


Less spam, more proper help posts please. -Helepolis
« Last Edit: November 21, 2015, 11:13:03 PM by Helepolis »
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #845 on: November 21, 2015, 10:42:28 PM »
There isn't a guide for dialogue scenes but it is very simple to make. Stealing code from others isn't always a good choice either, especially if you don't get permission to use their code.

The general idea is that you need: one sprite object for the player's cutin, another for the boss, a background sprite object for the text background, and finally a text object. so you can just setup a system that works like this.

Code: [Select]
CreatePlayerSpriteObject() just change the texture or source rects to show difference faces
CreateBossSpriteObject() same as the player
CreateDialogueBox() best to just have one of these unless you want the GFW - Present style floating dialogue boxes
CreateTextObject() for whoever is talking, again only one is needed, just change the text for whoever is talking

blahblahblah talking...

CleanUp everything else afterwards, deleting the previously created objects, removing textures, etc...
I can't really come up with an example code right now but that's sort of a quick step by step guide to how it could work for something extremely simple. The functions I mentioned don't actually exist but you'll be using ObjSprite_Create(OBJ_SPRITE_2D); for the player, boss, and text background, and finally ObjText_Create() for the actual dialogue text. I suggest looking at the official danmakufu documentation for ph3 (Google Translate does well enough here), the danmakufu wiki we have is also applicable but I always recommend using the official documentation because it contains more information about the engine and is more accurate atm.

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #846 on: November 22, 2015, 09:37:58 AM »
<code> would see 59 fps for 1 frame then skip the next frame, meaning that a script running at 59fps would have music running at half speed. In my original (which is still a naive approach) would run at 59fps for 60 frames before skipping one so 61 frames of music for 60 frames of gameplay. The difference in the actual fps and the expected fps per frame is only worth 1/60 of a frame which is why I waited to get 60 of them before skipping one.
Beep boop, I was mistaken, yes. I didn't scale it in my head properly and figured "FPS is a measure of frames so a difference of 1 means 1 frame".

Anyways, I'd like to see how my method performs when faced with horrible lag like you're reporting. I can't really emulate that very well on my machine.

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

BobTheTanuki

  • Ph3?
  • What is it?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #847 on: November 27, 2015, 12:07:43 PM »
Ah,Hello there everyone :derp:
I know it's kinda silly question
BUUUTT :V
I was wondering how to spawn bullets on the laser?Like on the end of the laser and stuff? ???

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #848 on: November 27, 2015, 04:00:05 PM »
Ah,Hello there everyone :derp:
I know it's kinda silly question
BUUUTT :V
I was wondering how to spawn bullets on the laser?Like on the end of the laser and stuff? ???

You know the starting point, angle, and length of the lasers. Knowing that, you can use trigonometry to place bullets along the length of the laser.

BobTheTanuki

  • Ph3?
  • What is it?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #849 on: November 27, 2015, 05:32:23 PM »
You know the starting point, angle, and length of the lasers. Knowing that, you can use trigonometry to place bullets along the length of the laser.

That's the problem
I don't understand trigonometry

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #850 on: November 27, 2015, 05:44:07 PM »
That's the problem
I don't understand trigonometry

What are you doing here? Get your butt out of your chair and go to school for once.

Anyway, I'd suggest learning basic trigonometry. There are many resources on the Internet that they're not worth linking from here.
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

BobTheTanuki

  • Ph3?
  • What is it?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #851 on: November 27, 2015, 05:51:32 PM »
What are you doing here? Get your butt out of your chair and go to school for once.

Anyway, I'd suggest learning basic trigonometry. There are many resources on the Internet that they're not worth linking from here.

No thanks!Don't wanna go to school again :u
Nah,I'm too stupid to understand this stuff

ALSO

I think I got it,thank you two for response!

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #852 on: November 28, 2015, 01:22:54 PM »
There isn't a guide for dialogue scenes but it is very simple to make. Stealing code from others isn't always a good choice either, especially if you don't get permission to use their code.

The general idea is that you need: one sprite object for the player's cutin, another for the boss, a background sprite object for the text background, and finally a text object. so you can just setup a system that works like this.

Thanks, that was more or less what I imagined. The real problem was how to pass through the text but I could do it.

Now, I'm having problems with the background. I try to make a BG that moves. The code is very simple (I don't put a loop yet), just for test purpose:

Code: [Select]
#include"./FuncList.dnh"

@Initialize{
RenderBG;
}

task RenderBG {
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
let imgpath = currdir~"./img/cielo2.png";

let alpha = 150;
let scale = 0.8;

ObjPrim_SetTexture(obj, imgpath);
ObjSprite2D_SetSourceRect(obj, 0, 0, 512, 1024);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj, CenterX, CenterY, 0);
ObjRender_SetAlpha(obj, alpha);
Obj_SetRenderPriority(obj, 0.21);
ObjRender_SetScaleXYZ(obj, scale, scale, 1);

moverBG(obj);
}

task moverBG(obj){
let x = 0;
let y = 0;

while(!Obj_IsDeleted(obj)){
ObjRender_SetPosition(obj, x, y, 0);
x++;
y++;

yield;
}
}

But if I call this file with #Background in the plural script, the image doesn't move at all. However, if I put the task "RenderBG" in the @Initialize of the plural script, it works (obviously deleting the @Initialize in the BG script).

Why does this happen? Thanks.
Paty

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #853 on: November 28, 2015, 03:52:53 PM »
But if I call this file with #Background in the plural script, the image doesn't move at all. However, if I put the task "RenderBG" in the @Initialize of the plural script, it works (obviously deleting the @Initialize in the BG script).

Why does this happen? Thanks.

In order for a task to run in a script, you must always have a yield; in your @MainLoop. You don't have a @MainLoop with a yield in this script.


Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #854 on: November 28, 2015, 07:19:08 PM »
Thank you Sparen, it worked  :D

Btw, there is no default item script?
Paty

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #855 on: November 28, 2015, 07:26:45 PM »
Thank you Sparen, it worked  :D

Btw, there is no default item script?

What do you mean by a 'default item script'? There are default items in Danmakufu, if that's what you are referring to.

http://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Item_Functions

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #856 on: November 29, 2015, 12:08:52 AM »
Yes, I know that. What I mean is... if exist something like this by default: http://puu.sh/lCeO3/be248c3d7c.png so I can edit it and make my own (that is an example used in an user script I downloaded).
Just like the Rumia boss and player script that comes with danmakufu by default, but with items.
The idea is to take the default script and use it as a "basis" to make a custon one, but I couldn't find any script that refers to items.

Sorry if I can't explain myself very well, it's difficult when English is not your first language.
Paty

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #857 on: November 29, 2015, 01:41:33 AM »
There is no 'default' item script that comes with Danmakufu, afaik. Mine is based off of Ultima's. It's one of those things that scripters tend to make on their own once they begin working on large-scale projects such as full games.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #858 on: November 29, 2015, 02:25:20 AM »
Oh, I see. Thanks!
Paty

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #859 on: November 29, 2015, 03:37:39 AM »
There is a Item Script system that contains events for how custom items are handled when they are collected, or when bullets are converted to items, etc...

That is what I use, however if you do not define one for danmakufu to use, custom items will not be properly handled. The official ph3 documentation has an example of what the item script should be like (you will have to also add a @MainLoop{yield;} since iirc, the example didn't do that and it is the only way for tasks to yield properly. Once you have an item script you can use StartItemScript() with a path to the script itself.

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #860 on: November 29, 2015, 09:14:35 AM »
The example given in the official documentation doesn't have an explicit MainLoop (and so no yield statement in one) because it doesn't need one as it's written. Once you start defining fancy custom behaviour and effects it would be necessary of course, but for simple stuff you don't even need it.

Here's a really basic outline extending the doc's a bit:
http://pastebin.com/NLjHdwjS

EDIT: Sage I never meant to imply otherwise, just mentioning that detail :)
« Last Edit: November 29, 2015, 09:54:05 PM by Drake »

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

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #861 on: November 29, 2015, 03:03:01 PM »
Sure the script doesn't require it to be there, but for the sake of avoiding the "why doesn't my task yield?" question, I mentioned to add it in now.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #862 on: November 29, 2015, 07:21:38 PM »
Good day, everyone.
Who had wrote often STGs?
Which fps-problem can I face during writing STGs? What should I beware? My big problem is that Boss Fight in Stage runs in low fps (Even if I upload it from the beginning of the Stage). But when I play just Plural, all work successfully. Somebody knows that trick?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #863 on: November 29, 2015, 07:36:40 PM »
Good day, everyone.
Who had wrote often STGs?
Which fps-problem can I face during writing STGs? What should I beware? My big problem is that Boss Fight in Stage runs in low fps (Even if I upload it from the beginning of the Stage). But when I play just Plural, all work successfully. Somebody knows that trick?

It's not a 'trick' when it comes to FPS over a long period of time. It is known as optimization, and constitutes more than just mere 'tricks'.

Ways to improve your FPS:
-Short circuit your boolean expressions:
Code: [Select]
if (x && y) {} //if x is false, then y won't even be evaluated -Kill all tasks when they are completed
-Delete all objects when they are no longer needed
-Remove unused variables and redundant statements
-Use variables for things that are used multiple times (e.g. GetCurrentScriptDirectory, or for trigonometry)
-Avoid indexing large arrays
-etc.

If you are using the log window, then it should be clear where some of your resource management is going haywire.

Optimization is a process that cannot be taught - only experienced. You will have to see for yourself how to improve your code and resource management.

P.S. Excessive curvy lasers and ADD/INVERT bullets significantly lag Danmakufu when used in excess.

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #864 on: November 29, 2015, 08:18:25 PM »
Ways to improve your FPS:
-Short circuit your boolean expressions:
Code: [Select]
if (x && y) {} //if x is false, then y won't even be evaluated -Remove unused variables and redundant statements
-etc.

These two yield zero increase in performance, variables are just value lookups on the script's virtual stack. Mkm handles these things quite well.

Optimization can be taught, but you really want to focus on optimization after you reach a certain level in your project, for example: after finishing a boss battle, stage, or even cleaning up and preparing for a demo. If there's one thing about programming games you should know, you build your game the smart way, and worry about "what can I do make improve performance" later. The last thing you need to do is develop unnecessary lag safety habits early on, danmakufu is not a very performance optimized engine so there is a limit to what you can do to improve and avoid lag.

I suggest being mindful of sprite objects you have going around, deleting unused things is best, textures can stay in memory no problem but sprites, bullets, enemies etc... need to go. Be mindful of the calculations you make, you don't need to have an ellipse formula for a ring of bullets, or some other unnecessary trig ran each frame.

But after all of these things are said and done, at the end of the day, it is all left up to how good your computer is. Don't let worrying about optimization discourage you and take away the fun of making games. I had to learn that the hard way, and most serious programmers will tell you the same. (after I spent nights worrying about improving my personal danmaku engine I made in both C++ and C#, I ended up seeing that those efforts were unnecessary)

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #865 on: November 29, 2015, 08:55:27 PM »
Thank you @Sparen.
Thank you @Sage.
I will consider it.
Maybe.. later I need some people to test my Danmaku-game, before it will be published.
Who wants to play (test) Extra stage? Touhou Treasure Castle Labyrinth   :V
> zhan.fox.12@gmail.com

Edit
One more question..
For what is this " .def " file?
Which programm language used there? What can I add there more?
Where I can learn more about this file (language)?


Please use the edit button if your post is the last one -Helepolis
« Last Edit: November 30, 2015, 05:33:00 PM by Helepolis »

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #866 on: November 30, 2015, 05:12:43 PM »
One more question..
For what is this " .def " file?
Which programm language used there? What can I add there more?
Where I can learn more about this file (language)?

It is a configuration file.

Code: [Select]
// Path to the package script
package.script.main = script/ExRumia/ExRumia_Package_Main.txt

// Window title
window.title = test

// Screen dimensions
screen.width=1024
screen.height=576


A second sincere request to make your posts more elaborate if you're willing to help. -Helepolis
« Last Edit: November 30, 2015, 05:37:08 PM by Helepolis »
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #867 on: November 30, 2015, 05:49:08 PM »
It is a configuration file.

Code: [Select]
// Path to the package script
package.script.main = script/ExRumia/ExRumia_Package_Main.txt

// Window title
window.title = test

// Screen dimensions
screen.width=1024
screen.height=576

Yes, that I know already. But if there something more than that? Where can I see more information about this configuration file?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #868 on: November 30, 2015, 06:55:43 PM »
Yes, that I know already. But if there something more than that? Where can I see more information about this configuration file?

The code posted is basically all you need to know.

You place the th_dnh.def file in the same directory as your executable.

Comments are preceded by //

Keep each statement on a separate line.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #869 on: December 01, 2015, 07:19:35 PM »
Sorry please..
How do I point CreateStraightLaserA1 angle, to object, that moves with ObjMove_SetAngularVelocity.
When I make this, lasers angle points to object askew.