So I have a game with a lot of enemies in it, and they're using a custom movement that makes them bounce around on the screen. If they collide with a solid object, they bounce on it and change direction.
This works as it should in most situations. However, I've noticed that if the things happening on the screen become too intense, some collisions are dropped as the computer does not seem to keep up with all the detection work. If I have twenty enemies in the same room bouncing on the walls, they will sometimes just fly through the walls and become lost. It also happens frequently if the game is lagging, or if the room with the enemies in it is very small - with a lower distance between walls, the bounces happen more frequently, so the computer has to handle more collision events and some of them are lost.
Obviously, I don't want this to happen; I want the enemies to bounce on every solid object in the game without fail. Even if the game is lagging, I want things to progress as they should, and not cause odd behavior due to some events being lost. How do I solve this issue?