How can i optimize tower defense game?

Just curious, what kind of techniques can i use in Tower defense game to make it optimized, for example TDX can handle hundreds of enemies while keeping 60 FPS on average PC with tens of towers shooting at those enemies

This isn’t an easy question to answer because there’s a lot of nuance to optimizing a game and behind the scene trickery that highly depends on how you designed your system. How do your towers work? How do your enemies work? Do enemies re-generate health once they’re shot at? Do towers have a cool down? And on and on…

Your first step is to think. Think long and hard. There are different paradigms of when you should optimize, I personally think you should first take the time to intelligently plan out what you’re setting out to achieve because rushing straight forward only guarantees messy solutions. The point of this is not to optimize, but just to organize yourself so you don’t have hastily coded in solutions.

The next step is to create a prototype of your system. Once you have a system in place and you’re happy it works, analyze your code and look for the slowest parts of your code. “Measure before you optimize” -Bjarne Strostrup.

Basically what I’m trying to say is that it’s some parts intelligent design, and other parts experience with coding and avoiding “heavy” operations.

Edit: I forgot to mention that DOD (data oriented design, the book) is a good way to get started. I’ve learned a lot of tricks from it.

2 Likes

You’re right, i’ll try to do this first, thx for help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.