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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #540 on: May 11, 2017, 08:51:09 PM »
I have a complex question, but I will ask it in a simple example:

Code: [Select]
let speed = 1;
ascent(i in 0..9){
        CreateShotA1( -, -, speed, 45 + i*10, -, -);
}

How do I make first three bullets with speed 1, next three with speed 2, and next three with speed 3.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #541 on: May 11, 2017, 09:06:24 PM »
Could just use if statements, but speed = floor(i/3)+1 should do it.

0/3 = 0
1/3 = 0.333 -> 0
2/3 = 0.666 -> 0
3/3 = 1
4/3 = 1.333 -> 1

etc

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #542 on: May 11, 2017, 10:20:54 PM »
Could just use if statements, but speed = floor(i/3)+1 should do it.

Thank you so much! I solved my problem with floor function, it's really helpful. I just wanted to know how to do this little space after each three numbers in score system. Like this: 000 000 000.

Code: [Select]
ascent(iObj in 0..9){
        ObjRender_SetX(obj, 508 + iObj*10 + floor((iObj)/3)*6);
...
}

NLTM

  • Fuck You Marisa
  • I mean, Fuck.
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #543 on: May 12, 2017, 09:51:51 AM »
So the idea here is to have some bullets spew out some more bullets whenever they touch, and it works, but only when they touch the first time (ie when they spawn in) and then never again. I thought it was because a distance of less than or equal to 1 or 10 was too small, but tweaking that doesn't seem to help. Setting it to a high number like 80 or something will have them spawn more bullets for a while longer, but then once they exit that distance, even when they get close again, they won't do anything.

Code: [Select]
task Shoot{
wait(120);
let AngleTRed = 45;
let AngleTBlue = 135;
loop{
let objShotRed = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 3, AngleTRed, BUBBLE_RED, 5);
AngleTRed += rand(85,90);
Reflect(objShotRed);

let objShotBlue = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 3, AngleTBlue, BUBBLE_BLUE, 5);
AngleTBlue += rand(85,90);
Reflect(objShotBlue);

while(GetObjectDistance(objShotRed, objShotBlue) <= 10){
CreateShotA1(ObjMove_GetX(objShotRed), ObjMove_GetY(objShotRed), 1, rand(0,360), DOT_PURPLE, 5);
CreateShotA1(ObjMove_GetX(objShotBlue), ObjMove_GetY(objShotBlue), 1, rand(0,360), DOT_PURPLE, 5);
yield;
}

wait(300);
yield;
}
}

Also, bizarrely, setting up a variable like
Code: [Select]
let Distance = GetObjectDistance(objShotBlue, objShotRed); and then calling that in the while loop just makes the bubbles spew bullets 100% of the time? I mean, I can pretty easily just type out the full GetObjectDistance function, but it was just strange.
« Last Edit: May 12, 2017, 10:16:12 AM by NLTM »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #544 on: May 12, 2017, 03:52:59 PM »
This is a fairly complex problem and you're underthinking it.

When you call CreateShot, it returns that new object's ID, which is then stored in your objShotRed/Blue variables. You immediately get to the while statement, and because their spawn points are the same the loop executes and you get the bullets. But if for example the spawn points were different, then they would be too far away, and because the while statement is only tried immediately it will fail and they wouldn't even spawn bullets once they touch for the first time.

Okay, so would they at least check for collision again once every 300 frames if they just happened to collide? No. When the loop restarts, the objShotRed/Blue variables are reset with new object IDs, and so the first ones are tossed away and will never be checked again. This is why it currently only happens "once"; because it literally only ever checks on one frame. So now you have the problem where you want to be able to check on every frame whether those bullets are colliding, but you also want to be able to fire more of the colliding bullets at the same time. This can be done without much modification.

I'm not sure why you would store the value of GetObjectDistance in a variable and try to use that instead. The variable represents the value, not the calling of the function. If you set it before the while loop and then asked (distance < 10) it would just always stay true.

The problem gets more complex if you want every red bullet and every blue bullet to be able to collide with each other, rather than just each individual fired pair of red and blue. Is this your intention?
« Last Edit: May 12, 2017, 04:00:12 PM by Drake »

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

NLTM

  • Fuck You Marisa
  • I mean, Fuck.
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #545 on: May 12, 2017, 07:10:08 PM »
Hmm.... My intention was to have every red and blue bullet be able to collide, but I might drop the idea until I learn a little more, I didn't realize I was in over my head. I appreciate the help!
« Last Edit: May 12, 2017, 07:15:21 PM by NLTM »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #546 on: May 12, 2017, 07:48:28 PM »
No problem. I actually have an example solution and demonstration of the programming pattern because this shows up every so often:
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1230565.html#msg1230565
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1234079.html#msg1234079
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1234229.html#msg1234229

But whether you can get what's going on here is another thing entirely. Take a peek if you want.

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

NLTM

  • Fuck You Marisa
  • I mean, Fuck.
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #547 on: May 12, 2017, 07:56:37 PM »
Ah, that does help! My first instinct when you told me what was wrong was to say "maybe I can write each object to an array" so I guess I was on the right track, even if I didn't know exactly how to implement that, which makes me feel a little more confident.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #548 on: May 15, 2017, 07:50:00 PM »
I've been trying to make a plural, so I have to make sure the singles delete themselves. That should be easy but I have little enemies objects beside the boss running around in the singles. After the single ends, the enemy keeps on moving then fires a little, and then it ends itself, kinda late. I've gotten everything else to delete itself properly except that. When the single ends, I'm not sure how to make the moving enemy object delete itself in time with the rest of the single.

Also, I just want to say these Q&A threads are really nice and helpful.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #549 on: May 16, 2017, 01:08:14 PM »
I've been trying to make a plural, so I have to make sure the singles delete themselves. That should be easy but I have little enemies objects beside the boss running around in the singles. After the single ends, the enemy keeps on moving then fires a little, and then it ends itself, kinda late. I've gotten everything else to delete itself properly except that. When the single ends, I'm not sure how to make the moving enemy object delete itself in time with the rest of the single.

Also, I just want to say these Q&A threads are really nice and helpful.

From what I can guess, you have an issue with object deletion.

Your extra enemies, in their main loop/looping task, should have a check to see if the main boss's HP < 0. If the main boss's HP < 0, then they should do whatever they need to do and then delete.

Alternatively, setting object auto delete to true may also work, but you still need to ensure that the enemies behave as you want them to.

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #550 on: May 17, 2017, 07:10:31 AM »
I've gone through all of Sparen's ph3 tutorials, and they are very well written (though I still don't think I can design anything :P).

That said, are there any available resources to learn about stage/package scripts?
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #551 on: May 17, 2017, 04:20:53 PM »
I've gone through all of Sparen's ph3 tutorials, and they are very well written (though I still don't think I can design anything :P).

That said, are there any available resources to learn about stage/package scripts?

Prod me until I write guides. :)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #552 on: May 18, 2017, 07:40:06 AM »
How can I render
Code: [Select]
OBJ_SPRITE_2D_LIST in
Code: [Select]
OBJ_SPRITE_2D
I tried to use RenderToTextureB1(...); but it didn't help a lot (or I used it wrong).
The main aim is to change alpha of sprite_2d_list in loop{}. ObjRender_SetAlpha(...); doesn't work on sprite lists.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #553 on: May 18, 2017, 09:56:59 AM »
Yes it does, you are probably using it incorrectly. Sprite Lists work by having you set up a single sprite, completely, and then adding it to the list of sprites to finalize it. Once you do that you cannot modify the previous sprite by itself anymore. Calling functions to modify the sprite are modifying the next sprite to be added, and anything you don't change (such as the sprite texture, render priority, etc) will also still apply to the next sprite.

Once the whole sprite list is finished, you can then call ObjSpriteList2D_CloseVertex on the object. This finalizes the sprite list, and any following modifications are applied to the whole object.

So to do what you want, you could either call ObjRender_SetAlpha once per sprite before you add them to the list, or call SetAlpha once before adding any sprites to the list so they are all affected, or to modify the whole thing after you build the list you can close the list with CloseVertex and then call SetAlpha once.
« Last Edit: May 18, 2017, 09:59:18 AM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #554 on: May 21, 2017, 07:24:35 PM »
So after tinkering around on my own, I'm still unable to make any sort of dialogue function. I've got the following functions that work to create the sprites and text and display them, but I've no idea how to put it into the stage/plural/single/whichever script I should use. I think I can use while(GetVirtualKeyState(VK_SHOT) != KEY_PUSH) {yield;} to keep the system from displaying the next part of the text and sprite, but I don't know how to make it stop the spellcards from starting.

https://pastebin.com/MCMsMxXx
« Last Edit: May 21, 2017, 11:13:23 PM by Skilvrel »

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #555 on: May 22, 2017, 12:34:22 AM »
but I don't know how to make it stop the spellcards from starting.

Use a function or subroutine instead of a task. Those will run in serial and any waits in them will stall whatever called them.

EDIT: To be clear, this is what I mean:

task Stage {

    //Stuff

    Dialogue;

    //Boss, stuff
}

sub Dialogue {
    //Text, dialogue, images, etc.
}

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #556 on: May 22, 2017, 07:10:49 PM »
Perfect. Looks like I've got it working almost the way I want it now. There's only one thing I can't seem to find a solution to. Is there a way to make the text automatically linebreak at a space?

Essentially I want

"Here is a whole lot of writing to test width of text function."

To come out

"Here is a whole lot of writing to test
width of text function"

instead of

"Here is a whole lot of writing to test wi
dth of text function"

without having to manually add a [r] for newline at the specific location.

And less important but still a little annoying, how do I make a player character not shoot during dialogue?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #557 on: May 22, 2017, 07:35:59 PM »
Perfect. Looks like I've got it working almost the way I want it now. There's only one thing I can't seem to find a solution to. Is there a way to make the text automatically linebreak at a space?
And less important but still a little annoying, how do I make a player character not shoot during dialogue?

First one: afaik no. Additionally, fonts may render differently on different machines, so where you insert a [r] will depend on the font type, font size, and word length.

http://dmf.shrinemaiden.org/wiki/Player_Functions#SetForbidPlayerShot

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #558 on: May 23, 2017, 01:51:26 AM »
You can use ObjText_GetTotalWidth to check if a textbox renders beyond a certain length. Then you'd have to check for where you want to split or something.
Anyways here's one solution I scrubbed together. It's only valid for two lines (i.e. one break) because anything more than that requires much more serious thought.

Code: [Select]
function ObjText_SetTextAutoLine(obj, s, len){
ObjText_SetText(obj, s);
let a = [];
ascent(i in 0..length(s)){
if(s[i] == ' '){ a = a ~ [i]; }
}
descent(i in 0..length(a)){
if(ObjText_GetTotalWidth(obj) < len){ return; }
ObjText_SetText(obj, s[0..a[i]] ~ "[r]" ~ s[a[i]..length(s)]);
}
ObjText_SetText(obj, s);
ObjText_SetMaxWidth(obj, len);
}

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #559 on: May 26, 2017, 01:19:38 PM »
Hi,I'm new to everything since I only used it not long. I'm using this code,

@Initialize{
     objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
    ObjEnemy_Regist(objBoss);
    let imgShikiekiki = GetCurrentScriptDirectory() ~ "Shikiekiki.png";
    ObjPrim_SetTexture(objBoss, imgShikiekiki);
    ObjSprite2D_SetSourceRect(objBoss, 45, -50, 45, 50);
    ObjSprite2D_SetDestCenter(objBoss);
    ObjMove_SetDestAtFrame(objBoss, GetCenterX(), 60, 60);
    TFinalize;
    MainTask;
}

However, The picture i wanted is not showing up, even i put the picture on the folder  ??? ??? :derp: :derp:
Why and how ?
Just keep it neutral :3

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #560 on: May 26, 2017, 04:05:33 PM »
@Initialize{
    ObjSprite2D_SetSourceRect(objBoss, 45, -50, 45, 50);
}
I am not sure how your Shikiekiki.png looks like, but the coordinates for SetSourceRect is 'top' , 'left',  'bottom' , 'right'.

Basically you're telling the game to draw the image using Y: 45 of your image as top coordinate and Y:45 as bottom coordinate, which results in 0 pixels as height. And I am not sure how -50 to 50 is picked up by the game.

Perhaps take a look at a video tutorial here: https://www.youtube.com/watch?v=dKSe8s9FsAc#t=6m50s
« Last Edit: May 26, 2017, 04:12:21 PM by Helepolis »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #561 on: May 30, 2017, 01:10:45 PM »
The picture graphic is 70x100, it's a png. And by the way, why do images get .txt line in it ?
« Last Edit: May 30, 2017, 01:15:12 PM by BananaCupcakey »
Just keep it neutral :3

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #562 on: May 30, 2017, 02:33:59 PM »
This is my another question (due last question came from Sparen's code), when im doing exact your tutorial, when i run ph3, they said "}" is neccesary.
This is my code : // texture the boss, set centre as true centre.
                             ObjPrim_SetTexture(bossObj,imgBoss);
                             ObjSprite2D_SetSourceRect(bossObj,0,0,70,100)
                             ObjSprite2D_SetSourceCenter(bossObj);  <--- This is the problem line

Note : The error line will be 19
 
Just keep it neutral :3

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #563 on: May 30, 2017, 06:01:01 PM »
This is my another question (due last question came from Sparen's code), when im doing exact your tutorial, when i run ph3, they said "}" is neccesary.
This is my code : // texture the boss, set centre as true centre.
                             ObjPrim_SetTexture(bossObj,imgBoss);
                             ObjSprite2D_SetSourceRect(bossObj,0,0,70,100)
                             ObjSprite2D_SetSourceCenter(bossObj);  <--- This is the problem line

Note : The error line will be 19
The second line is missing a semicolon. I think Danmakufu lets you get away with that if there's a closing bracket right after the line, so that's why it decided on that particular error message.
Danmakufu error messages in general tend to be a bit misleading, so it's usually a good idea to look at the code before the specific line it points out to see if the error could be there.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #564 on: May 30, 2017, 06:54:09 PM »
If there are errors in my tutorials, PLEASE PLEASE PLEASE notify me so that I can fix them.

Also, if the error is on my side, please tell me which lesson has the error.
« Last Edit: May 30, 2017, 06:56:32 PM by Sparen »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #565 on: May 31, 2017, 06:50:32 AM »
Thanks, it worked ,but this problem still is on my mind.

let imgBoss = GetCurrentScriptDirectory ~ "Shikiekiki.png";
however, my pic,I told you last time, does not appear
* I named it correctly (pic name is Shikiekiki.png.

Just keep it neutral :3

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #566 on: May 31, 2017, 09:08:50 AM »
Please show your entire script code through pastebin.com because this isn't working.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #567 on: May 31, 2017, 01:49:09 PM »
I uploaded it, username is BananaCupcake.
https://pastebin.com/jnUjjxFN
« Last Edit: May 31, 2017, 02:50:20 PM by BananaCupcakey »
Just keep it neutral :3

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #568 on: May 31, 2017, 02:20:00 PM »
I uploaded it, username is BananaCupcake.

Please include a link to the paste for easy reference. I.E. https://pastebin.com/zhrqhAy7

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #569 on: May 31, 2017, 04:26:39 PM »
Copy pasted your code and used an image with 70x100 dimensions called Shikiekiki.png. The image is in the same directory as the script and I can see the boss appearing.

Conclusion: What ever is happening on your end has to do with your image. Make sure the image is valid and not faulty.