SOLVED Only 700(ish) objects then stops!

oldnoob

Member
Hi all,

I've just started a very simple project that creates snow (one drop every cycle) falling down the screen. When the Y pos of the snowdrop is greater than 350, I destroy it.

Unfortunately, once it loops around by about 600 times, the drops get fewer and fewer and by the time the counter is at 700, there are no new snowdrops at all!

I don't understand why as I'm destroying the instances when they get to the bottom of the screen. Here's a GIF...


snowwy.gif

The step event of my controller object has this...

GML:
instance_create_depth(random(600),-20,0,obj_snowdrop)
count+=1;
Any idea why this is happening?

Thanks.


Noob.
 
Last edited:

oldnoob

Member
Step event:

GML:
y+=ymove

if y>335 then {
        instance_destroy(self);
}

if place_meeting(x,y,obj_snowdrop){
    ymove=0;
        image_speed=0;   
}
ymove is set up as 1 in the the create event.
 
Why do you stop the snow when it collides with another? Chances are you're slowly building a ceiling at the top and they're all stuck there. Try creating the snow at a y of 50 instead of -20 and see if that's the case. You also don't need the "self" in there if you want the instance to destroy itself.
 

Nidoking

Member
How certain are you that the instances are not being created? Are you looking at the instance list in the debugger? What I see is that if two snowdrops overlap, they both stop moving forever. And you appear to be creating them above the top of the screen. So the top of the screen probably gets so clogged with snowdrops that all of the ones being created get stuck and can't move.
 
Just a side note, you really don't have to use a different instance for each and every snowflake. Each instance will hold like a 100 built-in variables that are totally useless in that case (you don't need 13 alarms, collision checks and 60 keyboard checks every step with each showflakes!). Best thing to do for performance is have ONE object control all that.

Think about it: you lag with 600 snowflakes, what will it be when you'll add 500 bullets, 30 enemies, scrolling background, SFX etc?

Just to give you an example, pretty much all of my GM projects rarely have more than 2-3 objects, from which I draw all the game.

Makes a lot of difference, try it.
 
Last edited:

oldnoob

Member
All wonderful feedback. I think it's the collision occurring above the screen that's doing it.

Thank you, all.
 
Top