system
Given the following post, respond as if you're commenting on Reddit:
human
Why Does My Small Game Cause Massive Slowdown While Much Bigger Games Do Not?

This is something that has kind of baffled me for a long time.

So I have a little game I'm working on in C++ using OpenGL rendering. It's essentially a re-creation of Wolf3D. All it does at the moment is render a small map with a handful of enemies (which are literally drawn as billboards) in it you can kill. They don't fight back yet, all they do is walk around randomly when they spot you, and change direction when they hit a wall.

However, if I push the number of enemies up to about 20+, the game slows to an absolute crawl.

Obviously, my code is inefficient in some way, likely the collision detection between the enemies and the walls.

What confuses me is how can my code be SO inefficient that it slows to a crawl in such a small game, when there are VASTLY bigger games with seemingly INFINITELY more going on in them that can comfortably run on the same machine at over 100fps? 

Take a game like Doom Eternal, for example. The visuals are all handled by the GPU, of course, but when you consider exactly how much is going on in a given scene, how can it run so fast? It needs to handle updating all the enemies, handling collisions for all the objects in the scene, handling projectiles flying everywhere, handling AI updates and pathfinding, just a TON of stuff.

There's obviously something I'm missing here.
gpt
If your collision code is algorithmically bad you can easily kill performance.  You need to profile your code and see where it is spending the most time.

Old-school OpenGL can also tank performance if you use the naive "send a single triangle per draw call" code that most tutorials start with.  GPUs can work amazing magic but only if you instruct them in the right way.