No More Web Lag!


Hello!

So it turns out that instantiating hundreds of shapes all at once isn't very performative on a single threaded web version of Click The Shape. Who could've guessed that?? As atonement for my efficiency crimes, I went back and established a much better system. Now when maxing out the shape count in the Custom game settings, the game no longer lags for several seconds on completing an individual level. 

As for what my solution was: instead of creating new shapes for the next level when the goal was clicked, I stored the existing shapes from last level and rebranded them to fit the criteria of the next level. The technicality of it wasn't bad since it was really only keeping an array of the shape objects and adding to it when I needed more shapes. I was just being extra careful not to destroy all of my code logic as I was making changes. I'm pretty sure this is standard practice for optimization, but I'm happy that I was able to cut down the instantiation costs by 90% (max object count difference between levels is 100 with 1000 being the max count I was spawning at once before). Either way, yay progress!

Thanks for reading!

Alex , Iron Rhino Games


Files

click_the_shape_0.2.zip 15 MB
15 days ago

Leave a comment

Log in with itch.io to leave a comment.