public void ResolveSlideCollissionOrthogonal() { var initPosition = new Vector2(0.5f,0f); var shape = new RectangleShape(initPosition, new Vector2(1,1)); IForwardMovablePhysicalEntity pe = new ForwardMovablePhysicalEntity(initPosition, shape, 1, MathHelper.Pi / 2); pe.InelasticCollision = true; ICollisionChecker collisionChecker = new CollisionCheckerMock(new List<IPhysicalEntity>() {pe}); var movementPhysics = new MovementPhysics(); ICollisionResolver collisionResolver = new MomentumCollisionResolver(collisionChecker, movementPhysics); movementPhysics.Move(pe); collisionResolver.ResolveCollisions(); Assert.Equal(pe.Position.X, 0, 2); Assert.Equal(pe.Position.Y, 0, 2); }
public void ResolveSlideCollission45() { var initPosition = new Vector2(0.5f, 0f); var shape = new RectangleShape(initPosition, new Vector2(1, 1)); float angle = 135f; var angleRads = MathHelper.ToRadians(angle); IForwardMovablePhysicalEntity pe = new ForwardMovablePhysicalEntity(initPosition, shape, 1, angleRads) {InelasticCollision = true}; ICollisionChecker collisionChecker = new CollisionCheckerMock(new List<IPhysicalEntity>() {pe}); var movementPhysics = new MovementPhysics(); ICollisionResolver collisionResolver = new MomentumCollisionResolver(collisionChecker, movementPhysics); movementPhysics.Move(pe); collisionResolver.ResolveCollisions(); Assert.Equal(pe.Position.X, 0f, 2); Assert.Equal(pe.Position.Y, -0.71f, 2); }