GMS 2 Help with drawing fog particles around area that is getting smaller


Hi and sorry for my bad English.
I make this game where player collects food from bushes while area around exiting point is getting smaller. Kinda like those Battle Royal games. I have an object oFog, that has an ellipse collision mask that covers all of the room at the beginning of game. Then it slowly gets smaller. And if player goes beyond it, he loose points of food.

What I want to do, is to make object oFog invisible and createa texture of fog particles beyond it, that can become bigger, smaller, change rotation direction. But most important, they should come closer as oFog gets smaller.

I tried to do it with objects which had a texture of sFogParticle and they were created and destroyed while they had no collision with oFog. That looked pretty well, but creating and destroying all those objects affected performance of the game. And if player went deep into oFogParticles the game nearly stopped with few fps.

Then I tried to reach my goal with streaming particles of sFogParticle sprite. Turned out, that particles can not detect collision with oFog and, therefore, can not follow oFog or be destroyed by colliding with it.

That when I tried to make a grid by iterating from point x of camera to camera width. From y, to height. And at every point of that grid on the screen I checked collision with oFog, and in case there is not printed particle by part_particles_create();

for(var xCord = xCordStart - bourderExt; xCord <= xCordStart + camWidth + bourderExt; xCord += step) {
    for(var yCord = yCordStart - bourderExt; yCord <= yCordStart + camHeight + bourderExt; yCord += step) {
        if(!position_meeting(xCord, yCord, oFog)) && partNumber == 0 {
            part_particles_create(part, xCord, yCord, type, 1);
That worked, but looked very messy. As I create particles every step, they lost their animation, overlayered each other and just did not look not right at all.

What am I asking is how can I make moving or constantly creating and destroyed texture that does not affect performance so badly. Maybe some Kind of additional layer that can be invisible when object oFog is.

I am new to GML, so still try ways to figure this out. Thank you for your time.

I think what your doing is making is to that the particles are always there and only hide temporarily as you walk by them and then reappear when you leave. If you wanted it to work this way there isn't a whole lot of wiggle room. You could do some stuff to make it a little faster, but essentially you are going to have to run that code constantly so that it can trigger when to turn it back on.

If however you were okay with them hiding and then being hidden forever you could get better performance. So, basically you need to reverse the way your doing it. You would have all the fog objects on the screen and then a "radius" object around the player. When the radius object collides with the fog object it just destroys it. That simple.