public override void LoadContent() { _circleBrush = new CircleBrush(64, Color.White, Color.Black); _circleBrush.Load(ScreenManager.GraphicsDevice); _circleBody = BodyFactory.Instance.CreateCircleBody(PhysicsSimulator, 64, 1); _circleBody.Position = new Vector2(725, 384); _circleGeom = GeomFactory.Instance.CreateCircleGeom(PhysicsSimulator, _circleBody, 64, 20); _rectangleBody = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 128, 1); _rectangleBody.Position = new Vector2(256, 384); _rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(PhysicsSimulator, _rectangleBody, 128, 128); _rectangleBrush = new RectangleBrush(128, 128, Color.Gold, Color.Black); _rectangleBrush.Load(ScreenManager.GraphicsDevice); _p1 = ScreenManager.ScreenCenter; _p2 = _circleGeom.Position; _lineBrush = new LineBrush(1, Color.Black); _lineBrush.Load(ScreenManager.GraphicsDevice); _marker = new CircleBrush(3, Color.Red, Color.Red); _marker.Load(ScreenManager.GraphicsDevice); base.LoadContent(); }
public void LoadObstacles() { _obstacleBrush = new RectangleBrush(128, 32, Color.White, Color.Black); _obstacleBrush.Load(ScreenManager.GraphicsDevice); _obstacleBodies = new Body[5]; _obstacleGeoms = new Geom[5]; for (int i = 0; i < _obstacleBodies.Length; i++) { _obstacleBodies[i] = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 32, 1); _obstacleBodies[i].IsStatic = true; if (i == 0) { _obstacleGeoms[i] = GeomFactory.Instance.CreateRectangleGeom(PhysicsSimulator, _obstacleBodies[i], 128, 32); _obstacleGeoms[i].RestitutionCoefficient = .2f; _obstacleGeoms[i].FrictionCoefficient = .2f; } else { _obstacleGeoms[i] = GeomFactory.Instance.CreateGeom(PhysicsSimulator, _obstacleBodies[i], _obstacleGeoms[0]); } } _obstacleBodies[0].Position = ScreenManager.ScreenCenter + new Vector2(-50, -200); _obstacleBodies[1].Position = ScreenManager.ScreenCenter + new Vector2(150, -100); _obstacleBodies[2].Position = ScreenManager.ScreenCenter + new Vector2(100, 50); _obstacleBodies[3].Position = ScreenManager.ScreenCenter + new Vector2(-100, 200); _obstacleBodies[4].Position = ScreenManager.ScreenCenter + new Vector2(-170, 0); }
public void Load(SimulatorView view, PhysicsSimulator physicsSimulator) { //use the body factory to create the physics body _borderBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _width, _height, 1); _borderBody.IsStatic = true; _borderBody.Position = _position; LoadBorderGeom(physicsSimulator); float left = (_position.X - _width / 2f); float top = (_position.Y - _height / 2f); float right = (_position.X + _width / 2f); float bottom = (_position.Y + _height / 2f); RectangleBrush r1 = view.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(_borderWidth * 2, ScreenManager.ScreenHeight)); r1.Extender.Position = new Vector2(left, _position.Y); RectangleBrush r2 = view.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(_borderWidth * 2, ScreenManager.ScreenHeight)); r2.Extender.Position = new Vector2(right, _position.Y); RectangleBrush r3 = view.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(ScreenManager.ScreenWidth, _borderWidth * 2)); r3.Extender.Position = new Vector2(_position.X, top); RectangleBrush r4 = view.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(ScreenManager.ScreenWidth, _borderWidth * 2)); r4.Extender.Position = new Vector2(_position.X, bottom); }
private void LoadSliderJointContent(GraphicsDevice graphicsDevice) { _sliderJointLineBrush = new LineBrush(_sliderJointLineThickness, _sliderJointColor); _sliderJointRectangleBrush = new RectangleBrush(10, 10, _sliderJointColor, _sliderJointColor); _sliderJointLineBrush.Load(graphicsDevice); _sliderJointRectangleBrush.Load(graphicsDevice); }
private void LoadRevoluteJointContent(GraphicsDevice graphicsDevice) { _revoluteJointLineBrush = new LineBrush(_revoluteJointLineThickness, _revoluteJointColor); _revoluteJointRectangleBrush = new RectangleBrush(10, 10, _revoluteJointColor, _revoluteJointColor); _revoluteJointLineBrush.Load(graphicsDevice); _revoluteJointRectangleBrush.Load(graphicsDevice); }
public RectangleBrush AddRectangleToCanvas(Body body, Vector2 size) { RectangleBrush rect = new RectangleBrush(); rect.Extender.Body = body; rect.Size = size; _simulatorCanvas.Children.Add(rect); drawingList.Add(rect); return(rect); }
public override void LoadContent() { //load texture that will visually represent the physics body _rectangleBrush = new RectangleBrush(128, 128, Color.Gold, Color.Black); _rectangleBrush.Load(ScreenManager.GraphicsDevice); //use the body factory to create the physics body _rectangleBody = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 128, 1); _rectangleBody.Position = ScreenManager.ScreenCenter; base.LoadContent(); }
public void Load(GraphicsDevice graphicsDevice, PhysicsSimulator physicsSimulator) { _brush = new RectangleBrush(_width, _height, _color, _borderColor); _brush.Load(graphicsDevice); //use the body factory to create the physics body Body = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _width, _height, _mass); Body.Position = _position; Geom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, Body, _width, _height); Geom.CollisionGroup = 100; Geom.CollisionGroup = _collisionGroup; Geom.FrictionCoefficient = .2f; }
public void Load(GraphicsDevice graphicsDevice, PhysicsSimulator physicsSimulator) { _platformBrush = new RectangleBrush(_width, _height, _color, _borderColor); _platformBrush.Load(graphicsDevice); //use the body factory to create the physics body _platformBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _width, _height, 1); _platformBody.IsStatic = true; _platformBody.Position = _position; _platformGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _platformBody, _width, _height); _platformGeom.CollisionGroup = 100; _platformGeom.CollisionGroup = _collisionGroup; _platformGeom.FrictionCoefficient = 1; }
public void Dispose() { if (RectanglePen != null) { RectanglePen.Dispose(); } if (RectangleBrush != null) { RectangleBrush.Dispose(); } if (TextFont != null) { TextFont.Dispose(); } if (TextBrush != null) { TextBrush.Dispose(); } if (TextShadowBrush != null) { TextShadowBrush.Dispose(); } }
static void DrawPrimitives(IEnumerable <Drawable> primitives, Cairo.Context grw) { foreach (var p in primitives) { var l = p as LineElement; if (l != null) { LineBrush.Draw(grw, l); } var a = p as ArcElement; if (a != null) { ArcBrush.Draw(grw, a); } var a3 = p as Arc3PointsElement; if (a3 != null) { Arc3PointsBrush.Draw(grw, a3); } var t = p as TextElement; if (t != null) { TextBrush.Draw(grw, t); } var r = p as RectangleElement; if (r != null) { RectangleBrush.Draw(grw, r); } } }
public void LoadObstacles() { _obstacleBrush = new RectangleBrush(128, 32, Color.White, Color.Black); _obstacleBrush.Load(ScreenManager.GraphicsDevice); _obstacleBodies = new Body[5]; _obstacleGeoms = new Geom[5]; for (int i = 0; i < _obstacleBodies.Length; i++) { _obstacleBodies[i] = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 32, 1); _obstacleBodies[i].IsStatic = true; if (i == 0) { _obstacleGeoms[i] = GeomFactory.Instance.CreateRectangleGeom(PhysicsSimulator, _obstacleBodies[i], 128, 32); _obstacleGeoms[i].RestitutionCoefficient = .2f; _obstacleGeoms[i].FrictionCoefficient = .2f; } else { _obstacleGeoms[i] = GeomFactory.Instance.CreateGeom(PhysicsSimulator, _obstacleBodies[i], _obstacleGeoms[0]); } } _obstacleBodies[0].Position = ScreenManager.ScreenCenter + new Vector2(-50, -200); _obstacleBodies[1].Position = ScreenManager.ScreenCenter + new Vector2(150, -100); _obstacleBodies[2].Position = ScreenManager.ScreenCenter + new Vector2(100, 50); _obstacleBodies[3].Position = ScreenManager.ScreenCenter + new Vector2(-100, 200); _obstacleBodies[4].Position = ScreenManager.ScreenCenter + new Vector2(-170, 0); }