using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using FarseerGames.FarseerPhysics;
using FarseerGames.FarseerPhysics.Dynamics;
using FarseerGames.FarseerPhysics.Factories;
using FarseerGames.FarseerPhysics.Collisions;
namespace TestePhysics
{
///<summary>/// This is the main type for your game///</summary>publicclass Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D bola;
Body body;
Geom geom;
PhysicsSimulator simulador;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
///<summary>/// Allows the game to perform any initialization it needs to before starting to run./// This is where it can query for any required services and load any non-graphic/// related content. Calling base.Initialize will enumerate through any components/// and initialize them as well.///</summary>protectedoverridevoid Initialize()
{
// TODO: Add your initialization logic here
simulador = new PhysicsSimulator();
simulador.Gravity = new Vector2(0, 100);
base.Initialize();
}
///<summary>/// LoadContent will be called once per game and is the place to load/// all of your content.///</summary>protectedoverridevoid LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
bola = Content.Load<Texture2D>("alienFos");
// TODO: use this.Content to load your game content here
}
///<summary>/// UnloadContent will be called once per game and is the place to unload/// all content.///</summary>protectedoverridevoid UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
///<summary>/// Allows the game to run logic such as updating the world,/// checking for collisions, gathering input, and playing audio.///</summary>///<param name="gameTime">Provides a snapshot of timing values.</param>protectedoverridevoid Update(GameTime gameTime)
{
// Allows the game to exitif (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
body = BodyFactory.Instance.CreateCircleBody(simulador, bola.Width / 2, 50);
geom = GeomFactory.Instance.CreateCircleGeom(simulador, body, bola.Width / 2, 12);
body.Position = new Vector2(400, 10);
// TODO: Add your update logic here
simulador.Update(gameTime.ElapsedGameTime.Milliseconds * 0.001f);
base.Update(gameTime);
}
///<summary>/// This is called when the game should draw itself.///</summary>///<param name="gameTime">Provides a snapshot of timing values.</param>protectedoverridevoid Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
spriteBatch.Begin();
spriteBatch.Draw(bola,body.Position,null,Color.White,body.Rotation,new Vector2(bola.Width/2,bola.Height/2),
1,SpriteEffects.None,1);
spriteBatch.End();
base.Draw(gameTime);
}
}
}

A game's Update is called by default up to 60 times per second. It is the place where you would *update* your game according to all kinds of input. It is not the place to create a body or geom, because it will be recreated on every update, which is 60 times
per second by default. You should do it in either Initialize() or LoadContent(). Those are called once per game (or component).