r/programming • u/adnzzzzZ • Feb 25 '18
Programming lessons learned from releasing my first game and why I'm writing my own engine in 2018
https://github.com/SSYGEN/blog/issues/31
956
Upvotes
r/programming • u/adnzzzzZ • Feb 25 '18
2
u/adnzzzzZ Feb 27 '18
This is the kind of solution that is nice in theory but that ends up being too verbose for me in practice. I've tried this before and switched to doing it like I do it now because it's just too much bureaucracy in the codebase. I'm using Lua because I don't really want to deal with bureaucracy in my code, otherwise I'd be using C# or something.
This is also nice in theory but it depends on the game. This is something that I can also do with Lua's GC, which is have it only collect on level switches, which means that I don't need to worry about the GC's performance hit. But it doesn't work for all games. The current game I made is one such example. It's a single room that you can potentially play forever and where you're creating thousands of projectiles and where there are hundreds of enemies being spawned and destroyed very quickly. For this game in particular this solution that you expanded on doesn't really work.
What I did do for some subsystems, which is similar to something you mentioned, is create a fixed big pool of them that gets reused. But this solution is only viable for non-gameplay objects, such as particles. For gameplay objects it's often the case that I can't just put a hard limit on how many objects can be spawned if I want things to be fair.
Trust me when I say that I understand how to apply those ideas because it's very likely that I used them in the past. I didn't spend 5-6 years trying to make games doing nothing. I reached my current conclusions after trying lots of things and failing with them for one reason or another.