Hi everyone ! I'm new on this forum and english is not my native language but i'll do my best to express myself.
Briefly, i'm a 25 years old chemistry student and passionate of programming. I've touched several languages (HTML & CSS, Java, C, C++ and python) and it allowed me to find the best language with the one I've a good feeling and I can quickly understand everything. So, since 2 years I'm programming in Pythont to practice myself but I've been always intrested in making a small cool game (not thoses clone of tetris, snake or whatever arcade game cauz' I never liked them sorry). I'm more intrested in dungeons crawler or Die and retry games in narrow levels. We see a bunch of thoses games on the market (Hotline miami, enter the gungeon or more recently streets of rogue etc...).
I've coded on Python with the Pygame library, a couple of lines that allow me to display images, move them, handle keyboard inputs and sounds. But, I was thinking about trying to handle collisions between entities that are represented as sprites with an ID and coordinates (x and y). There are various possibilities to check collision, but my question is more focused on a global concept.
Imagine we have a large background where there is a blue entity on the left side and a bunch (100 maybe) of red entities on the right side with random moves. If my blue entity start to move to the right, what I want is to determine when this blue entity hit a red one. The first idea that come is to check every step if the blue one collide with the other 100 red ones. In terms of computer calculating it's unforgivable to do that. So how can we optimized the collision detection to reduce this calculation time but without loosing efficiency if multiple things collide at the same time ?
I've try to think by myself and I found that maybe a solution will be to do a coordinates comparison between entities. If the red one is farther than X units then you skip the collision algorithm and you go to the next entities. It's probably faster than the first idea but i'm sure there is a more efficient way to do that, so I'm asking for help with this problem. Thank you in advance for any kind of help that you can bring to me.