Windows FPS drop, "DrawTheRoom 49 %"?

Hi everybody! I have a problem with my game and I've been googling like a mad man trying to figure it out, and I would reeaaaally appreciate any help I could get. My game is a simple 1vs1 on small arenas (you share a keyboard, very simple), and basicly you restart the game when one player has died.

But after a few games the game starts to lag, fps drops and it never recovers, just keeps on decaying the longer you play. I've double and trippled checked that there is no instances that shouldnt be there and so on.

I use a lot of particle systems, mainly with emitters set to burst, no streams, do I need to destroy all those systems even though they are burst-emitters? In that case how to do that smoothly, without loosing splash effects and so on?

When I run in debug mode, this is how it looks after awhile, but I still can't figure out what to change.

Like, if "DrawTheRoom" is 49%, why is SpriteDraw only 4 %? The numbers don't add up?

Thanks in advance!
 
A

anomalous

Guest
click the T in the upper right (with a line over it), that will show you average time. Then try again?
Check GML (instead of Engine), and Engine both. Usually GML shows an issue.
Typically you hit the T-bar (average time), and you look at GML who are the top offenders. Then let your game run.
Someone should creep up that list and become a top offender or be really obvious to spot as the big time sink. Often in that case its some recursive creation of some resource that just keeps going when it should not.

If no luck, comment out your particles if its easy, and see if it still hangs.
 
S

Snail Man

Guest
Well, from what you said, it sounds like particle ps are the issue, especially considering they are a non-Sprite draw call. I'd try destroying the particle systems between rounds if you can, maybe making the last round's one "inactive" (not creating new particles) for the first few seconds of the next round, then destroying it once all its partials have naturally decayed. This would stop the particles from disappearing abruptly.
 
Thanks alot for the help! I have tried what you said and maybe the particle systems are the problem.

However, I have tried to make a way to delete all particlesystems inbetween rounds or when the room/arena changes, but I havent found and easy way to do so. Do I need to adress the partSys-variable in each script that I use? Can you link to variables inside scripts, something like:

if part_system_exists(scr_blood.partSys)
{
part_system_destroy(scr_blood.partSys);
}
if this is the case I could "just" go through all spells/scripts like this and remove them, but is there an easier way, like just clearing all existing partsystems?


I tried something like destroying them inside the objects using them, like:

if part_system_exists(obj_magic_missle.partSys)
{
part_system_destroy(obj_magic_missle.partSys);
}

however this was very prone to errormesseages and crashes. Thanks again!
Edit: In the particle-scripts I use "part_type_sprite" instead of "part_type_shape" since I read this is more memory-efficient, in case it might be relevant.
 
S

Snail Man

Guest
Unfortunately you cannot link to particle systems in the way you describe. However, you could have it so whenever a new particle system is created, you append it to a global array of particle systems. That way all you need to do at the end of the round is loop through all the systems, destroying each one before the next round begins
 
Alright, thanks! But how would you do that exactly?

I now realize I know way too little about particle system. But a typical example in the way i use them: player 1 cast a spell, that instance/spell has a particle trail in an alarm that sets of every 3 secs, each time it uses a script that creates a particle system and then uses it just once through a emitter-burst.

So, just to clear, all my spell-particle-scripts begin with this piece of code "partSys = part_system_create();", a local variable. Does that mean I create way to many particle systems? Anyway, since they all are local variables with the same name, how might the code look if I wanted to, like you said, add them a global array? I'm fairly new to GML, as you maybe can tell.
 
S

Snail Man

Guest
Hmm, well in that case, I'd start by rewriting your particle code. There's no reason to make a new particle system for every little thing, so instead, I'd have one controller that maintains just a couple of particle systems. If that doesn't fix the problem, then you can think about clearing in between rounds, but I don't think that's actually necessary anymore, as I think the problem just lies in an exponential number of particle systems being made and accumulating over the rounds
 
A

anomalous

Guest
Typically you just create a few systems, these set the depth of the particles, and gives you a little group control for destroying them.
So maybe you make system foreground, background. Or if you have to, "spells".

All emitters for spells go into one of those few systems when you create the emitter.
If you create an emitter, when that emitter is done or no longer needed (when your object is destroyed or room end for example) use part_emitter_destroy( ps, ind );

When you're done with the system , destroy the system (Like room end, game end, etc. however you have it set up)
There should only be a few.

This is all in the manual under particles. Destroy when not needed else memory leak, its a mantra in the manual.

If for whatever reason you need to create a ton, you would need to set up an array or ds to stuff every single system you create in there (the index goes in there, not the actual system), and at the appropriate time, loop through it to delete each one. But I don't think you need that at this point.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Personally, I always create two GLOBAL particle systems and define all the particle types as global too. The first system has a high depth for drawing under, and the second system has a low depth for drawing over. Now all you need to do is create them on game start and forget about them... no need to delete or clean up. I also almost NEVER use emitters. Emitters are messy and really only good for some very specific things. Most effects can be achieved perfectly well using a bit of code and part_particles_create().
 
You people are indeed mighty, wise and kind! I shall now take on this tedious task of updating all of my particle scripts, make 3 global systems, front, back.
I shall repent my sins, never again be so lazy as to mindlessly copy and paste whole particle systems, and I shall be a wiser man henceforth!
Godspeed!

Seriously though, thanks for explaing and helping =)
 
Last edited:
Top