I've been stuck on a bug regarding collision in my 2D Mario-like game. 

```
public void collision() {
    if (Rect.intersects(Robot.rect2, r)){
        robot.setSpeedY(0);
        robot.setCenterY(tileY - 32);
        robot.setJumped(false);
    } else if (Rect.intersects(Robot.rect, r)){
            robot.setSpeedY(0); 
            robot.setCenterY(tileY + 32);
    } 
    updateRect();
    if (Rect.intersects(Robot.rect3, r)){
        robot.setCenterX(tileX + 32);
        robot.setSpeedX(0);
    } else if (Rect.intersects(Robot.rect4, r)){
        robot.setCenterX(tileX - 32);
        robot.setSpeedX(0);
    }

}

```

Collision in my game is checked by comparing rectangles. My robot's rectangles: rect (bottom collision, so rectangle on bottom half of my robot sprite), rect2 (top collision), rect3 (left collision), and rect4 (right collision).

Every tile in my game is bounded by an instanced Rectangle r. When my robot's rectangle and the tile's rectangle intersect, I call collision(), which sets the position of my robots direction.

Here is my problem: If my robot is at a corner, where it is in bottom collision and right collision, and I move to the right, my robot moves INTO the right tile, and that triggers the bottom collision, and screws everything up.

Switching the postiions of the Bottom/Top & Right/Left collision doesn't help since then the same problem occurs, where the robot falls into the ground, triggering the Right/Left collision.

Essentially, I need a way to run all four at the same time. 
Thanks