Hello and thanks for this site!
I’m not a new programmer but I am new to game programming. I am amazed at how the solutions to some things, like collision detection are not what I expected. I thought there was more magic to it. For instance Pong, even if the ball is far away from the paddle, collision is checked each frame.
Last night I was trying to work out how to do a UI/Overlay/Options menu system on my own and I wondered, “How in the world do I know if the mouse is over a particular component?”. After a time I started just playing with collision detection to see if the current x,y position of the mouse not just collided but is within a rectangle boundary that contains the component. Instinct for me is this is overkill, just way too much. Every frame I check to see where the mouse is and if it’s within a rectangle. That’s crazy! Then my thought of managing multiple UI elements was to have a list of them with their details – that would mean that each frame I would have to iterate over the list of UI elements and see if the mouse x,y is within any of them – that just feels like using soooo much processing power and that I’m doing it wrong, that there is a more direct approach.
Is this really how I should approach it?
Thanks!