Author Topic: ※ Danmakufu Q&A/Problem thread 3 ※  (Read 469363 times)

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1620 on: January 07, 2019, 03:19:07 PM »
I see that some scripts use .txt files and some use .dnh files.
Is there a difference, other than personal preference?

There is no difference functionally. .dnh may be helpful if you use a text editor and want syntax highlighting.

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1621 on: January 11, 2019, 07:42:39 AM »
Is it possible to vary the alpha value of a laser along its length?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1622 on: January 11, 2019, 02:22:56 PM »
Is it possible to vary the alpha value of a laser along its length?

You can utilize multiple lasers or apply a shader to achieve this effect.

HumanReploidJP

  • The Scripter with Something of Common Sense
  • "Start the life of an idol! Let's get STAR~ted!"
    • HumanReploidJP's Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1623 on: January 13, 2019, 12:07:39 AM »
Hmm... I have a question.

What's the purpose of a loading system (when you open a pre-packaged danmakufu script)?
Can you describe the loading system? I wanted to know for sure, thank you.
MiraikeiBudoukan (Futuristic Vineyard) Game Concepts (WIP)
(Non-Touhou, yet bullet-hell-Inspirable (Like JynX). Don't get serious.)

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1624 on: January 13, 2019, 03:22:04 AM »
Hmm... I have a question.

What's the purpose of a loading system (when you open a pre-packaged danmakufu script)?
Can you describe the loading system? I wanted to know for sure, thank you.

What do you mean by 'loading system'?

HumanReploidJP

  • The Scripter with Something of Common Sense
  • "Start the life of an idol! Let's get STAR~ted!"
    • HumanReploidJP's Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1625 on: January 13, 2019, 11:10:17 PM »
What do you mean by 'loading system'?

This loading system (see picture below i.e.)
[attach=1]
MiraikeiBudoukan (Futuristic Vineyard) Game Concepts (WIP)
(Non-Touhou, yet bullet-hell-Inspirable (Like JynX). Don't get serious.)

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1626 on: January 14, 2019, 02:08:01 AM »

Splash Screens are done typically for graphical effect before the Main Menu. Many games have them in some form.

In Danmakufu, they don't have any specific purpose since they're just a few images rendered before loading the menu. Some scripters may choose to load assets for the menu, etc, but it's not necessarily required.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1627 on: January 16, 2019, 04:16:50 PM »
Hi, everyone.

I recently got into Danmakufu scripting, and I feel like I've understood the basics for the most part (including rendering, moving, and giving the boss a hitbox, some nonspells and spells), but I've run into an issue as I was working on an idea for a spell card.

The idea would be : firing 6 curvy lasers from the boss's location at intervals, which leave trails of "soul" bullets (Yuyuko-type butterfly bullets) behind as they travel, which then will randomly begin moving shortly after.

The problem is : I'm unable to find a solution to fire all six lasers and have the trails appear at the same time. I have tried using different variations of loops, ascents, different positioning of curly braces, yields, to no avail. In the recent versions of the code idea, either the lasers appear one after the other, and the rest don't appear until the prior one finishes trailing, or I get a "variable is not defined" error.

Here is the most recent version of the code I've been experimenting with. No other shooting tasks run alongside this one, this task is included in Initialize. I didn't include movement commands for the soul-bullets in this one yet. I'm using the AllStar shotsheet in this example.

Code: [Select]
task lazertime{
let i = 1;
loop{
loop(6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 5, 120+i*10, 50, 20, 1019, 10); //shoots lasers. "Zataihou" would equal "objBoss" in this code, it itself being a name for an original character of mine. Yes, I'm weird.
i++;
} //if this brace is taken out, the lasers fire sequentially instead of at the same time. If it's in, Danmakufu shows "obj is not defined" error due to the "let souls" line.

loop(20){
wait(1);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,294,10);} //would handle spawning of soul bullets along the lasers. No angle and speed set yet for testing. 294 is a Yuyuko-type, blue "butterfly" bullet graphic.
ObjCrLaser_SetTipDecrement(obj,0); //makes laser hitbox fair by removing their invisible parts
ObjMove_SetAngularVelocity(obj,-1); //curves the lasers
yield;}

I've been thinking of making the trailing be handled by a seperate task, but it would likely also bring up a "variable is not defined" error. I've also seen people use arguments in task names, but I don't exactly get what is that used for, or how to make use of it. Any advice regarding these matters is greatly appreciated.
Achieve your mission without regrets.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1628 on: January 16, 2019, 05:52:59 PM »
The problem is : I'm unable to find a solution to fire all six lasers and have the trails appear at the same time. I have tried using different variations of loops, ascents, different positioning of curly braces, yields, to no avail. In the recent versions of the code idea, either the lasers appear one after the other, and the rest don't appear until the prior one finishes trailing, or I get a "variable is not defined" error.

Here is the most recent version of the code I've been experimenting with. No other shooting tasks run alongside this one, this task is included in Initialize. I didn't include movement commands for the soul-bullets in this one yet. I'm using the AllStar shotsheet in this example.

Code: [Select]
task lazertime{
let i = 1;
loop{
loop(6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 5, 120+i*10, 50, 20, 1019, 10); //shoots lasers. "Zataihou" would equal "objBoss" in this code, it itself being a name for an original character of mine. Yes, I'm weird.
i++;
} //if this brace is taken out, the lasers fire sequentially instead of at the same time. If it's in, Danmakufu shows "obj is not defined" error due to the "let souls" line.

loop(20){
wait(1);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,294,10);} //would handle spawning of soul bullets along the lasers. No angle and speed set yet for testing. 294 is a Yuyuko-type, blue "butterfly" bullet graphic.
ObjCrLaser_SetTipDecrement(obj,0); //makes laser hitbox fair by removing their invisible parts
ObjMove_SetAngularVelocity(obj,-1); //curves the lasers
yield;}

I've been thinking of making the trailing be handled by a seperate task, but it would likely also bring up a "variable is not defined" error. I've also seen people use arguments in task names, but I don't exactly get what is that used for, or how to make use of it. Any advice regarding these matters is greatly appreciated.

Tasks are the perfect solution to your problem, since you want each laser to perform the same task. In this case, you get the ID of each laser, and pass it to a task. In the task, the trails are made.

In other words, your code structure would be as follows:

In lazertime:
- In a loop without waiting (unless you want a delay between lasers), create your lasers, and call a new task, passing the laser ID as a parameter.
- In the new task, handle the trail.

Tasks run parallel to the main routine as long as you are using yield; in your Main Loop.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1629 on: January 16, 2019, 07:06:09 PM »
Tasks are the perfect solution to your problem, since you want each laser to perform the same task. In this case, you get the ID of each laser, and pass it to a task. In the task, the trails are made.

In other words, your code structure would be as follows:

In lazertime:
- In a loop without waiting (unless you want a delay between lasers), create your lasers, and call a new task, passing the laser ID as a parameter.
- In the new task, handle the trail.

Tasks run parallel to the main routine as long as you are using yield; in your Main Loop.

Hey, Sparen. It's been a great honor to be helped out by one of the grandfathers of Danmakufu, so to say.
I created a new task to handle the trail as you've advised to do, and sure enough, now each laser leaves a trail correctly, like it was meant to be. And using an if Obj_IsDeleted statement in the trail task also successfully prevented 0,0 spawning (in case a laser went offscreen).
Many thanks for the advice!

A few more questions that came up while experimenting/thinking about spell ideas and how to code them :

-Judging from the example indicated, giving a task an argument (like : trail(obj)) serves to pass the ID of created objects so the "no variable defined" error doesn't come up? Likewise, for shots, its ID is acquired by declaring it as something?

-For more complicated shapes (in my case, a spiderweb comes to mind) it's best to use multiple tasks to handle their creation, right?

-If I want to modify the lasers by modifying their angular velocity at various intervals and values (for example, setting it to 1 after 90 frames, then 2 after 30 frames, then 0 shortly after) via tasking, would that affect even the newly spawned lasers, or would newly spawned ones also only have their velocity modified when they are intended to?

-Danmakufu seems to be faster whenever the player (Reimu) is in a "shotdown" state (before respawning) for some reason, which leads to quite big desyncs at times, mainly in more complicated patters or regarding sound effects. What could be causing this?
« Last Edit: January 16, 2019, 07:27:09 PM by Mr.Ownage »
Achieve your mission without regrets.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1630 on: January 16, 2019, 09:13:25 PM »
You shouldn't add angular velocity to non-curvy lasers. I've never been able to figure out how danmakufu's curvy lasers are supposed to work, so I just made my own out of a bunch of small straight lasers.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1631 on: January 16, 2019, 10:07:28 PM »
You shouldn't add angular velocity to non-curvy lasers. I've never been able to figure out how danmakufu's curvy lasers are supposed to work, so I just made my own out of a bunch of small straight lasers.

Don't worry, I've made sure that they are indeed curvy lasers. I've managed to get them working since.

Now, however, the only problem I have is that I've accidentally overwritten the script with an old version, thus losing a lot of work, and I had to remake it. Something went wrong, though, as bullets from the trail keep spawning at 0,0, even if if/while statements checking for if the parent lasers are deleted are included (and if they are deleted, remove said shots, but some still manage to spawn in 0,0 anyway). Perhaps due to them being spawned via an ascent?

Due to this, I'm using a weird workaround of DeleteShotInCircle aimed at 0,0 with a small radius. It looks wonky, but it works, at least.

And to help you in the curvy laser regard : you need to use ObjMove_SetAngularVelocity on your lasers to have them curve. Though first, declare them as something so you'll be able to refer them via that variable through the command.

For example, if you name your laser obj, it would look like this :
let obj = CreateCurveLaserA1(xcoord, ycoord, speed, angle, length, width, graphic, delay);
ObjMove_SetAngularVelocity(obj,number)

Hope this helps!
Achieve your mission without regrets.

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1632 on: January 16, 2019, 10:58:20 PM »
This is the code I'm currently using:

Code: [Select]
let angle = 0;
CreateShotA1(GetCenterX(),GetCenterY(),1,angle,5,5);
{
let angle = 90;
CreateShotA1(GetCenterX(),GetCenterY(),1,angle,5,5);
}

I wrote this as a test in the process of debugging a larger problem. The expected behaviour of this code here is that two bullets will be fired at angle 0 and 90 degrees respectively.

For me, this code does not compile at all, requesting a "}" on the same line as the opening bracket. Removing the curly braces leads to a conflicting declaration of 'angle'.

I'm aware that if I were to represent the latter two lines as a nested task or function I would be able to make use of a local scope for the variable, but since this code only appears once in this location and has no yields, I was wondering if there was a way to define a section of limited, local scope without using a task, function, or something queer-looking like "loop(1){...}" ?

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1633 on: January 16, 2019, 11:51:25 PM »
local{}

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1634 on: January 17, 2019, 01:39:21 AM »
Hey, Sparen. It's been a great honor to be helped out by one of the grandfathers of Danmakufu, so to say.
:V :V :V :V :V

Something went wrong, though, as bullets from the trail keep spawning at 0,0, even if if/while statements checking for if the parent lasers are deleted are included (and if they are deleted, remove said shots, but some still manage to spawn in 0,0 anyway). Perhaps due to them being spawned via an ascent?

You'll need to post code for us to locate a specific problem. In general, you need to prevent bullets from spawning if their position is based on the position of a deleted object. IE if the player bombs and a bullet that spawns other bullets is deleted, no more bullets should be spawned from that bullet (IE the task should be terminated via return;)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1635 on: January 17, 2019, 07:46:27 AM »
Here is the current version of the code I'm using for the card, which, other than the 0,0 spawning post-death, seems to work great by now :

Code: [Select]
task lazertime{
let angle = 100;
wait(60); //One time wait so the cutin can disappear by this time, and the boss can move into position
loop{
while(GetShotCount(Zataihou) > 160){yield;} //If there's many souls on screen, stop creating new lasers and trails. Once again, Zataihou = objBoss in this example.
wait(10);
ascent(i in 1..6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 12, angle+i*12, 30, 20, 1019, 10); //Handles the lasers
ObjCrLaser_SetTipDecrement(obj,0); //Makes laser hitbox fair
ObjMove_SetAngularVelocity(obj,-7); //Handles the initial curving of the lasers
trail(obj); //Task to spawn trails
straighten(obj); //Task to have the lasers go straight after a short while (so they leave the screen)
angle+=30; //Increment angle to give different laser angles
}
}}

task trail(obj){
while(Obj_IsDeleted(obj)){return;} //Supposed to handle preventing 0,0 spawning, which works until player death, but some souls spawn at 0,0 anyway on respawn.
loop(5){
wait(8);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,rand(291,298),10); //Creates the souls
fly(souls);} //Task to wait until there's a certain amount of souls, then let them begin moving
}

task straighten(obj){
ObjMove_AddPatternA2(obj,60,NO_CHANGE,NO_CHANGE,NO_CHANGE,0,11); //Task to straighten the lasers by setting their angular velocity to 0, leaving everything else intact.
}

task fly(souls){
while(GetShotCount(Zataihou) < 150){yield;} //Wait until there's enough souls, then...
ObjMove_AddPatternA2(souls,60,NO_CHANGE,rand(40,150),0.01,0,12); //... let them move around.

I'm assuming that since the lasers are in an ascent loop (which I need to have an incrementing angle, imo this is the easiest way to do so) they get spawned just a tiny bit one after the other, and because of that, since there's at least one obj (laser) on screen by that time, the ones that can spawn at the lasers' x, while the rest spawn in at 0,0?
Then again, this does not happen when the card starts out, only after player respawn. It's... weird.

For me, personally, it's not a big deal to use DeleteShotInCircle aimed at 0,0 as a workaround, but for keen eyes, it really does look wonky regardless.

« Last Edit: January 17, 2019, 07:51:18 AM by Mr.Ownage »
Achieve your mission without regrets.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1636 on: January 17, 2019, 08:19:25 AM »
Your while(Obj_IsDeleted(obj)){return;} is the culprit I think. Cannot test it as I am at work but you need to enclose this statement around the execution of your trail code.

As in:
Code: [Select]
// As long as the obj IS NOT deleted, executed the code in between. Otherwise, jump over it (thus not executed)
while (!Obj_IsDeleted(obj)) {
// Spawn fancy trail stuff here.
}
You can translate the above code into human language but reading it out loud: "While the object is not deleted, execute the code in between which is CreateShotA etc.

Because, there could be a scenario where the creation of souls could be already running while the original object is perhaps just 1 frame ago deleted. Which results in spawning at 0,0 because the original Obj is gone. And this can be confirmed because you're looping it 5 times. So if indeed the obj got deleted and the program was executing the loop, then it would simply run it 5x.

Edit: However, even if you do it like this there is still a trap in your code. It is the loop(5) and the way you're spreading out the tasks. You should approach it differently imo.

So if I understood your code. Your use case is this, right?
- Boss keeps firing number of shots on screen
- It also spawns these lasers (shots) on screen
- If the shotcount exceeds a certain number, stop spawning lasers
- Respawn lasers/shots if the number drops under this said threshold

So for this case, you will need something like this:
Code: [Select]
task fireCurvyLaser() {
  // While the boss IS alive AND the number of shots IS BELOW 160, execute the code.
  while (!Obj_IsDeleted(Zataihou) && GetShotCount(Zataihou) < 160) {
    let obj = CreateCurveLaserA1(...);
    // ... laser related stuff etc
    spawnLaserTrail(obj);
    wait(10);
  }
}

task spawnLaserTrail(obj) {
  // Loop 5x, but keep checking each loop whether the obj (laser) is NOT deleted. If the laser is "alive", spawn a soul (createShotA1)
  loop(5) {
    if (!Obj_IsDeleted(obj)) {
      let soul = CreateShotA1(...);
    }
    wait(8);
  }
}

Above code will do the following:
- Add extra lasers up to your given threshold (160 in this case)
- Prevent the laser from spawning more souls if it is "dead"
- A more compact and maintainable code

Imagine if the curvy was deleted exactly the moment when spawnLaserTrail was executing loop #3. This code will immediately prevent the spawn of future souls. This is exactly the type of control you want. Always verify the existence of the obj. When working with objects, the only reason something spawns at 0,0 is the fact that the original reference object is gone.

So why might wonder now why your code spawning things at 0,0 when the player went pichuun? (post death as you mentioned)
In your original code, your script is executing loops without verifying whether its reference object is still alive. So once the loop started running, it would just do what you told it to do: Spawn souls. But the souls used the obj as its reference for its x/y position. As the player dies, it clears the entire screen of bullets (by default). Clearing the screen means all objects (bullets) are deleted. With the objects gone, its x/y is destroyed. But your loop was probably running at that moment and thus the 0,0 spawning occurs for that specific task.

Conclusion is that you didn't check/verify or control your code. A common mistake made by many beginner and intermediate danmakufu scripters.

Hope this helps out.


Edits, spelling/grammar correction
« Last Edit: January 17, 2019, 09:17:46 AM by Helepolis »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1637 on: January 17, 2019, 09:20:23 AM »
Not sure if this is exactly how you meant it, but I did this (enclosing the trail task in a while statement) :

Code: [Select]
task trail(obj){
while(!Obj_IsDeleted(obj)){ //Supposed to handle preventing 0,0 spawning
loop(5){
wait(8);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,rand(291,298),10); //Creates the souls
fly(souls);} //Task to wait until there's a certain amount of souls, then let them begin moving
}}

But it only made it worse : as soon as a laser leaves the screen, "souls" begin spawning at 0,0 in greater amounts.
One thing to note is that I'm using this code in @MainLoop to delete bullets on player death, could it be a potential culprit?

Code: [Select]
if(GetPlayerState == STATE_DOWN){
DeleteShotAll(TYPE_ALL, TYPE_FADE);

Setting the down state time to 30 frames via SetPlayerDownStateFrame (from the default 2-3 seconds) also helped alleviate the problem a LOT, but there are still rare cases of 0,0 spawning even with it.  This is all assuming the original version of the code is being used (instead of enclosing the task in a while(!Obj_IsDeleted) statement, while(Obj_IsDeleted(obj)){return;} is used) and does not occur when a bomb is used.
Achieve your mission without regrets.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1638 on: January 17, 2019, 09:28:12 AM »
I edited my post while you were probably trying it out. See my edited post, I am pretty sure it will work out.

Edit:
I have no idea why you're calling a DeleteShotAll because it is default being done when the player dies. All bullets, which aren't resistant to deletion, will be deleted. Pure objects (sprites, effects, etc) obviously won't.
« Last Edit: January 17, 2019, 09:54:57 AM by Helepolis »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1639 on: January 17, 2019, 10:10:50 AM »
Alright, the issue was found and fixed at last!

The problem was, for one, that the check for the parent laser existing was, as you've mentioned, incorrect. Rewriting it using an if(!Obj_IsDeleted(obj)) statement as you've mentioned helped do the trick.

But for the most part, I assume the problem was that I included the wait( 8 ); function inside the check statement, which would make it wait 8 frames before running the check to see if the lasers are still existing (in other words, the check wouldn't be running every frame, but rather every 8 frames). Enough time for souls to try spawning, and end up spawning at 0,0.

With these modifications done, and by putting the wait before the if statement (the wait is there to make sure the souls are nicely spread, and so they don't spawn right on the first frame, as in, on the boss), now no souls spawn at 0,0 whatsoever, nor when bombing, nor when the lasers leave the screen, nor after going pichuun.

Thanks a lot for the help so far!

About the DeleteShotAll statement, I included it because the lasers/souls don't seem to delete by default without it. Both the souls and the lasers remain if it's not included (normally, they disappear via bombing).
« Last Edit: January 17, 2019, 10:15:49 AM by Mr.Ownage »
Achieve your mission without regrets.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1640 on: January 17, 2019, 11:11:50 AM »
Ah yes. This was also a thing in 0.12m. Bullets/danmaku created through Objects (including lasers) were default immune to bombing or player death or even leaving the screen. You indeed have to tell it to be not-immune. I forgot the exact code but it is there on the wifi.

Glad to be of any help and good to see you figured it out.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1641 on: January 21, 2019, 03:32:33 PM »
As I've been working on spell card ideas more, I've run into a few roadblocks which I couldn't figure out how would I do them or how would it work :

-I've been experimenting on a spellcard which spawns bullets in triangles randomly around the screen, which worked out well. However, I've been also thinking of a spell which would have bullets incoming from the edges of the screen as a part of it (rather than randomly spawn bullets anywhere on the screen, having them spawn along the edges only). What could be a possible way to implement it? Certainly not rand with values of STGFrame width and height, as it could spawn them anywhere, rather than at the edges only.
Similiarly, how it would be best to create a task that begins spawning bullets from 0,0, then begins "going around" the screen, by going to the maximum x value, then the maximum y value, and so on, spawning bullets as it goes?

-If there are multiple objects spawning multiple objects of the same type sequentially (for example, big bullets labelled as obj, spawning smaller bullets declared as obj2), would the AddPattern function control each bullet (obj2 ones) at the same time, or in a certain order? I think it's the latter from experimenting with a spellcard in which lasers leave bullet trails, but I haven't confirmed it for sure.

-There have been occasions of needing to use an ascent loop inside a loop (mainly for more complex patterns to use the i in the ascent as incrementing values, mainly the angle) for patterns. For example:

Code: [Select]
task example{
loop{
        ascent(i in 1..10){
                               let obj = any create shot function(arguments);
                                     }
                               ObjMove_AddPatternA2(obj,stuff)
                                    }

However, in this case, an error about a non-declared variable would come up in the AddPattern line. I know it's due to the variable being inside the ascent loop, but I can't seem to find a workaround for it. Is there any?

Thanks for replies in advance!
« Last Edit: January 21, 2019, 03:37:11 PM by Mr.Ownage »
Achieve your mission without regrets.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1642 on: January 21, 2019, 04:06:04 PM »
-I've been experimenting on a spellcard which spawns bullets in triangles randomly around the screen, which worked out well. However, I've been also thinking of a spell which would have bullets incoming from the edges of the screen as a part of it (rather than randomly spawn bullets anywhere on the screen, having them spawn along the edges only). What could be a possible way to implement it? Certainly not rand with values of STGFrame width and height, as it could spawn them anywhere, rather than at the edges only.
Similiarly, how it would be best to create a task that begins spawning bullets from 0,0, then begins "going around" the screen, by going to the maximum x value, then the maximum y value, and so on, spawning bullets as it goes?
Assuming that you want to utilize the edges of the screen exclusively, you can lock one coordinate and then set the other to be random along the edge.

e.g. task a { loop { CreateShotA1(rand(0, GetStgFrameWidth), 0, 2, 90, 1, 0); yield; } }

-If there are multiple objects spawning multiple objects of the same type sequentially (for example, big bullets labelled as obj, spawning smaller bullets declared as obj2), would the AddPattern function control each bullet (obj2 ones) at the same time, or in a certain order? I think it's the latter from experimenting with a spellcard in which lasers leave bullet trails, but I haven't confirmed it for sure.
AddPattern applies to the object ID you pass to it. The frame you pass as a parameter is what controls the timing of the effect.

-There have been occasions of needing to use an ascent loop inside a loop (mainly for more complex patterns to use the i in the ascent as incrementing values, mainly the angle) for patterns. For example:

Code: [Select]
task example{
loop{
        ascent(i in 1..10){
                               let obj = any create shot function(arguments);
                                     }
                               ObjMove_AddPatternA2(obj,stuff)
                                    }

However, in this case, an error about a non-declared variable would come up in the AddPattern line. I know it's due to the variable being inside the ascent loop, but I can't seem to find a workaround for it. Is there any?

When you define a variable, it only exists in the block it was defined in. You can move the AddPattern inside the ascent, or pass the Object ID to a task that runs the AddPattern.

For more information, refer to the tutorials on the subject: https://sparen.github.io/ph3tutorials/ph3u1l8.html#sub5

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1643 on: January 21, 2019, 05:32:40 PM »
Hey there, and thanks for the detailed reply, Sparen! The mentioned information is most definitely very helpful, espicially the part on solving the problem with variables. Despite having such a simple solution, I likely couldn't have figured it out my own. A bit embarrassing, I know.

Thanks once again!
Achieve your mission without regrets.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1644 on: January 21, 2019, 05:58:18 PM »
Hey there, and thanks for the detailed reply, Sparen! The mentioned information is most definitely very helpful, espicially the part on solving the problem with variables. Despite having such a simple solution, I likely couldn't have figured it out my own. A bit embarrassing, I know.

Thanks once again!

No problem. If you have any further questions, please feel free to ask. We're here to help. :)

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1645 on: January 23, 2019, 08:23:51 AM »
Can someone please explain to me what the render functions SetFogEnable() and SetFogParam() are for?
I can't quite work it out from the documentation, and I haven't noticed anything yet by putting them in a script.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1646 on: January 23, 2019, 09:07:43 AM »
Fog is used for 3D backgrounds; it's a way for backgrounds to slowly fade away into the distance, typically when you don't want to be drawing things far away and don't want them to just disappear and reappear when they get closer (i.e. clipping).
Hele has a video tutorial briefly talking about how to use it in a script.

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

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1647 on: January 23, 2019, 08:21:25 PM »
Thanks, that video is helpful.

However, it makes me wonder, if I were to move the camera to an angle, does that mean I would have to recalculate the angles of the all the objects on the screen to control their positions?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1648 on: January 23, 2019, 09:18:17 PM »
Thanks, that video is helpful.

However, it makes me wonder, if I were to move the camera to an angle, does that mean I would have to recalculate the angles of the all the objects on the screen to control their positions?
No, that is also explained in this video tutorial.

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1649 on: January 25, 2019, 01:16:56 PM »
I discovered that adding this code causes danmakufu to not detect a .dnh script in its menu.
Code: [Select]

/***********************


************************/


What causes this behaviour? Is "/***" or "***" or "***/" reserved syntax or something?