Long story short, I fixed one of the biggest lag factors in AKR2, and I didn’t want to wait until v2.9.1 to have the game running more smoothly for everyone, so I’m releasing an update now. Play it on NG, or download it from here. (Those using Ruffle to play the downloaded version, should be able to keep their save files by giving the new version the same file name as the old one they were saving on.)
Long Story Version
Some people complained about sections in 2-A and 5-1 lagging a lot after the v2.9 update of A Koopa’s Revenge 2. I wasn’t sure why, and I couldn’t recreate the lag at first (not to brag, but I have a powerful-ish gaming laptop). After finding a way to induce lag, I started marking down where I experienced it the most so I could improve those areas for version 2.9.1. Every area had an easy explanation like too many collisions are running, or too much vector art. But that one set of areas had horrendous single-digit-framerate lag I just couldn’t explain.
As it turns out those areas were all the areas with a lot of cloud textures, but only at night. I tried in vain for hours to figure out what was wrong with the night cloud texture. I tried replacing the texture with a smaller one, replacing it with a tiny unrelated texture, and even deleting it entirely, but still it lagged at night. As it turns out, the hacked together method I was using to load the night backgrounds was swapping between the day backgrounds and then the night backgrounds thirty times per second. Which actually wasn’t a big deal at all when the night backgrounds were just the day versions with a tint applied, because nothing new needed to be loaded or unloaded. But I used a separate texture for the clouds at night, causing both the day and night textures to load in and out every single frame.
Once I had this all figured out, I just had to apply a simple fix to the background code so that it only tries to load when there is a change to the variable that stores which background to use, instead of every frame. And boom! Totally fixed. Now it only loads the backgrounds in once when they change, whether it’s day or night. So after I had tested things to be sure the backgrounds weren’t broken, I uploaded it. And now we have AKR2 v2.9 with a lot less lag.
Let this be a lesson. When you’re adding on to decade old code, rewrite the system, rather than lazily piling on top of it. And maybe learn good coding practices in the first place so you don’t have to clean up old messes.