Hey guys, new to the forum and to game development in general.
I'm an engineering/physics student getting my feet wet with game development to get better at programming and have som fun along the way. I'm making a 2d platformer, but want to make my engine fairly physics based (eventually adding rotations, angular momentum, maybe even elasticity etc).
Looking for some input on how to best handle collision detection for games with continuous movement (ie not chopping up the screen into 20x20 grids or whatever). My problem is that when updating player coordinates with hero.x = hero.x + dx, collisions are a bit tricky. My previous solution was to keep track of the distance between each object and the hero, and comparing the distance between and after resolving x = x + dx. If the distance had switched sign, that means the player has went through a wall which triggers a collision "fix".
This works, but it's buggy sometimes. I'm considering another solution: When generating the objects, I could keep track of all the space coordinates that are occupied by these objects in some sort of list. Then, before updating player position, I could check if this list of occupied coordinates contains any of the points between hero.x and hero.x + dx. That would mean a collision has occured. Sounds fairly quick computationally, especially if I happen to have some sort of idea what the thickness of the objects are - say they're all atleast 5 pixels thick. Then I only need to check every fourth or fifth point on the line connecting x and x + dx.
Is this viable? Are there better solutions out there? Any help is appreciated