Can someone take a look at this code for me and make sure it all checks out OK? I’m getting random times where yCollision is equal to false when I’m standing on a surface.
public void move(int delta){
xCollision = false;
yCollision = false;
pastX = x;
pastY = y;
x = nextX;
y = nextY;
collisionBox = new CollisionBox(x,y, sprite.getWidth(),sprite.getHeight()).rotate(rot,getCenterPoint());
velocity.y += (G_ACCELERATION * delta)/1000.0;
nextX = x + (velocity.x * delta)/1000.0;
if(doesCollideOnX( new CollisionBox(nextX, y, sprite.getWidth(),sprite.getHeight()).rotate(rot, getCenterPoint()))){
nextX = x;
velocity.x = 0.0;
xCollision = true;
}
nextY = y + (velocity.y * delta)/1000.0;
if(doesCollideOnY(new CollisionBox(nextX, nextY, sprite.getWidth(),sprite.getHeight()).rotate(rot, getCenterPoint()))){
nextY = y;
velocity.y = 0.0;
yCollision = true;
}
}