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

0 Members and 3 Guests are viewing this topic.

Drake

  • *
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1740 on: April 05, 2019, 07:54:43 am »
The keyword for the image file is shot_image. That might be the only thing wrong.

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

Twizzy

  • Nickname: Twizzler
  • Gender: Kermit
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1741 on: April 08, 2019, 11:14:57 pm »
Currently making some stage enemies. I'm using sparen's tutorial on it: https://sparen.github.io/ph3tutorials/ph3u3l28.html. However, every time I spawn an enemy and there isn't an enemy on the screen, danmakufu stops for a second (probably trying to run the thing) and continues without any lag. It's noticeable enough to raise some concern. Is there something in the code itself that is causing the pause, or is it the way it's programmed? Also, is there another (and better) way to make stage enemies?

this is the code I have for the enemies:
https://pastebin.com/YV6dvHQz
« Last Edit: April 09, 2019, 04:24:56 am by Helepolis »

Drake

  • *
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1742 on: April 08, 2019, 11:47:33 pm »
That kind of lag tends to come from something unloading due to being unused and having to later be reloaded or recompiled, but nothing in particular in here seems like it would make a significant impact. How are you calling this? The script should just be imported into the stage and the Create task called per enemy?

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

Twizzy

  • Nickname: Twizzler
  • Gender: Kermit
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1743 on: April 08, 2019, 11:57:40 pm »
I'm calling it through a stage script as a statement. Here's the code for that:
https://pastebin.com/sNPHB8Kh
« Last Edit: April 09, 2019, 04:25:30 am by Helepolis »

Drake

  • *
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1744 on: April 09, 2019, 12:16:51 am »
Yeah, I dunno if I'm missing something here, but unless enemFairy.png is like significantly big I don't see why it would actually stutter. Just to check though,
1) In the log window, check if the texture is pruned after the first wave then reloaded (this should be the case given your description)
2) Move your declaration of objImage outside the task and use LoadImage to preload it. This should keep the texture in memory so even after everything that uses the texture is deleted it persists instead of being unloaded.

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

Twizzy

  • Nickname: Twizzler
  • Gender: Kermit
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1745 on: April 09, 2019, 12:29:03 am »
Yep, I just checked the debugger, and it seems to occur to when it reloads the texture (it doesn't reload it when a fairy is still on screen). Using LoadImage and having it outside the task fixed the lag issue.

Drake

  • *
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1746 on: April 09, 2019, 12:45:42 am »
On a larger scale, this is why games and full stages often preload their resources, and why stages begin compiling their scripts at the start of the stage.

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=
  • Nickname: Marx
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1747 on: April 12, 2019, 06:32:52 pm »
My player script go through a lag that freeze a few seconds Danmakufu and then, render a shield around the player (instead of using TMagicCircle()).

And when the player dies and keep pressing the shot button, this error happens:
https://ibb.co/GsgyB0C

What can I do in these cases?

Player link: https://1drv.ms/u/s!AgwNeb6oBlvsgd9U5gYLfol-acAwmA
I've noticed that I put this post outside of this thread, my apologies  :P

I've removed your other thread, thanks for noticing and posting in the correct thread --Hele
« Last Edit: April 14, 2019, 07:33:54 am by Helepolis »

tsunami3000

  • Touhou is cool i guess
  • Nickname: tsu
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1748 on: April 14, 2019, 06:53:40 pm »
Hi! I have a small doubt...

When using DeleteShotAll and TYPE_ITEM, all of the bullets on screen are turned into items (little white boxes) which fly towards the player. How could I make it so that a sound is played when the player picks up those items?
some day i'll finally beat UFO... some day

Twizzy

  • Nickname: Twizzler
  • Gender: Kermit
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1749 on: April 14, 2019, 07:24:48 pm »
In the player's @Event section, you can add

Code: [Select]
case(EV_GET_ITEM){
      //statements;
}

and you can add sound effects in there since it will run every time the player gets an item

tsunami3000

  • Touhou is cool i guess
  • Nickname: tsu
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1750 on: April 14, 2019, 07:43:18 pm »
In the player's @Event section, you can add

Code: [Select]
case(EV_GET_ITEM){
      //statements;
}

and you can add sound effects in there since it will run every time the player gets an item

So I would need to have a custom player first, then?
some day i'll finally beat UFO... some day

Drake

  • *
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1751 on: April 15, 2019, 05:31:24 am »
Either a custom player or a custom item script. It depends on context which is more appropriate; if you want the sound to play when a player would collect some kind of item that way regardless of what script you're playing then you would modify a player script, but it you wanted the sound to play specifically on when a certain kind of item is collected regardless of player then you'd write an item script.

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

tsunami3000

  • Touhou is cool i guess
  • Nickname: tsu
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1752 on: April 15, 2019, 10:05:31 am »
Alright, I understand, I need an item script then. Thanks to you two, Drake and Twizzy!
some day i'll finally beat UFO... some day

Tad Marx Barba

  • Mastermind Behind the Mirror
  • Struggling with my boring life =w=
  • Nickname: Marx
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1753 on: April 16, 2019, 03:32:02 am »
My player script go through a lag that freeze a few seconds Danmakufu and then, render a shield around the player (instead of using TMagicCircle()).

And when the player dies and keep pressing the shot button, this error happens:
https://ibb.co/GsgyB0C

What can I do in these cases?

Player link: https://1drv.ms/u/s!AgwNeb6oBlvsgd9U5gYLfol-acAwmA
I've noticed that I put this post outside of this thread, my apologies  :P

I've removed your other thread, thanks for noticing and posting in the correct thread --Hele

Someone, help me :'(

Drake

  • *
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1754 on: April 16, 2019, 07:45:59 am »
I don't get any lag. However in your Shield task you do ascent(i in 0..65){ ObjRender_SetScaleXYZ(ielD, sc, sc, 0); } which just does the same thing 65 times.

As for the second thing, I've identified that what's happening is that you are calling CreatePlayerShotA1 in VaniBulletA1 and then are immediately checking its coordinates to set mx and my. This should be fine assuming that CreatePlayerShotA1 actually returns a valid object, but in this case it does not. In fact, it doesn't even return ID_INVALID (-1); it looks like if player shots are forbidden, CreatePlayerShotA1 doesn't return anything, which means the variable ParentShot isn't set to anything at all, leading to errors. That's mkm's mistake.

There's more to this though. When do you forbid player shots? On EV_PLAYER_SHOOTDOWN. Now you would think that VaniBulletA1 shouldn't be run if the player is dead, but that isn't the case; you check Obj_IsDeleted(ID), which is not a check for the player being dead. On top of this, even though your options get deleted when the player is supposed to die, your loop for this is:

Code: [Select]
while(!Obj_IsDeleted(Option)){
  if(!yetAlive){
    Obj_Delete(Option);
  }
  // stuff being run
  yield;
}

So what's happening is that the player gets shot down, yetAlive is set to false in the event, this loop resumes, the option object still exists so it runs the loop, deletes the option because yetAlive is false, then still runs whatever was in the body of the loop, including your player shot logic. So even though the player is dead and shots are forbidden, VaniBulletA1 runs anyway and the above error happens.

There are a couple main things to fix; one is that when you delete your Option object you should end the task immediately with return or do something similar. The other is that even if you changed your condition for player shots to check if the player has died, the error will still occur if the player is ever alive and shots are forbidden. So the condition to shoot should include IsPermitPlayerShot() somewhere.
« Last Edit: April 16, 2019, 07:55:56 am by Drake »

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

tsunami3000

  • Touhou is cool i guess
  • Nickname: tsu
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1755 on: April 16, 2019, 11:37:10 pm »
How could I find the x and y position where a laser collides with the edges of the screen? I want to spawn some bullets on that point, but I can't figure out a way to obtain the coordinates...
some day i'll finally beat UFO... some day

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1756 on: April 17, 2019, 02:42:55 am »
How could I find the x and y position where a laser collides with the edges of the screen? I want to spawn some bullets on that point, but I can't figure out a way to obtain the coordinates...

Given a laser's starting point and angle, you're trying to find the laser's intersection with one of the edges with the screen. For each edge, you can obtain the perpendicular distance to the edge from the laser's origin using the x/y coordinates of the respective edge and the laser's origin. Then using trigonometry, you can determine the missing coordinate.

For example, the left side of the STG_Frame and the laser being spawned at (64, 128) at 120 degrees. The laser, the edge, and the perpendicular line from the laser origin to the edge form a right triangle, where the angle between the perpendicular line and the laser is 60 degrees. Using the definition of the tangent, we get that tan(60) = opp/adj where adj = 64. Therefore, opp = 64*tan(60) = 110.85. Adding the initial height of 128, we get 238.85.

Therefore, the laser meets the edge at (0, 238.85).

A similar method can be applied for the other edges.

tsunami3000

  • Touhou is cool i guess
  • Nickname: tsu
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1757 on: April 17, 2019, 01:16:12 pm »
Given a laser's starting point and angle, you're trying to find the laser's intersection with one of the edges with the screen. For each edge, you can obtain the perpendicular distance to the edge from the laser's origin using the x/y coordinates of the respective edge and the laser's origin. Then using trigonometry, you can determine the missing coordinate.

For example, the left side of the STG_Frame and the laser being spawned at (64, 128) at 120 degrees. The laser, the edge, and the perpendicular line from the laser origin to the edge form a right triangle, where the angle between the perpendicular line and the laser is 60 degrees. Using the definition of the tangent, we get that tan(60) = opp/adj where adj = 64. Therefore, opp = 64*tan(60) = 110.85. Adding the initial height of 128, we get 238.85.

Therefore, the laser meets the edge at (0, 238.85).

A similar method can be applied for the other edges.

Thanks, it worked great!
some day i'll finally beat UFO... some day

BananaCupcakey

  • ^_^
  • Nickname: Banana
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1758 on: April 23, 2019, 10:00:55 am »
Hi, doesn't really know if someone actually asked this but how to make a boss move towards the player in a set amount of time ? I've been testing all the time and it wasn't working for me.

Side request, how can I create a laser pillar ?
« Last Edit: April 23, 2019, 10:07:10 am by BananaCupcakey »
Just keep it neutral :3

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1759 on: April 23, 2019, 12:56:29 pm »
Hi, doesn't really know if someone actually asked this but how to make a boss move towards the player in a set amount of time ? I've been testing all the time and it wasn't working for me.
Depends on whether or not you want the boss to constantly adapt to the player's position or move to the location of the player at a certain time (regardless of where the player moves afterwards). Regardless, this stuff is in the tutorials. Refer to https://sparen.github.io/ph3tutorials/docs_object.html#sub14 for some hints.

Side request, how can I create a laser pillar ?
What do you mean by a 'laser pillar'? If you mean a Straight Laser, then there are functions to create those. Otherwise, you'll need to be more specific as to what you are trying to create.

Kinedyme

  • Dream Magic - Duplex Spark!
  • Nickname: Kine
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1760 on: April 23, 2019, 01:38:46 pm »
What are the main differences between LoadScript() and LoadScriptInThread()?

BananaCupcakey

  • ^_^
  • Nickname: Banana
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1761 on: April 23, 2019, 03:04:04 pm »
Well apparently I left out the GetPlayerX and Y, no wonder I can get it right... At least I successfully did it. Thank you so much !

About the laser side request, I want to try to script this in a straight and simple way and not by tasking it one by one.
« Last Edit: April 23, 2019, 03:05:56 pm by BananaCupcakey »
Just keep it neutral :3

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1762 on: April 23, 2019, 03:33:42 pm »
Well apparently I left out the GetPlayerX and Y, no wonder I can get it right... At least I successfully did it. Thank you so much !

About the laser side request, I want to try to script this in a straight and simple way and not by tasking it one by one.

If that's what you mean, I'll note the following:
- You can use ascent loops
- For even spacing, given 8 lasers for example, there are SEVEN spaces in between, so they are spaced GetStgFrameWidth/7 pixels apart

BananaCupcakey

  • ^_^
  • Nickname: Banana
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1763 on: April 30, 2019, 03:52:01 pm »
Hi again, I was wondering how to let all/specified bullets stop on a certain time like Cirno in Perfect Freeze ?
Just keep it neutral :3

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1764 on: May 01, 2019, 02:49:34 am »
Hi again, I was wondering how to let all/specified bullets stop on a certain time like Cirno in Perfect Freeze ?

GetShotIdInCircleA1 and GetShotIdInCircleA2 may be helpful for obtaining all bullet IDs in a certain radius. The rest is looping through and setting speed/assigning tasks, etc.

Drake

  • *
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1765 on: May 01, 2019, 07:35:24 am »
I think the best way to approach this is to use a timer or flag variable that sits outside the scope of the task for the bullets and controls them all. That way you only need one.

Code: [Select]
task freeze(){
  let flag = 0;
  loop(180){
    task bullet(){
      // make bullet
      while(!flag){ yield; }
      // freeze
    }
    bullet();
    yield;
  }
  loop(60){yield;}
  flag = true;
}

Something like this?
« Last Edit: May 01, 2019, 07:37:33 am by Drake »

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

BananaCupcakey

  • ^_^
  • Nickname: Banana
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1766 on: May 01, 2019, 11:01:23 am »
So I try to experiment the code but it always gives out this error after a few seconds
A variable was changing it's value type. (File Line : 102)
And it always lagging for the whole period and the error appeared .
How can I fix it ?  ???
https://pastebin.com/BpJff2d6
Just keep it neutral :3

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1767 on: May 01, 2019, 05:20:35 pm »
So I try to experiment the code but it always gives out this error after a few seconds
A variable was changing it's value type. (File Line : 102)
And it always lagging for the whole period and the error appeared .
How can I fix it ?  ???
https://pastebin.com/BpJff2d6

You define flag as an integer 0 and then try to set it to a boolean True. Stick with one or the other.

Kinedyme

  • Dream Magic - Duplex Spark!
  • Nickname: Kine
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1768 on: May 02, 2019, 11:23:34 am »
For the functions LoadScript() and LoadTexture(), compared to LoadScriptInThread() and LoadTextureInLoadThread(), what are the differences?

Tad Marx Barba

  • Mastermind Behind the Mirror
  • Struggling with my boring life =w=
  • Nickname: Marx
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1769 on: May 05, 2019, 06:01:25 pm »
Can you help me? My system has a problem...

When the player reach to a certain nonspell, and a certain percentage of vitality comes down, the boss's steps and difficulty indicator are deleted for no apparent reason...
Demo: DANMAKUFU] System Test 01

Link to my System: OneDrive

(By the way, I forgot to thank Drake for help me in my player script  :P)
« Last Edit: May 05, 2019, 06:04:29 pm by Tad Marx Barba »
 

SMF 2.0.15 | SMF © 2017, Simple Machines
Theme based on ModernDark64 design by BlocWeb
Page created in 0.059 seconds with 41 queries.