c# - Collision Detection Logic -
i'm creating 2d platformer xna, , it's tilebased , such have square , sloped tiles. question is, how should algorithm work? right now, have separates horizontal , vertical movement, seems work square tiles, fails in relation slopes. should checking slope intersection?
- horizontal check, , subsequent repositioning
- vertical check, , subsequent repositioning
where in algorithm slopes fall place? or there perhaps better solution have overlooked serve me better?
[edit]
algorithm pseudocode
private void collision() { if (velocity.x != 0) { //check intersections new position, reposition if there intersection //moving right if (velocity.x > 0) {} //moving left if (velocity.x < 0) {} } if (velocity.y != 0) { //check intersections new position, reposition if there intersections //moving downwards if (velocity.y > 0) {} //moving upwards if (velocity.y < 0) {} } }
Comments
Post a Comment