I have fixed some of the previous problem. The collision when running into a corner(a wall on two sides) however is still not working. When the player runs into a corner he just falls down and out of the map. Not sure what is happening.
manageWallCollision Method:
@Override
public void manageWallCollision(Scene currScene) {
for(int i = 0; i < currScene.getMapManager().getWalls().size(); i++){
MapTile currTile = currScene.getMapManager().getWalls().get(i);
if(currTile.isCollidable()){
if(this.getBounds().intersects(currTile.getBounds())){
//down
if(vy > 0 && y2 > currTile.getY() && y2 < currTile.getY2()&& y < currTile.getY() && y < currTile.getY2() ){
setY((currTile.getY() - getHEIGHT()) - 7);
break;
}
//up
else if(vy < 0 && y < currTile.getY2() && y > currTile.getY() && y2 > currTile.getY2() && y2 > currTile.getY()){
setY(currTile.getY2() + 7);
break;
}
//right
else if(vx > 0 && x2 > currTile.getX() && x2 < currTile.getX2() && x < currTile.getX() && x < currTile.getX2() ){
setX((currTile.getX() - getHEIGHT()) - 7);
break;
}
//left
else if(vx < 0 && x < currTile.getX2() && x > currTile.getX() && x2 > currTile.getX2() && x2 > currTile.getX()){
setX(currTile.getX2() + 7);
break;
}
break;
}
}
}
}
If you need any more code or info just ask. Any help is appreciated.
bump