private void Form1_Load(object sender, EventArgs e) { sogc = new SimpleOpenGlControl(); sogc.Dock = DockStyle.Fill; sogc.Paint += new PaintEventHandler(sogc_Paint); sogc.Resize += new EventHandler(sogc_Resize); Controls.Add(sogc); sogc.InitializeContexts(); InitOpenGL(sogc.Size, 1, PointF.Empty); // Define the gravity vector. b2Vec2 gravity = new b2Vec2(0.0f, -10.0f); // Do we want to let bodies sleep? bool doSleep = true; // Construct a world object, which will hold and simulate the rigid bodies. world = new b2World(gravity, doSleep); // world.SetWarmStarting(true); { b2BodyDef bd = new b2BodyDef(); b2Body ground = world.CreateBody(bd); b2PolygonShape shape = new b2PolygonShape(); shape.SetAsEdge(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f)); ground.CreateFixture(shape, 0.0f); } { float a = 0.5f; b2CircleShape shape = new b2CircleShape(); shape.m_radius = a; b2Vec2 x = new b2Vec2(-7.0f, 0.95f); b2Vec2 y; b2Vec2 deltaX = new b2Vec2(0, 1.25f); b2Vec2 deltaY = new b2Vec2(0, 1.25f); y = deltaY; for (int j = 0; j < 8; ++j) { b2BodyDef bd = new b2BodyDef(); bd.type = b2BodyType.b2_dynamicBody; bd.position = y; b2Body body = world.CreateBody(bd); body.CreateFixture(shape, 5.0f); y += deltaY; } } GDIDebugThing.instance.SetFlags(EDebugFlags.e_shapeBit); world.SetDebugDraw(GDIDebugThing.instance); System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 85; timer.SynchronizingObject = this; timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); timer.Start(); }
private void Form1_Load(object sender, EventArgs e) { sogc = new SimpleOpenGlControl(); sogc.Dock = DockStyle.Fill; sogc.Paint += new PaintEventHandler(sogc_Paint); sogc.Resize += new EventHandler(sogc_Resize); Controls.Add(sogc); sogc.InitializeContexts(); InitOpenGL(sogc.Size, 1, PointF.Empty); // Define the gravity vector. b2Vec2 gravity = new b2Vec2(0.0f, -10.0f); // Do we want to let bodies sleep? bool doSleep = true; // Construct a world object, which will hold and simulate the rigid bodies. world = new b2World(gravity, doSleep); // world.SetWarmStarting(true); { b2BodyDef bd = new b2BodyDef(); b2Body ground = world.CreateBody(bd); b2PolygonShape shape = new b2PolygonShape(); shape.SetAsEdge(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f)); ground.CreateFixture(shape, 0.0f); } { float a = 0.5f; b2CircleShape shape = new b2CircleShape(); shape.m_radius = a; b2Vec2 x = new b2Vec2(-7.0f, 0.95f); b2Vec2 y; b2Vec2 deltaX = new b2Vec2(0, 1.25f); b2Vec2 deltaY = new b2Vec2(0, 1.25f); y= deltaY; for (int j = 0; j < 8; ++j) { b2BodyDef bd = new b2BodyDef(); bd.type = b2BodyType.b2_dynamicBody; bd.position = y; b2Body body = world.CreateBody(bd); body.CreateFixture(shape, 5.0f); y += deltaY; } } GDIDebugThing.instance.SetFlags(EDebugFlags.e_shapeBit); world.SetDebugDraw(GDIDebugThing.instance); System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 85; timer.SynchronizingObject = this; timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); timer.Start(); }