Posted May 09, 2025 by WhereTheRedfernCodes
#testing #development
For the most recent update in Plush Rangers, I focused on improving the performance of the game. I wanted to share some tips I learned while going through the process that might help others that are looking to optimize code.
I didn’t use any “tricks” to improve the performance, it came down to using a consistent, methodical approach to understanding what was happening and finding improvements.
You need to know when optimizations are done.
My release performance target for this game (at release) is supporting ~500+ enemies active with corresponding effects, projectiles, and other tidbits on the screen at the same time while playing on a Steam Deck.
You don’t need perfect today, you just need to stay on course to your final goal.
Even after this round of optimizations, I’m not 100% of the way to my goal yet. I’m ok with this. I know that there will be many things that will change in the project between now and release. For iterative optimizations I’m trying to stay in contact with my goal so that as the game reaches it’s final stages the last rounds of optimization are easier to achieve.
Make a test that is 2-5x what your target goal is to break the performance of the game and find issues at scale.
Testing in normal gameplay will introduce a lot of variables and make it difficult to compare changes. In order to test your performance code changes methodically, you need a consistent comparison. Create a test environment that is as repeatable as possible that pushes beyond your target goal.
The profiler tells you where to look, but not why something is slow.
When I profiled my test bed I found that drawing was taking ~45% and enemy step was taking ~45%. That was interesting. In normal operations enemy movement was like 5% of the time and drawing was 60%+. I was dealing with two different kinds of problems.
Before I started making more changes, I need more information. What was exactly causing things to slow down? Was it loops, a specific routine, bad logic? To find the real problem areas and figure out how code was interacting, I commented out as much code as I could and still run the test. Then I reintroduced a small bit of a code at a time.
For example in my drawing routine, I commented out all the drawing and then just reintroduced constructing a matrix. I could see how it was performing and figure out if there was any wasted energy in that small section of code and test that I could improve that.
For my enemy step event code there were a few things that was making my code slow:
Because this game is drawn using a perspective camera and billboarded sprites, relying on the traditional Gamemaker drawing system wasn’t an option. All my drawing code goes through a centralized camera that loops through the appropriate objects to draw in the optimal order. (This is actually an interesting and easy to implement system). At times though, it was taking up too much energy I came across a few items to help improve performance.
Here’s a little sample video of a busy moment in the game after working through these tests. This is actually still in VM build and a full release build would perform even better.
Plush Rangers is a fast-paced auto battler where you assemble a team of Plushie Friends to take on quirky mutated enemies and objects. Explore the many biomes of Cosmic Park Swirlstone and restore Camp Cloudburst!
You can play the early alpha-test builds here on itch.io! (Bugs abound!) A release version will also be available here when we are finished.
Wishlist Plush Rangers on Steam: https://store.steampowered.com/app/3593330/Plush_Rangers/