public World() { float w, h; w = 640.0f; h = 480.0f; bodyList = new List <Body>(); engine = new PhysicsEngine(); engine.BroadPhase = new Physics2DDotNet.Detectors.BruteForceDetector(); engine.Solver = new Physics2DDotNet.Solvers.SequentialImpulsesSolver(); engine.AddLogic(new GravityField(new Vector2D(0, 500), new Lifespan())); Coefficients coffecients = new Coefficients(.8f, .5f); Shape floor = new Polygon(Polygon.CreateRectangle(100.0f, w), 2.0f); Shape left = new Polygon(Polygon.CreateRectangle(h, 100.0f), 2.0f); Shape right = new Polygon(Polygon.CreateRectangle(h, 100.0f), 2.0f); Physics2DDotNet.Body floorData = new Physics2DDotNet.Body(new PhysicsState(new ALVector2D(0.0f, w / 2.0f, h + 50.0f)), floor, new MassInfo(Scalar.PositiveInfinity, Scalar.PositiveInfinity), coffecients, new Lifespan()); Physics2DDotNet.Body leftData = new Physics2DDotNet.Body(new PhysicsState(new ALVector2D(0.0f, -50.0f, h / 2.0f)), left, new MassInfo(Scalar.PositiveInfinity, Scalar.PositiveInfinity), coffecients, new Lifespan()); Physics2DDotNet.Body rightData = new Physics2DDotNet.Body(new PhysicsState(new ALVector2D(0.0f, w + 50.0f, h / 2.0f)), right, new MassInfo(Scalar.PositiveInfinity, Scalar.PositiveInfinity), coffecients, new Lifespan()); floorData.IgnoresGravity = true; leftData.IgnoresGravity = true; rightData.IgnoresGravity = true; engine.AddBody(floorData); engine.AddBody(leftData); engine.AddBody(rightData); }
private Will() { _engine = new PhysicsEngine { BroadPhase = new Physics2DDotNet.Detectors.SelectiveSweepDetector(), Solver = new Physics2DDotNet.Solvers.SequentialImpulsesSolver { AllowedPenetration = 0.0001f } }; _engine.AddLogic(new GravityField(new Vector2D(0, -300), new Lifespan())); _engine.Updated += OnEngineUpdated; _timer = new PhysicsTimer(_engine.Update, .005f); }
/// <summary> /// Initializes a new instance of the <see cref="ScrollViewer"/> class. /// </summary> public ScrollViewer() { borderSoftness = BorderSoftness; AddHandler(MultitouchScreen.NewContactEvent, (NewContactEventHandler)OnNewContact); AddHandler(MultitouchScreen.ContactMovedEvent, (ContactEventHandler)OnContactMoved); AddHandler(MultitouchScreen.ContactRemovedEvent, (ContactEventHandler)OnContactRemoved); AddHandler(MultitouchScreen.ContactLeaveEvent, (ContactEventHandler)OnContactLeave); engine = new PhysicsEngine(); engine.BroadPhase = new SweepAndPruneDetector(); engine.Solver = new SequentialImpulsesSolver(); engine.AddLogic(new BoundsConstrainLogic(this)); timer = new PhysicsTimer(PhysicsTimerCallback, 0.01); Loaded += ScrollViewer_Loaded; }