I’m using aether.physics2d to apply physics into my game. When object fall from top, I noticed, falling is too slow. Here my code.
public class Level5 : State
{
private Texture2D _playerTexture;
private Texture2D _groundTexture;
// physics
private World _world;
private Body _playerBody;
private Body _groundBody;
public Level5(Game1 game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content)
{
_world = new World(new Vector2(0, 9.81f));
_playerTexture = content.Load<Texture2D>("Sprites/nut");
_groundTexture = content.Load<Texture2D>("Sprites/tile");
_playerBody = _world.CreateRectangle(50, 50, 1f);
_playerBody.BodyType = BodyType.Dynamic;
_playerBody.Position = new Vector2(300, 300);
var pfixture = _playerBody.CreateCircle(1.5f/2f, 1f);
// Give it some bounce and friction
pfixture.Restitution = 123f;
pfixture.Friction = 50f;
_groundBody = _world.CreateRectangle(1920, 1, 1f);
_groundBody.BodyType = BodyType.Static;
_groundBody.Position = new Vector2(0, 800);
}
public override void Draw(GameTime gametime, SpriteBatch spriteBatch)
{
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend,
null, null, null, null,
Resolution.TransformationMatrix());
spriteBatch.Draw(_groundTexture, _groundBody.Position, Color.White);
spriteBatch.Draw(_playerTexture, _playerBody.Position, Color.White );
spriteBatch.End();
}
public override void PostUpdate(GameTime gametime)
{
throw new NotImplementedException();
}
public override void Update(GameTime gameTime)
{
_world.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
}
}