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); }
public Body(float x, float y, float width, float height, float bounce, float friction, float mass) { Coefficients coffecients = new Coefficients(bounce, friction); Shape shape = new Polygon(Polygon.CreateRectangle(height, width), 3.0f); state = new PhysicsState(new ALVector2D(0.0f, x, y)); data = new Physics2DDotNet.Body(state, shape, mass, coffecients, new Lifespan()); }
public Body(float x, float y, float radius, float bounce, float friction, float mass) { Coefficients coffecients = new Coefficients(bounce, friction); Shape shape = new Circle(radius, 16); state = new PhysicsState(new ALVector2D(0.0f, x, y)); data = new Physics2DDotNet.Body(state, shape, mass, coffecients, new Lifespan()); }