I've recently picked up monogame and am working on a simple top down game to get me started and learn the basics.
I've got the movement and the rotation to follow the mouse sorted out but I'm stuck with the collisions.
What I want to know, basically, are two things:
- What would be the best way to handle collisions? I know that
Rectangle.Intersects(Rectangle1, Rectangle2)returns the overlapping rectangle, but, as the movement in top down is on x/y axis I'd like to know where the collision is happening so I can create kind of "wall sliding" where the player doesn't get stuck at the wall.
Is checking the players x/y coordinates against solid objects coordinates, then throw the player to his previous position if he enters the bounds of a solid object really the best approach? What would you suggest?
- What would be the best way to apply collisions to all of the solids, npc's etc.? I'm currently thinking of creating a
gameObjectclass that all of the objects will inherit from and just handle the collisions there.
Thanks for reading and hope that someone can give me some tips.