I'm using per pixel collision detection in a scrolling shooter, which works just fine - It's the collision response that I've been struggling with.
The bit of code bellow works perfectly fine while colliding with the terrain directly bellow the ship, but in any other direction the collision responds differently. What I'm trying to do with the code bellow is find the coordinates of where the collision takes place, turn that into a direction and then negate the ships movement based on that direction... Or at least I'm pretty sure that's what I'm trying to do. I've been staring at it for too long and it's almost 3am lol.
fgACollisionP1 is where the collision takes place.
Vector2 newPos = player1Pos - fgACollisionP1; player1Pos += Vector2.Normalize(newPos) * 8;
Can anyone shed some light on this?