public void Tumbler(bool stressTest = false) { Body ground; { var bd = new BodyDef(); ground = World.CreateBody(bd); } { var bd = new BodyDef { BodyType = BodyType.DynamicBody, AllowSleep = false, Position = new Vector2(0.0f, 10.0f) }; var body = World.CreateBody(bd); var shape = new PolygonShape(); shape.SetAsBox(0.5f, 10.0f, new Vector2(10.0f, 0.0f), 0.0f); body.CreateFixture(shape, 5.0f); shape.SetAsBox(0.5f, 10.0f, new Vector2(-10.0f, 0.0f), 0.0f); body.CreateFixture(shape, 5.0f); shape.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, 10.0f), 0.0f); body.CreateFixture(shape, 5.0f); shape.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, -10.0f), 0.0f); body.CreateFixture(shape, 5.0f); var jd = new RevoluteJointDef { BodyA = ground, BodyB = body, LocalAnchorA = new Vector2(0.0f, 10.0f), LocalAnchorB = new Vector2(0.0f, 0.0f), ReferenceAngle = 0.0f, MotorSpeed = 0.05f * Settings.Pi, MaxMotorTorque = 1e8f, EnableMotor = true }; _joint = (RevoluteJoint)World.CreateJoint(jd); } _bodyCount = 0; if (stressTest) { var timer = Stopwatch.StartNew(); for (int i = 0; i < FrameCount; i++) { Step(false); } timer.Stop(); Console.WriteLine($"{timer.ElapsedMilliseconds} ms"); } else { FixedUpdate = new FixedUpdate(TimeSpan.FromSeconds(1 / 60d), () => { Step(true); }); FixedUpdate.Start(); while (true) { FixedUpdate.Update(); } } }
public void Update() { FixedUpdate?.Update(); }