Jittery effects with collisions [closed]

I have been having some problems with my coding lately. I am trying to create a platform-based game and I have been having some troubles.

A friend of mine said that some update functions are out of order, so my collision is causing a jittery effect. It looks kind of weird so I am hoping that you guys could help me.

Here is the code for the update in game1.cs and player.cs

game1.cs -

protected override void Update(GameTime gameTime)
{
// Allows the game to exit
this.Exit();
player.update(gameTime);
if (f.rectangle.Intersects(player.rectangle))
{
player.isOnSurface = true;
player.position.Y = f.rectangle.Top - player.texture.Height;
}
else player.isOnSurface = false;
f.update(gameTime);
base.Update(gameTime);
}


player.cs -

public void update(GameTime gameTime)
{
position = position + velocity;
// walking
if (Keyboard.GetState().IsKeyDown(Keys.A) | Keyboard.GetState().IsKeyDown(Keys.Left)) velocity.X = -4f;
else if (Keyboard.GetState().IsKeyDown(Keys.D) | Keyboard.GetState().IsKeyDown(Keys.Right)) velocity.X = 4f;
else velocity.X = 0;
// jumping

if (Keyboard.GetState().IsKeyDown(Keys.W) | Keyboard.GetState().IsKeyDown(Keys.Up) | Keyboard.GetState().IsKeyDown(Keys.Space) && isOnSurface == true)
{
isOnSurface = false;
position.Y -= 10;
velocity.Y = -5;
}
// gravity
rectangle = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
if (!isOnSurface)
{
float i = 1;
velocity.Y += 0.15f * i;

}
else
{
velocity.Y = 0f;
}
}


I would just like to know if my functions are in order, or how to get rid of the jittery effect (and therefore a good method for collision).

closed as too localized by MichaelHouse♦, Jesse Dorsey♦Mar 25 '13 at 18:22

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

• When you draw your sprite use (int)position.X and (int)position.Y instead of just position – ssb Mar 25 '13 at 10:19
• spriteBatch.draw(texture, new Vector2((int) position.X, (int) position.Y), Color.White) – ssb Mar 25 '13 at 11:07