Created
October 13, 2017 16:12
-
-
Save mjr27/a0d4b2d79caf9ed56fce0f929dcefaa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm wondering how to get rid of this issue?