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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #810 on: November 05, 2015, 03:10:06 AM »
So, would verifying whether the object is deleted before spawning from its location be possible? Also, is it possible to work with offscreen bullets?

Please refer to the documentation.
http://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_IsDeleted
http://dmf.shrinemaiden.org/wiki/Shot_Functions#SetShotAutoDeleteClip

(More specifically, you can work with any object that is currently existing, regardless of whether or not they are on the screen. Even if an object such as a bullet is 'offscreen', it may still exist depending on various conditions. So yes, it is possible to work with offscreen bullets)
« Last Edit: November 05, 2015, 03:11:46 AM by Sparen »

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #811 on: November 05, 2015, 04:00:50 AM »
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 #812 on: November 05, 2015, 11:32:34 AM »
I'm dumb, it was contained in Sparen's tutorial and I'd missed it because I was too busy trying to fix the code to actually read the damn tutorial.

Still, thank you so much! This'll fix a whole lot of issues that I've been having with ph3.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #813 on: November 09, 2015, 07:44:21 PM »
(I think I post this topic on right place)
I'm writing a Danmaku Game, a very big project. And I need help in hiding game resource (code, graphics, music,?). Because it would be not interesting, if each person can change code (open Extra, without finishing Normal mode; extra lives and bombs, ?). Also there is MY graphics and MY music ( and code, sounds,? only engine is not). I'm writing on [TouhouDanmakufu] Ph3. Sorry for my English.

1000 Thankyou to a person, who will help me to solve a problem. I hope you understand me.

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #814 on: November 09, 2015, 07:45:59 PM »
Use the archiver?
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 #815 on: November 09, 2015, 07:50:15 PM »
Use the archiver?
I have installed some, but I had no imagination how there working '(mostly not working)
Maybe you know a good archiver?

Python

  • Plains of Chi-u have no end.
  • *
  • They are boundless and last forever.
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #816 on: November 09, 2015, 10:00:36 PM »
He means the archiving program that comes with Danmakufu. I have no experiences with it, but supposedly you can compress multiple files into a single DAT file with it and then use specific functions to access the files inside that DAT archive.
Have a look at my truly scrumptious scripts!.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #817 on: November 09, 2015, 11:34:19 PM »
When using Danmakufu Archives (the executable is located in tools/FileArchiver.exe), you can safely archive your code. However, please note that your file paths must be EXACT (capitalization matters), and that directories can be a little funky without proper guidance.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #818 on: November 10, 2015, 06:09:56 AM »
When using Danmakufu Archives (the executable is located in tools/FileArchiver.exe), you can safely archive your code. However, please note that your file paths must be EXACT (capitalization matters), and that directories can be a little funky without proper guidance.
I completly forgot about that's Archiver :000
Oh my "stupidness", I should try this one!

Edit: Yes, it archives all scripts/music/graphic to one dat file. But it doesn't hide all this stuff, or if I delete this stuff, he couldn't find the way. HELP! Maybe I should wright a specific path?  ???

Edit: Okay, An easier question. How to read images/sounds from Archiver file? There should be one method, because there is helpful function "AddArchiverFile(path)", "Adds the path to use when reading images or sounds from an archive file. Returns true if the archive was successfully read, false otherwise."



Please use the Edit button if your post is the last one and it is on same topic. -Hele
« Last Edit: November 10, 2015, 08:28:05 PM by Zhan_fox »

Lollipop

  • stay woke
  • literally and figuratively dying
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #819 on: November 13, 2015, 04:30:27 AM »
My tasks are shaped like this:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

task fire1 {
   let setime = 0;
   let angleA = 90;

   loop(45){
      let obj1 = CreateShotA1(GetPlayerX + 60*cos(angleA),GetPlayerY + 60*sin(angleA),0,angleA,211,30);
      angleA += 360/45;
      update(obj1);
   }

   loop{
      let obj2 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),23,0);
      let obj3 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),19,0);
      let obj4 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),35,0);
      let obj5 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),39,0);
      let obj6 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),179,0);
      let obj7 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),183,0);
      if(setime == 7){
         setime = 0;
         PlaySE(shotfx);
      }
      setime++;
      wait(2);
   }

   inRadius(obj1,obj2);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

task update(obj){
   loop{
      ObjMove_SetPosition(obj,GetPlayerX + 55*cos(ObjMove_GetAngle(obj)),GetPlayerY + 55*sin(ObjMove_GetAngle(obj)));
      yield;
   }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Currently, my inRadius task is empty. My two questions are;
1. When I call the task inRadius(obj1,obj2), Danmakufu says "obj1 cannot be found." how to fix?
2. How do I shape my inRadius task so that if a bullet is inside the ring I created in task fire1, the speed of the bullet slows down?

(Sorry if this post is stupidly long)
Touhou 1CCS:
Hard: LLS, EoSD(NB), PCB(NB), IN, MoF, TD, DDC(NB), LoLK
Lunatic: EoSD, PCB, DDC, LoLK
Extra: LLS, EoSD, PCB(Extra&Phantasm), IN, MoF, SA, DDC, LoLK
Current Focus: 1cc SA Hard, or an Extra

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #820 on: November 13, 2015, 04:47:06 AM »
The first problem is that obj1 is defined within the scope of a loop, and so can't be referenced outside of the loop. Normally this would be fixed just by declaring let obj1; before the loop (it wouldn't find obj2 either). However this won't fix anything because you have 45 separate declarations for obj1, and so you can't know what you actually mean when referring to obj1 for the inRadius call (do you mean one particular bullet? All 45 of them?). Additionally, because you have a loop without a counter or terminating condition the script will never get to inRadius in the first place.

You don't actually need to reference any of those bullets in the ring at all for your slowdown effect. Your circle has a radius of 55 and is relative to the player position, so this is essentially collision detection. You would have to write inRadius to detect if the bullet is close to the player, then call inRadius(obj2) after you fire obj2 (and again for the other five). However, because the bullets are all pretty much the same and you aren't actually doing anything with those variables afterwards you can plop the bullet creation right in the task itself instead.

Code: [Select]
task slowBullet(graphic){
  let obj = CreateShotA1(bossX, bossY, rand(2.5,4), rand(0,360), graphic, 0);
  while(!Obj_IsDeleted(obj)){
    // if bullet is within a distance of 55 to the player
    if(((GetPlayerX() - ObjMove_GetX(obj))^2 + (GetPlayerY() - ObjMove_GetY(obj))^2)^0.5 < 55){
      // slow down
    }
    yield;
  }
}

And then in your loop instead of firing the six bullets you would write slowBullet(23); slowBullet(19); etc.
« Last Edit: November 13, 2015, 05:11:57 AM by Drake »

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

Lollipop

  • stay woke
  • literally and figuratively dying
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #821 on: November 13, 2015, 05:10:45 AM »
thanks  :)
Touhou 1CCS:
Hard: LLS, EoSD(NB), PCB(NB), IN, MoF, TD, DDC(NB), LoLK
Lunatic: EoSD, PCB, DDC, LoLK
Extra: LLS, EoSD, PCB(Extra&Phantasm), IN, MoF, SA, DDC, LoLK
Current Focus: 1cc SA Hard, or an Extra

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #822 on: November 15, 2015, 02:31:36 PM »
1) How to read music/sounds/graphic that is in the .dat file? (When it was Archived by FileArchiver for ph3)

2) Which program/engine can run TouhouDanmakufu scripts too? (Please no 0.12m, ph3)

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #823 on: November 15, 2015, 03:50:01 PM »
1) How to read music/sounds/graphic that is in the .dat file? (When it was Archived by FileArchiver for ph3)

2) Which program/engine can run TouhouDanmakufu scripts too? (Please no 0.12m, ph3)

First one: Reference them as you would normally. If you had a file ScriptName/img/effect.png, and you archived it to img.dat, you should place img.dat inside ScriptName, but you do NOT need to change any of your paths. (i.e. GetCurrentScriptDirectory/img/effect.png is correct)

Just remember to give Danmakufu the archive path in your System script or something.

Second one: There is none. Danmakufu is a custom scripting language and the Danmakufu ph3 interpreter is the only way to run it unless you were to build or find a transpiler to another language.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #824 on: November 15, 2015, 06:44:16 PM »
Thanks!

First one: Reference them as you would normally. If you had a file ScriptName/img/effect.png, and you archived it to img.dat, you should place img.dat inside ScriptName, but you do NOT need to change any of your paths. (i.e. GetCurrentScriptDirectory/img/effect.png is correct)

Just remember to give Danmakufu the archive path in your System script or something.

I didn't quite understand with first one. And what if, in one ".dat" file archived more than one graphic?

Edit: Already all understand, Big big thank you to you.
« Last Edit: November 15, 2015, 08:04:50 PM by Zhan_fox »

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #825 on: November 18, 2015, 12:15:14 PM »
I'm attempting to implement some bullets that only collide if the player is moving, and I've run into some trouble.
I can't figure out how to test if the player is currently moving.
The function "GetPlayerSpeed" returns the possible speeds of the player, not the current one
Using "ObjMove_GetSpeed" on the ID returned from "GetPlayerObjectID" always returns 0 (I assume that the player object is not counted as a move Object?)
Is there a way to easily get the player's speed that I'm missing?
Is there another implementation of testing if the player is moving that I'm missing?

Here is the relevant code:
Code: [Select]
        let r = GetShotDataInfoA1(ObjShot_GetImageID(obj),TARGET_ENEMY,INFO_COLLISION);
        ObjShot_SetIntersectionEnable(obj,false);
        let pl = GetPlayerObjectID;
        while(!Obj_IsDeleted(obj)){
            if(GetObjectDistance(pl,obj)<r&&ObjMove_GetSpeed(pl)>0){
                let shot = CreateShotOA1(pl,0,0,2190,0);
                ObjRender_SetAlpha(shot,0);
                yield;
                Obj_Delete(shot);
                return;
            }
            yield;
        }

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #826 on: November 18, 2015, 05:05:05 PM »
If the player is not pressing any movement keys, then it's not moving at all. If the player is focused, it's moving at the focused speed. If the player is unfocused, then it's moving at the unfocused speed.
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

TalosMistake

  • Master of Aura and Shade
  • I'm Talos, not Talo~~
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #827 on: November 18, 2015, 08:13:06 PM »
I'm attempting to implement some bullets that only collide if the player is moving, and I've run into some trouble.
I can't figure out how to test if the player is currently moving.
The function "GetPlayerSpeed" returns the possible speeds of the player, not the current one
Using "ObjMove_GetSpeed" on the ID returned from "GetPlayerObjectID" always retturns 0 (I assume that the player object is not counted as a move Object?)
Is there a way to easily get the player's speed that I'm missing?
Is there another implementation of testing if the player is moving that I'm missing?

As Fluffy8x said, you can use GetVirtualKeyState to check whether the arrow keys are being pressed or not. If the answer is yes, then you can assume that player is moving. (You can also check the player's unfocused/focused state with this function.)

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #828 on: November 19, 2015, 02:43:22 AM »
Why is the extra shot to kill the player needed? You already seem to know how SetIntersectionEnable works. Also since it takes a boolean you can just plop the condition right in there.

Code: [Select]
task bullet(){
let obj = // CreateShotBla();
while(!Obj_IsDeleted(obj)){
ObjShot_SetIntersectionEnable(obj, condition);
yield;
}
}
So if you want to check movement keys, you can use it as that condition.

However, I wouldn't really recommend this from a design perspective. This is because checking the pressed keys happens before your player even moves, and so seems to me like one frame too early before you should actually collide. The "standard" way of checking something like this would look like:

Code: [Select]
task bullet(){
let p = [ObjMove_GetX(player), ObjMove_GetY(player)];
let op = p;

let obj = // CreateShotBla();
while(!Obj_IsDeleted(obj)){
p = [ObjMove_GetX(player), ObjMove_GetY(player)];
ObjShot_SetIntersectionEnable(obj, (p != op));
op = p;
yield;
}
}

Which would only hit the player if they both collide with the bullet and have actually just moved, on the same frame. One minor disadvantage to this is that it'll be recalculating the player positions for every bullet, which can be slightly expensive. If you care about these sorts of things like me then you can use the following sort of design pattern, where you have one object that holds the movement state and a single routine that updates it, and only ever access that one value.

Code: [Select]
let state = ObjShot_Create(OBJ_SHOT);
function IsPlayerMoving(){ return Obj_GetValueD(state, "STATE_PLAYER_MOVING", false); }

task UpdatePlayerMoving(){
let player = GetPlayerObjectID();
let p = [ObjMove_GetX(player), ObjMove_GetY(player)];
let op = p;
while(!Obj_IsDeleted(state)){
p = [ObjMove_GetX(player), ObjMove_GetY(player)];
Obj_SetValue(state, "STATE_PLAYER_MOVING", (p != op));
op = p;
yield;
}
}
UpdatePlayerMoving();

task bullet(){
let obj = // CreateShotBla();
while(!Obj_IsDeleted(obj)){
ObjShot_SetIntersectionEnable(obj, IsPlayerMoving());
yield;
}
}


Really though the first one is fine, I'm just writing this for completeness' sake.

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 #829 on: November 19, 2015, 04:25:16 AM »
Thank you all, that's very helpful.
For clarity's sake, am I right in my guess that the player is not counted as a move object?

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #830 on: November 20, 2015, 07:57:59 AM »
I'm writing a script that is intended to be synced to the music and I was wondering if there was a way to have music that slows down if the game lags.
i'm using
Code: [Select]
function Sound(path){
     let obj = ObjSound_Create;
     ObjSound_Load(obj,path);
     ObjSound_SetSoundDivision(obj, SOUND_BGM);
     ObjSound_SetRestartEnable(obj, true);
     ObjSound_SetLoopEnable(obj, true);
     ObjSound_SetLoopTime(obj, 0,300);
     ObjSound_Play(obj);
     ObjSound_SetVolumeRate(obj,95);
     return obj;
 }
instead of #bgm, but I'm open to switching to something else if that wold work better.

Is it something like(pseudo code)
Code: [Select]
@event{
     case(game lags){
     let lagAmount = Calculate Lag
     Slow music(lagAmount)
     }
}

Also, I have the music stopping if I pause, but it still plays when I click over to another window, even though that effectively pauses the rest of the script is there a way to fix that?
my Twitch Stream I play shmups sometimes

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #831 on: November 20, 2015, 08:14:29 AM »
I'm writing a script that is intended to be synced to the music and I was wondering if there was a way to have music that slows down if the game lags.
There isn't.

You can try to heavy experiment with stopping the music and fiddling with the restartenable function. But I doubt it is something to be done effectively.

Why don't you just make sure the script doesn't lag anyway?  (i.e: securing 60fps running)

Also, I have the music stopping if I pause, but it still plays when I click over to another window, even though that effectively pauses the rest of the script is there a way to fix that?
Afaik, nope. Danmakufu behaviour as you have noticed. So far nobody has even tried to attempt something like this (making music lag / not continue when focussing the main window). The solution I guess is to play full screen (which you probably guessed yourself).
« Last Edit: November 20, 2015, 08:16:29 AM by Helepolis »

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #832 on: November 20, 2015, 08:42:08 AM »
Thank you all, that's very helpful.
For clarity's sake, am I right in my guess that the player is not counted as a move object?
No, it is a Move object, but essentially all players are going to be implemented by moving using SetPosition-like functions, rather than setting an angle and speed. GetAngle and GetSpeed will only return useful values if the objects have those attributes set to something. In the same way, if you create a Shot object without giving it an angle or speed and move it around with SetPosition, it won't return useful values for those functions either.

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 #833 on: November 20, 2015, 05:12:45 PM »
Why don't you just make sure the script doesn't lag anyway?  (i.e: securing 60fps running)

How do I do this? is it code I need to include in my scripts/system or a vPatch type of thing; cause all my games still lag even with vpatch.
my Twitch Stream I play shmups sometimes

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #834 on: November 20, 2015, 05:37:10 PM »
How do I do this? is it code I need to include in my scripts/system or a vPatch type of thing; cause all my games still lag even with vpatch.
vPatch? Why would you try to apply that for Danmakufu? What do you mean with all your games?


Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #835 on: November 20, 2015, 07:07:41 PM »
It made sense to me that vpatch would work on other stgs(e.g. danmakufu) apparently this is not the case, so forget about vpatch.
,
I found this function
StartSlow(TARGET_ALL, 60);
is this what I want to do? I tried it in @initialize and it changed some of the timing for the script, but the fps in the hud still fluctuated between 59.3 and 60.4. I tried slowing it to 40 which worked but "slowing" it to 70 did not make it go any faster. Is this the intended function to secure 60fps, I am quite inept when it comes to danmakufu.
my Twitch Stream I play shmups sometimes

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #836 on: November 20, 2015, 09:31:15 PM »
It made sense to me that vpatch would work on other stgs(e.g. danmakufu) apparently this is not the case, so forget about vpatch.
,
I found this function
StartSlow(TARGET_ALL, 60);
is this what I want to do? I tried it in @initialize and it changed some of the timing for the script, but the fps in the hud still fluctuated between 59.3 and 60.4. I tried slowing it to 40 which worked but "slowing" it to 70 did not make it go any faster. Is this the intended function to secure 60fps, I am quite inept when it comes to danmakufu.
That function simply changes the frame rate of Danmakufu, which is already 60 by default. It is not an anti-lag function, its intended purpose is to create a Youmu-esque sIowdown effect. It also cannot be used to speed the game up.

If it ends up lower than that anyway, then either your scripts need to be better optimized or your computer hardware (specifically the CPU) needs to be upgraded. Do you have a ton of objects running tasks all at once? Are you deleting objects after you are finished with them? Are you using too many curvy lasers? Those in particular are WAY more process intensive than the ones that ZUN himself uses. Do you have an abundance of visual effects, possibly with primitive objects using large numbers of vertices? Are you making Danmakufu do an excessive amount of trig calculations (i.e. once every frame)?

There are quite a few things you can do to reduce lag in your scripts, many more than I'm capable of thinking of at the moment. Maybe it would help to make a more comprehensive list of things that can bog Danmakufu's framerate down.

but the fps in the hud still fluctuated between 59.3 and 60.4.
However, this is not really a significant source of lag. I've observed Danmakufu keeping these fluctuations (on the main menu at least) even under the most ideal of conditions. If small fluctuations like this are all you're experiencing, then syncing music to Danmaku shouldn't be an issue when it comes to the framerate.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #837 on: November 20, 2015, 11:22:25 PM »
If it ends up lower than that anyway, then either your scripts need to be better optimized or your computer hardware (specifically the CPU) needs to be upgraded. Do you have a ton of objects running tasks all at once? Are you deleting objects after you are finished with them? Are you using too many curvy lasers? Those in particular are WAY more process intensive than the ones that ZUN himself uses. Do you have an abundance of visual effects, possibly with primitive objects using large numbers of vertices? Are you making Danmakufu do an excessive amount of trig calculations (i.e. once every frame)?

There are quite a few things you can do to reduce lag in your scripts, many more than I'm capable of thinking of at the moment. Maybe it would help to make a more comprehensive list of things that can bog Danmakufu's framerate down.
However, this is not really a significant source of lag. I've observed Danmakufu keeping these fluctuations (on the main menu at least) even under the most ideal of conditions. If small fluctuations like this are all you're experiencing, then syncing music to Danmaku shouldn't be an issue when it comes to the framerate.

99% sure it's my my comp: 4 tasks, no lasers curvy or otherwise, black background,  I don't even have many bullets yet just moving and animating the boss. I do use a lot of trig so that might be it. But I'mnot trying to get rid of all lag, it can't be helped with my comp. I was originally thinking of something like
Code: [Select]
task lagMusic{
lagMemory += 60-GetCurrentFps();
if(lagMemory>60){
ObjSound_Stop(bgm);
wait(1);
ObjSound_Play(bgm);
lagMemory -= 60;
}
}
but wanted to see if anyone had a more elegant solution. I also wanted a way to skip ahead if the framerate speeds up like it does when you hold ctrl, but I couldn't find a speed up music function.

I find it a little surprising that no one has ever needed synchronized music before. I noticed when moving the files to and from my laptop to my pc (i sometime work on my scripts when I go places and expect to have downtime) that the sync was off and I didn't want to finish syncing my script to the lagged version when everybody else who plays it will play on the lagless one. Even small fluctuation are noticeable on a ~4min script, they add up toward the end.
Why don't you just make sure the script doesn't lag anyway?  (i.e: securing 60fps running)
made it seem like there was a trivial way to force a framerate, if there is i would like to use it instead of a hack
my Twitch Stream I play shmups sometimes

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #838 on: November 21, 2015, 05:33:01 AM »
Hele meant that you should be writing your script so it isn't so heavy that it causes unstable framerate.


99% sure it's my my comp: 4 tasks, no lasers curvy or otherwise, black background,  I don't even have many bullets yet just moving and animating the boss. I do use a lot of trig so that might be it.
It would have to be a heck of a lot to cause any sort of slowdown with that barebones of a script.

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.

However, this is moot since GetCurrentFps gives you an average over one second, rather than calculating (the inverse of) wall time elapsed between one frame and the next. You can do much better with GetStageTime, but its resolution is still only down to milliseconds and you will not accurately be counting deviation from 60FPS. A simple test on a stable script averaged 0.1232s deviation over 5 seconds, or roughly 1.5 frames late per second. That might not necessarily be correct due to the resolution, but it might be good enough to do that silly skipping method.

Quote
I find it a little surprising that no one has ever needed synchronized music before
That isn't the case, there just usually isn't a situation where your computer performs poorly enough that this is a concern.

Regardless, you should be able to write a synchronized script even without being able to run it well yourself, if you can confirm the BPM and time your script accordingly. A 120 BPM song is 2 BPS (second) and so 30 frames per beat.
« Last Edit: November 21, 2015, 06:34:40 AM by Drake »

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 #839 on: November 21, 2015, 07:04:17 AM »
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!
Paty