I'm trying to create a smooth moving 2d camera but the camera is shaking back and forth 1 pixel.
Player camera rectangle:
public Rectangle recCamPosition(Global global)
{
return new Rectangle((int)Position.X, (int)Position.Y , 320, 240);
}
Camera rectangle:
public Rectangle recCamera(Global global)
{
return new Rectangle((int)_pos.X / global.zoom, (int)_pos.Y / global.zoom, 320, 240);
}
The move method:
public void physic(Vector2 position, Player player, GameTime time, Global global)
{
if(player.recCamPosition(global).X!=recCamera(global).X)
{
_pos.X+=(player.Position.X-160-recCamera(global).X)/16;
}
}
No comments:
Post a Comment