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

0 Members and 1 Guest 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
 

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