Help plz, drawing bug

hey im making my first game, and have a very wierd bug in drawing

the code i use:
public void Draw()
{
spritebatch.Draw(container, position, Color.White);
spritebatch.Draw(bar,position,new Rectangle((int)position.X,(int)position.Y, currenthealth, bar.Height), Color.White);
}

if i use:
public void Draw()
{
spritebatch.Draw(container, position, Color.White);
spritebatch.Draw(bar,position, Color.White);
}

if you notice in the first picture… it draws it blurry, because if i loose health the blurry part gets smaller.

any one can tell me what am i doing wrong?

Thank you very much that solved it

            int maxhealth=100;//
            int currenthealth=50;//
            float f=(float)currenthealth/maxhealth;
            spriteBatch.Draw(container, position, Color.White);
            spriteBatch.Draw(ico, new Rectangle((int)position.X,(int)position.Y, (int)(f * container.Width), container.Height), new Rectangle(0, 0, (int)(f * bar.Width), bar.Height), Color.White);
1 Like