Fixed bug with collision detection (when player fell too fast on rightTop Edge of Obstacle, Center went over test-diagonal -> RightEdge was returned)
This commit is contained in:
parent
fb3290a3b2
commit
5550543b77
File diff suppressed because one or more lines are too long
@ -156,10 +156,12 @@ public class CollisionDetector {
|
||||
}
|
||||
if (circleFullyInsideQuad)
|
||||
return circleCenterInQuadCollisionEdge(circle, circleMovement, quad, quadMovement);
|
||||
return circlePartlyOutsideQuadCollisionEdge(circle, quad);
|
||||
return circlePartlyOutsideQuadCollisionEdge(circle, circleMovement, quad, quadMovement);
|
||||
}
|
||||
|
||||
private Edge circlePartlyOutsideQuadCollisionEdge(Circle circle, Quad quad) {
|
||||
private Edge circlePartlyOutsideQuadCollisionEdge(Circle circle, Vector circleMovement, Quad quad, Vector quadMovement) {
|
||||
Vector relativeMovement = circleMovement.translate(quadMovement.negate());
|
||||
|
||||
Edge edge = Edge.NONE;
|
||||
if (circle.getCenter().getY() + circle.getRadius() >= quad.getTopEdge())
|
||||
edge = Edge.TOP;
|
||||
@ -187,12 +189,17 @@ public class CollisionDetector {
|
||||
} else if (circle.getCenter().getX() + circle.getRadius() >= quad.getRightEdge()) {
|
||||
if (edge != Edge.NONE) {
|
||||
if (edge == Edge.TOP) {
|
||||
float m = 1;
|
||||
float t = quad.getTopEdge() - m * quad.getRightEdge();
|
||||
if (circle.getCenter().getY() >= m * circle.getCenter().getX() + t)
|
||||
edge = Edge.TOP;
|
||||
else
|
||||
edge = Edge.RIGHT;
|
||||
//This movement check is because if player falls with too much speed on topLeft Vertex, sometimes RIGHT-Edge is returned
|
||||
if (relativeMovement.getY() < 0) {
|
||||
return Edge.TOP;
|
||||
} else {
|
||||
float m = 1;
|
||||
float t = quad.getTopEdge() - m * quad.getRightEdge();
|
||||
if (circle.getCenter().getY() >= m * circle.getCenter().getX() + t)
|
||||
edge = Edge.TOP;
|
||||
else
|
||||
edge = Edge.RIGHT;
|
||||
}
|
||||
} else if (edge == Edge.BOTTOM) {
|
||||
float m = -1;
|
||||
float t = quad.getBottomEdge() - m * quad.getRightEdge();
|
||||
|
@ -77,7 +77,7 @@
|
||||
<string name="tool_description_locked_format_d">You will unlock this mysterious tool at level %d</string>
|
||||
<string name="tool_description_ramp">Roll up the ramp to gain height</string>
|
||||
<string name="tool_description_spring">Shoots you in the air</string>
|
||||
<string name="tool_description_magnet">Difficult to handle, but give it a try</string>
|
||||
<string name="tool_description_magnet">You are pulled towards it. Just try it out!</string>
|
||||
<string name="tool_description_bomb">Blow up all obstacles near the bomb</string>
|
||||
<string name="tool_description_power_mushroom">This will give you super-powers for a few seconds</string>
|
||||
<string name="tool_description_stasis">Freezes a certain area which leads to longer in-air time</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user