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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1560 on: November 05, 2018, 07:55:38 PM »
I'm trying to render a simple sprite in Danmakufu ph3, but am having problems. Trying to render this sprite: gives me this: , with this code run every frame:
Code: [Select]
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
Obj_SetRenderPriority(obj, 1);
ObjPrim_SetTexture(obj,GetCurrentScriptDirectory()~"brokenheart.png");
ObjSprite2D_SetSourceRect(obj,0,0,20,16);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj,floor(x),floor(y),1);
The image I'm trying to render is 20x16. Rendering a 16x16 image this way works perfectly - the image appears very crisp: . Any ideas?
« Last Edit: November 05, 2018, 08:01:49 PM by Earlh21 »

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1561 on: November 06, 2018, 06:32:37 PM »
I'm trying to render a simple sprite in Danmakufu ph3, but am having problems. Trying to render this sprite: gives me this: , with this code run every frame:
Code: [Select]
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
Obj_SetRenderPriority(obj, 1);
ObjPrim_SetTexture(obj,GetCurrentScriptDirectory()~"brokenheart.png");
ObjSprite2D_SetSourceRect(obj,0,0,20,16);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj,floor(x),floor(y),1);
The image I'm trying to render is 20x16. Rendering a 16x16 image this way works perfectly - the image appears very crisp: . Any ideas?

Can you provide more context? Please include the sprite itself (as an attachment/link) and some additional code around the code you provided.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1562 on: November 06, 2018, 07:13:14 PM »
I can't find where to attach files. Full code for the script is here: https://pastebin.com/raw/8nTtsfz3. The sprite I'm trying to render can be downloaded here: https://postimg.cc/tY4MXTd5.

I changed the rendering a bit so that the sprite no longer stacks up every frame, solving the issue somewhat. The image is still blurry, however: . It's supposed to be rendered like this: (this screenshot is from Undertale). The purpose of this is for a player script. I have the same code in my player script with the same issues; I'm using this single script just to test it. Here's a copy of the same script but without references to anything but the image I'm trying to render: https://pastebin.com/raw/TzrbBuJ4.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1563 on: November 06, 2018, 07:44:29 PM »
The image is still blurry, however: .

You must use a multiple of 2 for your image dimensions or directX will blue the image. I recommend just adding padding on the right and bottom of your image s.t. it becomes 32x32

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1564 on: November 07, 2018, 02:22:16 AM »
This works, thank you.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1565 on: November 07, 2018, 06:12:34 AM »
By the way, I highly recommend restructuring how you render the sprite. You don't have to create a new sprite every frame at some coordinate and then immediately delete it to simulate movement. Also, I'm not too sure why you're using add blend over alpha blend, but if that is your intention you should be using BLEND_ADD_ARGB instead, which is for images that have transparency.

If you're using it as the player sprite, the player object has the same properties as any other 2D sprite object, so you can even just do this:

Code: [Select]
let objPlayer = GetPlayerObjectID();
task RenderPlayer(){
ObjRender_SetBlendType(objPlayer, BLEND_ADD_ARGB);
ObjPrim_SetTexture(objPlayer, GetCurrentScriptDirectory() ~ "brokenheart.png");
ObjSprite2D_SetSourceRect(objPlayer, 0, 0, 20, 16);
ObjSprite2D_SetDestCenter(objPlayer);
}

And then run RenderPlayer() in @Initialize.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1566 on: November 07, 2018, 02:53:45 PM »
I can't just set the texture to the player because decimal coordinates cause the image to be blurry. I tried flooring the player's position every frame, but that ended up causing movement problems. Rendering the image as its own sprite with floored coordinates works. I used a new sprite every frame because it gave me more control over rendering, but I think a continuous task would be more concise.

How would I go about removing the default boss health bar?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1567 on: November 07, 2018, 03:06:42 PM »
How would I go about removing the default boss health bar?

The default health bar is defined with TBossLife? in the system script. For more information on System scripts, refer to
https://sparen.github.io/ph3tutorials/ph3u2l19.html

In addition, if your aim is Undertale style gameplay, there *is* an engine for that specifically (Unitale?). I haven't heard much about it recently since its hype went down with the rest of the game over time, but it may be a better option depending on what your aim is.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1568 on: November 08, 2018, 08:49:16 AM »
I can't just set the texture to the player because decimal coordinates cause the image to be blurry. I tried flooring the player's position every frame, but that ended up causing movement problems. Rendering the image as its own sprite with floored coordinates works. I used a new sprite every frame because it gave me more control over rendering, but I think a continuous task would be more concise.
Ah you already got to that; I was going to save that for the next step because I figured you'd have an issue with that. It's done pretty much as you think it is:

Code: [Select]
task DrawHeart(){
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, dir~"brokenheart.png");
ObjSprite2D_SetSourceRect(obj, 0, 0, 20, 16);
ObjSprite2D_SetDestCenter(obj);

while(!Obj_IsDeleted(objPlayer)){
ObjRender_SetPosition(obj, floor(ObjMove_GetX(objPlayer)), floor(ObjMove_GetY(objPlayer)), 0);
yield;
}
}

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 #1569 on: November 09, 2018, 02:31:51 PM »
Can the rendering angle (on the Z-axis) be set for the vertex of a 2D_SPRITE_LIST object?

And a follow up question, if the answer to the above is yes, can a different angle be set for different vertices of the same object?

Thanks in advance.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1570 on: November 09, 2018, 10:57:30 PM »
Yes and yes. You would set up the angle change before adding each sprite, just as you would for any other property. Example:

Code: [Select]
let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
ObjPrim_SetTexture(obj, dir~"enm_test.png");
ObjSpriteList2D_SetSourceRect(obj, 0, 0, 32, 32);
ObjSpriteList2D_SetDestCenter(obj);
ascent(i in 0..10){
ObjRender_SetPosition(obj, 100+i*20, 100+i*20, 0);
ObjRender_SetAngleZ(obj, i*36);
ObjSpriteList2D_AddVertex(obj);
}

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 #1571 on: November 13, 2018, 06:09:47 PM »
Does the event EV_HIT get called before the counter bomb period set by SetPlayerRebirthFrame() ?
If yes, is there an event that is called after? If no, is there an event that is called before?

I have similar queries regarding the EV_PLAYER_SHOOTDOWN event.

Thanks in advance.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1572 on: November 14, 2018, 02:37:43 AM »
I don't really know what you mean by "before" or why this is important. EV_HIT is called the frame you are hit, and the counterbomb period also naturally starts the frame you are hit. There is no real order of execution here because either you're pressing bomb or you aren't. Your question is unclear.

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 #1573 on: November 14, 2018, 08:08:38 AM »
Ah, so for example, I have code executed upon EV_HIT that does stuff like create a death explosion, delete options and set the alpha of the player sprite to zero; thence if EV_HIT is called upon being hit, and then a few frames later the player successfully counter bombs, then the player seems to respawn, but with an invisible sprite and no options.

So it would subsequently be useful if there was a way to delay the necessary actions until after the counterbomb period is exhausted, or to insead link them to an event that is called only when the player is completely dead.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1574 on: November 14, 2018, 10:22:49 AM »
To me it sounds you're trying something very unstable and complex or your order of execution is faulty. My guess is a combination of both.

You should not handle any logic in EV_HIT because it is as you describe, called upon hit. It will conflict with countercomb periods and other things. A player isn't "dead" upon hit. It is when the counterbomb timer kicks in. Only after the counterbomb timer ended, the player state will be set to really dead. Meaning you cannot even counterbomb if you tried to.

Are you aware of EV_PLAYER_SHOOTDOWN and EV_PLAYER_REBIRTH ? Because those last two are the events you should handle logic such as remove / spawn objects etc etc.

Snippet from my own game:
Code: [Select]
case(EV_PLAYER_SHOOTDOWN) {
pichuunHandler;
PlaySFX(SFX_PLDEAD01);
DeleteShotAllEX(TYPE_SHOT,TYPE_IMMEDIATE,GetPlayerX,GetPlayerY);
}
case(EV_PLAYER_REBIRTH) {
SetPlayerSpell(2);
SetPlayerInvincibilityFrame(240);
invincEffect(240);
SetForbidPlayerShot(false);
SetForbidPlayerSpell(false);
}
« Last Edit: November 14, 2018, 10:27:29 AM by Helepolis »

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1575 on: November 15, 2018, 08:19:26 AM »
I take it that this means that EV_PLAYER_SHOOTDOWN is the one that is only called after the player is actually dead then?

I'll use that in this case.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1576 on: November 15, 2018, 09:16:39 AM »
I take it that this means that EV_PLAYER_SHOOTDOWN is the one that is only called after the player is actually dead then?

I'll use that in this case.
If you want to be really sure, output a debug text on screen and modify the value inside EV_HIT and EV_PLAYER_SHOOTDOWN and EV_PLAYER_REBIRTH. Counterbomb when hit and monitor what the value becomes. Then you will see/understand the flow of "pichuun"

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1577 on: November 15, 2018, 12:54:46 PM »
Okay, so I am working on a Plural script and have somehow managed to break whatever Danmakufu does to end the script. After defeating the boss, they disappear as normal, health bar goes away, etc, but the EndScript script is never called so you don't get the option to save replays and so on.

I've narrowed it down to this standard block of code not clearing:

Code: [Select]
task TPlural {
    let obj = ObjEnemyBossScene_Create();
    //Singles added to boss scene here...
    ObjEnemyBossScene_LoadInThread(obj);
    ObjEnemyBossScene_Regist(obj);
    while(!Obj_IsDeleted(obj)){
    yield;
    }
    //Execution never reaches this point
    CloseScript(GetOwnScriptID());
}

TPlural is present in the Plural script, and is called by @Initialize as normal

From what I can tell from the logs, the while statement runs basically once per boss phase and the idea is that after the last boss phase the plural notices that the boss scene has been deleted due to lacking any further single scripts and closes itself. This then ends the whole script if you're running the Plural in isolation. However, by putting a WriteLog in the while statement I've found that it doesn't seem to be executing after the last boss phase at all! As a result, the last time Obj_IsDeleted(obj) is checked it returns false, it's never checked after it becomes true (if indeed it IS becoming true...), CloseScript(GetOwnScriptID()) never executes, and the script fails to terminate. Instead, the player just flies around on an empty screen endlessly and pointlessly.

My current hypothesis is that something I did somewhere else is somehow not "returning" execution to the Plural and is just spinning forever, but I have no idea how Danmakufu normally handles this stuff and thus no idea what change might have busted it, and it seems weird that the Plural would be successfully checking after every script BUT the last one (something I verified with writeLog). To compound the problem, I only discovered the issue after a LOT of changes to the script since I was not playing it all the way through while editing it! Additionally, the problem isn't specific to any one single as I have tried using several different singles by themselves and the script still fails to end after the single is defeated.

I don't expect anyone to be able to solve the problem based on this admittedly terrible diagnostic information, so all I really want is to know what determines when the while statement in the standard TPlural task is checked (i.e. when the TPlural task gets to execute a frame, as it is clearly not just "on every frame") and maybe some theories on what could cause it to not execute after the EnemyBossScene has been deleted. I think with that I can probably go figure out which change is causing the check to not occur. The script has some custom events and visual effects, but otherwise nothing too fancy I didn't think.

EDIT: Okay, so I compared to an old test script and found that the TPlural task SHOULD be running every frame, but for some reason isn't. This is likely the cause of the issue, as it's simply not running on any frame where the script is over. However, I have no idea what could have caused this.

EDIT: Alright, I've commented out so much of the script that it literally just displays a black screen and all you can do is shoot or bomb the boss (which is at 0, 0 with no animation) to kill it. This STILL fails to end the script, and WriteLog shows that tasks in the Plural are still stopping executing. I think that means it has to be a problem with the player script.

EDIT: ...
...
...
I deleted the @MainLoop in my plural
I have no idea when or how this happened
Somehow the only symptom this led to was the script not ending properly
I remember thinking it was weird that stuff I was putting in the Plural wasn't happening every frame a while back, so it must have been before then
I will leave this post up as a monument to my idiocy
(seriously I even misread the logging and didn't understand what it was doing, and basically stumbled upon the problem by sheer luck)
« Last Edit: November 15, 2018, 02:01:26 PM by DichotomousCreator »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1578 on: November 15, 2018, 05:10:10 PM »
I want to display the filepath of a script but Windows uses '\' instead of '/' and they are displayed as ? instead of '\'.
Is there a easy way to retrieve the position of a '\' within a string so i can replace it with a '/'?
I know that '\' is the escape character. So code like below returns an error.
"The length of a character type value is only 1"
Code: [Select]
let index = SearchChar(Text, 0, '\');
function SearchChar(Text, startindex, Char)
{
let index = -1;
ascent(i in startindex..length(Text))
{
if(Text[i] == Char){index = i;break;}
}
return index;
}

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1579 on: November 16, 2018, 03:02:59 AM »
I want to display the filepath of a script but Windows uses '\' instead of '/' and they are displayed as ? instead of '\'.
Is there a easy way to retrieve the position of a '\' within a string so i can replace it with a '/'?
I know that '\' is the escape character. So code like below returns an error.
"The length of a character type value is only 1"
Code: [Select]
let index = SearchChar(Text, 0, '\');
function SearchChar(Text, startindex, Char)
{
let index = -1;
ascent(i in startindex..length(Text))
{
if(Text[i] == Char){index = i;break;}
}
return index;
}

I'm not 100% positive this is how it works in Danmakufu, but usually the way you can do this is you can in fact escape the escape character itself. So you'd want:

Code: [Select]
let index = SearchChar(Text, 0, '\\');

This would then be seen as a single backslash character, as the first backslash escapes the second one.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1580 on: November 16, 2018, 06:42:36 AM »
The problem is that DNH itself handles the character fine, but the script interpreter is faulty in that it only sees that there are two characters being wrapped by single quotes, so it throws the error before it tries to parse what the contents are. If you're performing comparison, you can use char+0 to force characters into their numerical representations (backslash is 92), but you can also get the character indirectly with something like
Code: [Select]
"\\ "[0]
Note that some of DNH's path functions already use forward slashes, it's just some of them that use backslashes, like GetModuleDirectory.

Code: [Select]
function replace(str, a, b){
ascent(i in 0..length(str)){
if(str[i] == a){
str[i] = b;
}
}
return str;
}

let fixedpath = replace(path, "\\ "[0], '/');
« Last Edit: November 16, 2018, 06:46:03 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 #1581 on: November 16, 2018, 02:51:24 PM »
''+0 does not work but "\ "
  • works perfectly.

Thank you for your assistance.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1582 on: November 17, 2018, 02:08:31 AM »
Yeah, for the former I meant something like this:
Code: [Select]
let path = GetSomeKindOfPath(); // returns "C:\Users\Name\Desktop\"
ascent(i in 0..length(path){
  if(path[i]+0 == 92){
    path[i] = '/';
  }
}
print(path); // => "C:/Users/Name/Desktop/"

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 #1583 on: November 19, 2018, 01:55:55 PM »
Where is the ideal place to put the code for dialogue before a boss battle?
Should it be part of the stage script, plural, attached to the first single script, or in a single of its own?

Same question applies to post-battle dialogue, in the event that the answers are different.

Thanks in advance

Gregory

  • I draw stuffs
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1584 on: November 19, 2018, 05:04:10 PM »
Where is the ideal place to put the code for dialogue before a boss battle?
Should it be part of the stage script, plural, attached to the first single script, or in a single of its own?

Same question applies to post-battle dialogue, in the event that the answers are different.

Thanks in advance

depends, but I put it on the single and after the dialogue, you set the hp to 0 to initiate the first non-spell

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1585 on: November 20, 2018, 01:54:46 AM »
The most common way you'll see is to have the first entry in the plural be a script just for the dialogue. This makes some things easier because the boss enemy object stays consistent and it transitions pretty smoothly into the first pattern.

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 #1586 on: November 29, 2018, 10:50:35 PM »
What does the 'DnhViewer.exe' program in the top danmakufu directory do?

Is there a manual somewhere for how it works? Preferably one in English?

Tad Marx Barba

  • Mastermind Behind the Mirror
  • Struggling with my boring life =w=
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1587 on: December 01, 2018, 04:29:47 AM »
Hello Everyone here... I need youy help with a player script (URL: https://www6.zippyshare.com/v/HA2PPec6/file.html)

This player script is almost completed, but, I found a strange thing that occurs when I put the lines
Code: [Select]
SetForbidPlayerShot(true);
SetForbidPlayerSpell(true);
and the spell's lasers are gone. The things that happens are Darken Screen and the Sound Effect of my player's bomb are visible, but lasers are missing.

Can you teach me how to do complex player bombs?
Talk me in private or in my Facebook Account: https://www.facebook.com/tzury.van.heltz

I would greatly appreciate it!  ::) ::) ::)


My other player script: https://www62.zippyshare.com/v/Vr78Viu4/file.html
I need a review of this script...Please comment EVERYTHING that I'm need to improve in player scripts

Sound effects and sprites are not my responsibility,
credits to the intellectual authors of the material used in this player scripts

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1588 on: December 03, 2018, 12:49:32 AM »
If you have SetForbidPlayerSpell set, you can't trigger EV_REQUEST_SPELL, so your bomb will not activate. It's structured correctly.

If SetForbidPlayerShot is set during the bomb, before the lasers appear, they won't appear because shots are disabled. This should be pretty normal behaviour though, why is this a problem?

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

Tad Marx Barba

  • Mastermind Behind the Mirror
  • Struggling with my boring life =w=
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1589 on: December 03, 2018, 06:40:57 AM »
If you have SetForbidPlayerSpell set, you can't trigger EV_REQUEST_SPELL, so your bomb will not activate. It's structured correctly.

The bomb activate in the correct form, but the lasers are gone when I put the line
Code: [Select]
SetForbidPlayerShot(true);What can I do in this case? Or how could do that bomb in other way?