Lighter Clones

Hello, I am qoride and I've been working on a project recently that is similar to the Touhou series. Two of the sprites produce a copious amount of projectiles which are all clones. I know I could optimize the code in each one to reduce lag but even if I did so, I doubt much would change. Yes, I know there's turbo mode but I am looking for in between turbo mode and regular mode. So I am suggesting that maybe sooner or later to implement lag reduction without sacrificing graphics. Thank you!

Hi, welcome to the forum!

It depends on where the lag is coming from. Experiment with the WARP block (the grey one under Control) around computationally heavy sections of code.

Also, if you're not already doing this, when your projectiles hit something (either the intended target or the edge of the stage) don't just hide them, delete them.

Thanks for your input! Those are useful tips, but I've already implemented them into my projectiles. Sure I'm a novice, but I'm no beginner. I believe the reason it's lagging is because of the sheer amount of projectiles on the screen at a time. Granted that both the enemy and the player are firing at the same time, there can be up to 100 or 200 projectiles on screen. For laggier situations, I created a function that deletes all of the enemies projectiles if the total amount reaches a set amount (currently 400).

But thank you for taking the time out of your busy schedule to review my post!

No problem! With 400 sprites onstage I'm not surprised it's a little slow.

There is no reason to extreme slow down.
I made lag micro benchmark with 3 different parallel execution strategies

Micro lag test

Time of moving the entire swarm of 400 clones in 60 steps is measured. It took slightly more than 1s for "Simple loop" which is expected for 60 fps screen with no sign of significant slow down.
But the same amount of work invoked with "Parallel launch" took 6 times longer. 60 x broadcast ("synchronous broadcast loop") is even worse - 20 times slower. It seems that process/thread switch has extreme overhead but only in some cases. Or there is a problem with yielding at wrong moment.

Your only shared project extensively uses parallel execution with "launch" block for clone context. Maybe method "Knife Spread" can be rewriten to use broadcast.

Thanks dardoro! I'll try out your method. Have a good one!