I wasn't sure about what section to put this question in, so i'll put it in here, sorry if i'm wrong:
this is more of just a general game dev question that has been bothering me.
let's take this scenario:
We have Sprite1 (player) and multiple instances of Sprite2 (scenery).
when Sprite1 touches Sprite2 = perform action on Sprite2.
That is simple, but i was thinking about the best, most optimized way to do this, regarding performance (in a situation where there is a lot of instances of Sprite2).
i started thinking different ways to check this condition. for example, which is usually more efficient, distance check or collision check?
say, if i disable all collision for Sprite2, and instead, use a distance check, like "distance between Sprite1 and Sprite2 is less than X = perform action on Sprite2". this is all assuming that the collision wouldn't need to be pixel perfect to begin with. and is there even more clever way to do this kind of check, for example to isolate and only check those instances (Sprite2) that are very close to the player (Sprite1)?
i guess it's really apparent that i'm not a very experienced dev, so i apologise if this is a silly question. i just simply want to learn more about efficient ways to do things, and performance is something that is always on my mind. anyway, thanks for reading and for any possible tidbits of knowledge for this.