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

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #450 on: March 23, 2015, 06:03:28 PM »
Hello, i'm really new on danmakufu (I know some programming language [C#, Java, VB, PHP, JS] but this is new to me, so, i'm a newbie) and i know how to do basic stuff but of course, everything looks great if you do great so, to the point:

I want to know how to put a BG on movement in a Spellcard and also how to do a hp bar similar to TH13 hp bar. I know the basic i do some... simple spellcards (Sparen tutorials, Helepolis tutorials too) but i want to this thing look more... "touhouness"? That's the think, thanks everyone and hope somebody can help me out :D

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #451 on: March 23, 2015, 08:55:35 PM »
Programming language experience won't do much since danmakufu isn't the same kind of OOP as the languages you mentioned. For backgrounds you need to use ObjPrim_Create(OBJ_SPRITE_2D) for 2D objects, followed by the appropiate ObjSprite2D_XXX functions and ObjRender_XXX functions. For 3D objects use OBJ_SPRITE_3D and the ObjSprite3D_XXX functions.

To create the lifebar like GFW - DDC, you'll need a decent understanding of how primitive objects work, as well as some basic knowledge of trig. Use ObjPrim_Create(OBJ_PRIMITIVE_2D);, set the primitive type to PRIMITIVE_TRIANGLESTRIP.

http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html

Here is the official documentation for ph3, which is currently more reliable than the english danmakufu wiki (wiki still needs to be cleaned up of incorrect information). Make use of this, it will help you alot, even if you just pop the function descriptions into google translate. For 10D's lifebar, look towards the bottom for the ObjPrim_XXX functions.

Alternatively, I can give you the code I used to make it for my game if you want.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #452 on: March 23, 2015, 09:14:15 PM »
This is a question that may have no answer.

When using a render object or any non-vector graphic in Danmakufu phd (it did not exist in 0.12m), there is anti-aliasing, which blurs the edges of images. However, when pixel perfect precision is wanted, there is, as far as I know, no way to turn this off and keep the original pixels of the source image. Is there a way to turn off anti-aliasing in Danmakufu? If there is a solution involving shaders, I will consider it.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #453 on: March 23, 2015, 09:23:27 PM »
You can use a x2 picture and keep pixel without blur if it don't move. But on moving picture it remain some very light blur pixels on the edges. It can work if you want a pixel perfect background or HUD and keep a blur tolerance on characters and bullets.

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #454 on: March 23, 2015, 09:31:21 PM »
Hello, i'm really new on danmakufu (I know some programming language [C#, Java, VB, PHP, JS] but this is new to me, so, i'm a newbie) and i know how to do basic stuff but of course, everything looks great if you do great so, to the point:

I want to know how to put a BG on movement in a Spellcard and also how to do a hp bar similar to TH13 hp bar. I know the basic i do some... simple spellcards (Sparen tutorials, Helepolis tutorials too) but i want to this thing look more... "touhouness"? That's the think, thanks everyone and hope somebody can help me out :D

You can look at my code.
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 #455 on: March 23, 2015, 11:07:47 PM »
Thanks to everyone, the last topic it's really helpfull, but thanks to everyone, i still a little confuse about the Background Imag of the spellcard, so, i make a 3D render of the image and use in the system?

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #456 on: March 23, 2015, 11:24:13 PM »
Thanks to everyone, the last topic it's really helpfull, but thanks to everyone, i still a little confuse about the Background Imag of the spellcard, so, i make a 3D render of the image and use in the system?
You can draw 3D backgrounds anywhere you like. Most people follow the samples and just call a separate script with a bunch of 3D background code stored in it with the #Background[path] header

This is a question that may have no answer.

When using a render object or any non-vector graphic in Danmakufu phd (it did not exist in 0.12m), there is anti-aliasing, which blurs the edges of images. However, when pixel perfect precision is wanted, there is, as far as I know, no way to turn this off and keep the original pixels of the source image. Is there a way to turn off anti-aliasing in Danmakufu? If there is a solution involving shaders, I will consider it.

Its not anti-aliasing, or even close to what AA even does. The problem is that your texture's width and height are not a power of 2. This is a feature that DirectX9 has that will resize images that are not a power of 2 (n^2), which causes the image to be blurred and distorted.
« Last Edit: March 23, 2015, 11:26:02 PM by Sage Ω (Ultima) »

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #457 on: March 24, 2015, 01:46:30 AM »
Its not anti-aliasing, or even close to what AA even does. The problem is that your texture's width and height are not a power of 2. This is a feature that DirectX9 has that will resize images that are not a power of 2 (n^2), which causes the image to be blurred and distorted.

...Except that the texture is 512x512.

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #458 on: March 24, 2015, 01:49:18 AM »
Oh boy, blurry aids question

You can use a x2 picture and keep pixel without blur if it don't move. But on moving picture it remain some very light blur pixels on the edges. It can work if you want a pixel perfect background or HUD and keep a blur tolerance on characters and bullets.
Its not anti-aliasing, or even close to what AA even does. The problem is that your texture's width and height are not a power of 2. This is a feature that DirectX9 has that will resize images that are not a power of 2 (n^2), which causes the image to be blurred and distorted.
This actually isn't entirely true. Yes, you do have to use images of dimensions 2n due to the aforementioned reason. Additionally though, the reason why moving pictures are blurred is largely due to rendering at non-integer positions. Even if you're drawing a sprite at a fixed location, but non-integer, it will also get blurry aids from interpolation gimmicks (not AA).

a) Drawn at (0, 0)
b) Drawn at (0.5, 0)
c) Moving with speed 2 and angle 45

   

One problem is that if you're using any sort of vector-based movement (SetSpeed() and SetAngle(), SetDestAtFrame(), etc) the position change is applied at the end of the frame by the engine (so you can no longer change it), but right before it's rendered, so you can't simply force the position and have it work like that.

However, when pixel perfect precision is wanted, there is, as far as I know, no way to turn this off and keep the original pixels of the source image. Is there a way to turn off anti-aliasing in Danmakufu? If there is a solution involving shaders, I will consider it.
There's a solution for Primitive objects. Unfortunately I haven't found a way to perfectly render things like Shot objects without introducing fairly significant overhead.
Basically though, you calculate the object's position in advance, get the decimal portion of the next position, and subtract it not from the object's position, but its rendering destination.

For example, if an object were moving at speed 2 and angle 40 from (100, 100), its next position will be (100 + 2*cos(40), 100 + 2*sin(40)) = (101.532089, 101.285575), so you want to offset the rendering location by (-0.532089, -0.285575) in order to get a clean (101, 101). The downside to this is that since you're actively trying to remove any interpolation, some movement (especially slow movement) might look not as smooth since it is moving a pixel at a time.

Code: [Select]
function ObjSprite2D_Clean(obj, l, t, r, b){
let hw = (r - l) / 2;
let hh = (b - t) / 2;
let a = ObjMove_GetAngle(obj);
let s = ObjMove_GetSpeed(obj);
let off_x = (ObjRender_GetX(obj)+cos(a)*s)%1;
let off_y = (ObjRender_GetY(obj)+sin(a)*s)%1;
ObjSprite2D_SetDestRect(obj, -hw - off_x, -hh - off_y, hw - off_x, hh - off_y);
}

For Primitive objects in general you'd have to change the position of each vertex accordingly. You should also be able to see why it won't work with Shot objects: they have no way to set their rendering location.
« Last Edit: March 24, 2015, 02:20:05 AM by Drake »

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #459 on: March 24, 2015, 03:40:29 AM »
Each tile object is permanently locked into a specific 24*x, 24*x integer position, fyi. I will live with it and have the tile sets cover up the fact that the issue even exists.

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #460 on: March 24, 2015, 04:17:08 AM »
If they're in static positions there is no reason that you couldn't get it to render properly. I'm not sure what you mean.

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 #461 on: March 24, 2015, 06:24:10 AM »
If the positions are even and nothing is moving, then that goes back to what I said before about the texture sizes not being a power of 2. If the actual texture is 24x24 and not just the source/destination rectangle, then you need to change the canvas of your image to 32x32 using gimp, or Photoshop or whatever.

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #462 on: March 24, 2015, 09:12:55 AM »
...Except that the texture is 512x512.

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #463 on: March 24, 2015, 12:49:13 PM »
The image is 512x512, and each individual tile is 24x24, placed at an integer coordinate. There may be an issue when the 2D camera moves, but that's on me.

Examples of code:

       ObjSprite2D_SetSourceRect(map[j], 26, 276, 50, 300);

       ObjSprite2D_SetDestRect(map[j], 0, 0, 24, 24);

Code: [Select]
//Initializes a Tile Object
//Param: Grid X (int), Grid Y (int)
//Return: Object ID (int)
function ObjTile_Create(x, y){
    let obj = ObjPrim_Create(OBJ_SPRITE_2D);
    ObjTile_SetPosition(obj, x, y);
    ObjRender_SetPosition(obj, x*24, y*24, 1);
    return obj;
}

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #464 on: March 25, 2015, 01:14:02 AM »
Dunno what you're doing, but this works just fine.

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

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #465 on: March 25, 2015, 03:22:10 AM »
Dunno what you're doing, but this works just fine.

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

I give up. The issue isn't that serious anyways. Worst case scenario, nothing happens. Since functionality is not impaired, it won't be too much of a problem.

FlareDragon

  • Gensokyo's Infernal Hellstorm
  • When will you come to Gensokyo, Satsuki Rin?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #466 on: March 25, 2015, 08:13:54 AM »
I dunno if it'll be of help, but perhaps the issue could be related to the Stage width/height? Or perhaps the window of Danmakufu isn't at its standard 640x480. If not those little thing, then I guess I'm of no help. Just figured I'd put my 2-cents worth in
Normal 1CC's: SoEW, LLS, MS, EoSD, PCB, IN, PoFV, MoF, SA, UFO, GFW, TD, HM, DDC, ULiL, LoLK(PD), CtC |IaMP|
Hard 1CC's: EoSD, PCB, MoF, IN(B), TD, LoLK(PD), |???|
Lunatic 1CC's: None
Extra 1CC's: SoEW, MS, EoSD, PCB, IN, PoFV, MoF(NB), SA, UFO, GFW, TD, DDC, CtC, LoLK, |???|

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #467 on: March 25, 2015, 12:33:32 PM »
I dunno if it'll be of help, but perhaps the issue could be related to the Stage width/height? Or perhaps the window of Danmakufu isn't at its standard 640x480. If not those little thing, then I guess I'm of no help. Just figured I'd put my 2-cents worth in

The issue is completely independent of the 640x480 window, which can be changed in the .def file

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #468 on: March 25, 2015, 08:43:14 PM »
Want to update on the people who helped me with the replay question, thank you once more. Based on the example scripts + explanation, I managed to do this:

As there is no difficulty info, I am abusing REPLAY_COMMENT for this. I'll use commondata to retrieve the difficulty level then store it inside REPLAY_COMMENT.

I also noticed that in the example script the replay info is concatenated in an array then the array is directly shown as the text object. I guess this is just a style. I personally adapted different style with setting vars then concatenating the vars in the text object. Similar thing but the array confused me personally.

Of course there is no playback, yet, though I understand the way replays are stored and displayed.

Edit 27-03-2015
Managed to successfully playback a replay and set in the menu-flow mechanics. I.e: Returning back to replay overview if it is a replay and such. All that is left now is to create the "Replay from stage #X" when multiple stages available + Replay Save mechanics with name entering and such. If this is all set I have finished another core requirement of my game. Excitement++
« Last Edit: March 27, 2015, 01:58:39 PM by Helepolis »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #469 on: March 27, 2015, 06:12:35 PM »
Still stuck with the final part of my replay saving system which is when you actually decide to Save and exit without the stage ending / player dying. It throws me the following error:

"save target replay not found"

When you hit the ESC button a Pause screen is summoned. The result of the pause screen is passed on in Alternative(result) 
Code: [Select]
case(RESULT_SAVE_REPLAY) {
ObjText_SetText(stglist2,"SAVE REPLAY was chosen");
loop(120) { yield; }
TerminateStageScene;
gameReplaySaveScene;
break;
}
I even delayed the thing to see if the correct case was called. It was, so we can assume my menu choice is correctly passed through. gameReplaySaveScene is basically task that summons the replay list and allows the player to select a replay slot. This same menu is exactly called when you Game Over. So to sum up:
- If I Game Over >> the replay saving goes perfectly fine.
- If I use the mid-play replay and exit, it will throw me the above error.

I am suspecting this has something to do with the fact that the GetStageSceneState isn't receiving a PLAYER DOWN / STAGE CLEAR status. But even if we suspected this, I tried summoning my replay save menu through  STAGE_RESULT_BREAK_OFF but that didn't help out either.

If I try to call FinalizeStageScene it will throw me the error "not finished stage"

 :o

Edit:
Ok so it seems this has to do with the fact CloseStgScene is not called and therefore the GetStageSceneState isn't officially over. Except calling CloseStgScene is throwing me the error the function is not defined. Confusion even more now.
« Last Edit: March 27, 2015, 09:59:39 PM by Helepolis »

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #470 on: March 31, 2015, 07:49:00 AM »
Sorry please, if this question was already here, aaand maybe it is stupiest question,,,but how to make enemy (boss) float? (by Y goes up and down a little). I tried various way, but enemy started to behave weird?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #471 on: March 31, 2015, 08:36:56 AM »
Sorry please, if this question was already here, aaand maybe it is stupiest question,,,but how to make enemy (boss) float? (by Y goes up and down a little). I tried various way, but enemy started to behave weird?
Use ObjSprite2D_SetDestRect(); and modify the ' top ' and ' bottom ' rect parameters so the Y-position of the sprite shifts. This way you won't be moving your actual Obj position and thus avoid weird behaviour.

Example for 64x64 sprite of a boss:
ObjSprite2D_SetDestRect(obj,0,0+hover,64,64+hover);

Then mutate the hover var as you please with sin() or something to make it smooth up/down.
« Last Edit: March 31, 2015, 08:43:12 AM by Helepolis »

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #472 on: March 31, 2015, 08:48:20 AM »
Use ObjSprite2D_SetDestRect(); and modify the ' top ' and ' bottom ' rect parameters so the Y-position of the sprite shifts. This way you won't be moving your actual Obj position and thus avoid weird behaviour.

Example for 64x64 sprite of a boss:
ObjSprite2D_SetDestRect(obj,0,0+hover,64,64+hover);

Then mutate the hover var as you please with sin() or something to make it smooth up/down.

Big big thanks! I would have not guessed  :X

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #473 on: April 01, 2015, 07:25:24 AM »
Question regarding resource management and pre-loading of sounds and bgm.

Some background info
Before I've had a task which was  task playSFX("pathname/sound.wav");. The task simply loaded a sound taking in the pathname parameter, played it and done. Except when you do this throughout your entire game the number of objects will be 20.000+ which is eventually degrading your performance.

Based on Drake's previous page post I have replaced all instances with ObjSound_Play(soundname);  example: ObjSound_Play(SFX_TAN00); in my spell cards or non spells or anywhere sounds are used SFX_TAN00 is declared and loaded inside an #included sounds.txt. So let us say spellcard01 has #included sounds.txt.

Code: [Select]
Library: sounds.txt

let SFX_TAN00 = loadSFX("pathname/tan00.wav");
let SFX_LAZER00 = loadSFX("pathname/lazer00.wav");
let SFX_KIRA00 = loadSFX("pathname/kira00.wav");

function loadSFX(path) {
let obj = .....;
ObjSound_Load(path);
Sound stuff;
return obj;
}

However, if you do this for a plural script, your sounds.txt will be called like N times and thus result in unnecessary loading. So obviously I could #include my sound library from a more central place, like my main stage script.

Here comes the problem
Plural scripts and System scripts are loaded through the StartScript() and they too contain various sound effects. I am getting SFX_TAN00 not defined errors, which is logical because scripts don't share info among each other. So what to do?

If I #include my sounds inside system script or my plural scripts it will defeat the purpose of optimization. Plural scripts being booted from the stage are also unable to access my sounds library.



« Last Edit: April 01, 2015, 07:34:56 AM by Helepolis »

FlareDragon

  • Gensokyo's Infernal Hellstorm
  • When will you come to Gensokyo, Satsuki Rin?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #474 on: April 01, 2015, 07:35:17 AM »
With the first scenario, couldn't you set it up so that it checks if particular sound objects exist (are loaded), and if they aren't, THEN they're loaded? Means that, although it'll look at the script multiple times, it would only load the sounds the once since it'll check if they're loaded.

The second scenario, I wouldn't have an idea (though this isn't helped by being a Danmakufu Novice)
Normal 1CC's: SoEW, LLS, MS, EoSD, PCB, IN, PoFV, MoF, SA, UFO, GFW, TD, HM, DDC, ULiL, LoLK(PD), CtC |IaMP|
Hard 1CC's: EoSD, PCB, MoF, IN(B), TD, LoLK(PD), |???|
Lunatic 1CC's: None
Extra 1CC's: SoEW, MS, EoSD, PCB, IN, PoFV, MoF(NB), SA, UFO, GFW, TD, DDC, CtC, LoLK, |???|

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #475 on: April 01, 2015, 09:51:05 AM »
You're basically correct, actually (although the implementation isn't quite that). After some thinking I have a fairly good solution:

https://gist.github.com/drakeirving/64833e1ef543fc713a2b

To use this, you include it once in your "main" script (stage, etc, EDIT: not packages), call InitSounds(), and then also include it in any other script you'd want sounds in. By doing so you'll be able to just use ObjSound_Play() with any of the pseudo-constants you write in.

This way you:
  • Don't have multiple copies of the sound in program memory
  • Aren't generating a billion references when playing the sound a lot
  • Aren't generating multiple objects for different scripts
  • Aren't even making a hassle programming to reference the same sound across scripts
  • Have pretty much the bare minimum of processing

I haven't seen a big script so far that doesn't have at least one of these problems, I think.
« Last Edit: April 02, 2015, 06:11:23 AM by Drake »

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

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #476 on: April 01, 2015, 10:48:09 AM »
Ok so attempted what Drake said and we seem to have success here.  I have tested it with just one sound for now (to avoid doing it 120x wrong)

When I monitor the logwindow I can see the reference to the sound file is maximum of 2 for some unknown reason. But this still means I need to include my sounds.txt everywhere where a script is launched using StartScript(); because otherwise the variables cannot be called.

I kept few old style code to compare. I can see for example 1 sound file being referred 15x and Drake's method 2x. Regardless how many times I call the #include sounds.txt, it will keep reference at two. I have tested bit more elaborate because I summoned the sounds.txt in the following locations for my own game:
- System.txt
- Globals.txt (contains some vars and stuff)
- MainStageScript
- Playerscripts (2x)

I'll try to see if I can load this all the way from my Main Package script + adding all sound files. Will report later tonight.
« Last Edit: April 01, 2015, 11:34:10 AM by Helepolis »

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #477 on: April 01, 2015, 01:59:15 PM »
Drake's style is the style I currently use as well (loading objects, storing them into common data), but I do want to note one limitation: if you were to load the sound effects (and create the objects) inside the Package script, it will not work if you try to play the objects in the game script (the Package objects seem to not be recognized from the game script... or maybe I was just doing something wrong idk, but in any case user events are pretty cool anyway).

An alternative, which I haven't tried but I'm certain it works, would be to use user events and constants. In your Package script initialize all your object sound effects, you then create a new user event, and inside you get the event argument (which we would use here as either a string or number, your choice), and based on that argument, you play a certain sound. For example code, refer to this sample code.

There are definitely ways you can improve upon the sample code. One really unique way I thought of would be to use ObjFile, duplicate the SE_Constants.txt (so that you can have an empty file and a new "working" file, created/overwritten each time the sound effects are loaded, that you reference in your code), fill in all the variables with the object ID, and by doing that, you can forgo the SE_SOUND_OBJ variables in the package script, and just directly play the given event argument instead of checking all the constants to determine which one to play.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #478 on: April 01, 2015, 07:12:38 PM »
Indeed, it seems package scripts are completely isolated from from everything and sound objects don't seem to function in there.

Though it seems I am running into more issues. First of all when I boot a boss through plural mode, I have all sounds except sounds being called inside my System.txt. If I boot the game through my stage script and meet the same boss, I don't have player sounds any more (shooting, spell card). Sounds.txt is called from all locations but problem keeps being persistent. Even more weird, when I load my own spell practise through my package script, which then eventually boots up the stage script to do a spell practise, it will start mixing sounds. Suddenly it will play voices or BGMs during spell cards.

And I did add #System["<pathto>/function_system.txt"] in each plural script so the system should be always loaded.

[Setup]
System.txt > calls sounds.txt  (in this file, spell card declare SFX (like se_cat00) is played or when boss step ends, another sound is played)
Plural scripts > #System is defined.
nonspells/spell cards > calls sounds.txt (regular sounds played like se_power / se_tan00 etc)
Stage script > calls sounds.txt and boots system script (handles the stage looks etc, loads sounds because it can be used for enemy wave patterns and such)
Player script(s) > calls sounds.txt (player spell card declare sound, fire sound, graze sound etc)

Plural mode:
- spell/nonspell sounds OK
- Player sounds OK
- System.txt are missing

Package play story mode (which eventually loads stage script)
- spell/nonspell sounds OK
- Player sounds missing
- System.txt sounds OK

I am extremely confused atm.

Edit: made some post edits to explain hopefully better.

Edit2
The mixing of sounds probably occurs due to sounds being unloaded or commondata being cleared. I can see it happening in my Sound log window.
1) Package script booted
2) Spell practise chosen (boots stage script then a plural script which loads 1 spell card)
3) All sounds work fine (log window shows sounds present)
4) Exit through the pause menu (sounds still present
5) Pick same spell card again
6) For some reason now, sounds are completely cleared / disappeared / unloaded.
« Last Edit: April 01, 2015, 07:54:11 PM by Helepolis »

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #479 on: April 02, 2015, 06:44:45 AM »
Ok so uh yeah, packages are a no-go. After some testing, the objects created in a Package script persist when you start other scripts, as expected, but:
1) New scripts lose control of the package's objects entirely, and the engine reassigns new object IDs starting back at 0
2) But, the package script still uses the existing object IDs
3) When you "come back" to the package script it actually just restarts, so the same objects are then recreated with IDs counting up from where the other scripts left off
4) Which means the package script can't even use/delete the objects it made the last time it ran, creating an object limbo and potential memory leaking!
5) When starting another script again, repeat step 1

Anyways yes gtbot, use of events the other idea I had. At first I was wary of flooding the event scheduler so I opted not to, but all things considered in regular circumstances you won't be calling many sounds on any given frame anyways. That is, as long as you're using a specific NotifyEvent() and not All(). However, I think using an ObjFile is overly convoluted, and playing with files isn't exactly quick. Just use an array to store the object IDs and you're done.
« Last Edit: April 02, 2015, 07:41:19 AM by Drake »

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