Skip to content

Instantly share code, notes, and snippets.

@mjr27
Created October 13, 2017 16:12
Show Gist options
  • Save mjr27/a0d4b2d79caf9ed56fce0f929dcefaa4 to your computer and use it in GitHub Desktop.
Save mjr27/a0d4b2d79caf9ed56fce0f929dcefaa4 to your computer and use it in GitHub Desktop.
[TestMethod]
public void TestReflectCollision()
{
var position = Vector2.One;
var speed = Vector2.One * -10.6f;
var dT = 0.0016666f;
var world = new World(Vector2.Zero);
var wall = world.CreateRectangle(2F, 20f, 1f, new Vector2(-1F, 10f));
wall.SetRestitution(1);
wall.SetFriction(0);
wall.FixedRotation = true;
wall.IsBullet = true;
var ball = world.CreateCircle(0.51f, 1f, position, BodyType.Dynamic);
ball.LinearVelocity = speed;
ball.SetRestitution(1);
ball.SetFriction(0);
ball.FixedRotation = true;
ball.IsBullet = true;
world.Step(dT*28);
Assert.IsTrue(ball.LinearVelocity.X < -10 && ball.LinearVelocity.Y < -10, ball.LinearVelocity.ToString());
world.Step(dT);
// this one fails
Assert.IsTrue(ball.LinearVelocity.X > 10 && ball.LinearVelocity.Y > 10, ball.LinearVelocity.ToString());
}
@sdcb
Copy link

sdcb commented Dec 25, 2018

I'm wondering how to get rid of this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment