public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, ScreenManager, Camera); _ramps = new List<Body>(); _ramps.Add(BodyFactory.CreateEdge(World, new Vector2(-20f, -11.2f), new Vector2(10f, -3.8f))); _ramps.Add(BodyFactory.CreateEdge(World, new Vector2(12f, -5.6f), new Vector2(12f, -3.2f))); _ramps.Add(BodyFactory.CreateEdge(World, new Vector2(-10f, 4.4f), new Vector2(20f, -1.4f))); _ramps.Add(BodyFactory.CreateEdge(World, new Vector2(-12f, 2.6f), new Vector2(-12f, 5f))); _ramps.Add(BodyFactory.CreateEdge(World, new Vector2(-20f, 6.8f), new Vector2(10f, 11.5f))); float[] friction = { 0.75f, 0.45f, 0.28f, 0.17f, 0.0f }; for (int i = 0; i < 5; ++i) { _rectangle[i] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _rectangle[i].BodyType = BodyType.Dynamic; _rectangle[i].Position = new Vector2(-18f + 5.2f * i, -13.0f + 1.282f * i); _rectangle[i].Friction = friction[i]; } // Create sprite based on body _rectangleSprite = new Sprite(ScreenManager.Assets.TextureFromShape(_rectangle[0].FixtureList[0].Shape, MaterialType.Squares, Color.ForestGreen, 0.8f)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, Lines, Framework.GraphicsDevice); for (int i = 0; i < 3; i++) { _breakableCookie[i] = Framework.Content.Load<BodyContainer>("Pipeline/FarseerBreakableBody")["Cookie"].CreateBreakable(World); _breakableCookie[i].Strength = 120f; _breakableCookie[i].MainBody.Position = new Vector2(-20.33f + 15f * i, -5.33f); } _breakableSprite = new List<Sprite>(); List<Texture2D> textures = ContentWrapper.BreakableTextureFragments(_breakableCookie[0], "Cookie"); for (int i = 0; i < _breakableCookie[0].Parts.Count; i++) { AABB bounds; Transform transform; _breakableCookie[0].Parts[i].Body.GetTransform(out transform); _breakableCookie[0].Parts[i].Shape.ComputeAABB(out bounds, ref transform, 0); Vector2 origin = ConvertUnits.ToDisplayUnits(_breakableCookie[0].Parts[i].Body.Position - bounds.LowerBound); _breakableSprite.Add(new Sprite(textures[i], origin)); } _completeSprite = new Sprite(ContentWrapper.GetTexture("Cookie"), Vector2.Zero); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, Lines, Framework.GraphicsDevice); Vertices rectangle1 = PolygonTools.CreateRectangle(2f, 2f); Vertices rectangle2 = PolygonTools.CreateRectangle(2f, 2f); Vector2 translation = new Vector2(-2f, 0f); rectangle1.Translate(ref translation); translation = new Vector2(2f, 0f); rectangle2.Translate(ref translation); List<Vertices> vertices = new List<Vertices>(2); vertices.Add(rectangle1); vertices.Add(rectangle2); _rectangles = BodyFactory.CreateCompoundPolygon(World, vertices, 1f); _rectangles.BodyType = BodyType.Dynamic; SetUserAgent(_rectangles, 200f, 200f); // create sprite based on rectangle fixture _rectangleSprite = new Sprite(ContentWrapper.PolygonTexture(rectangle1, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f)); _offset = new Vector2(ConvertUnits.ToDisplayUnits(2f), 0f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, ScreenManager, Camera); Vertices rect1 = PolygonTools.CreateRectangle(2f, 2f); Vertices rect2 = PolygonTools.CreateRectangle(2f, 2f); Vector2 trans = new Vector2(-2f, 0f); rect1.Translate(ref trans); trans = new Vector2(2f, 0f); rect2.Translate(ref trans); List<Vertices> vertices = new List<Vertices>(2); vertices.Add(rect1); vertices.Add(rect2); _rectangles = BodyFactory.CreateCompoundPolygon(World, vertices, 1f); _rectangles.BodyType = BodyType.Dynamic; SetUserAgent(_rectangles, 200f, 200f); // create sprite based on rectangle fixture _rectangleSprite = new Sprite(ScreenManager.Assets.TextureFromVertices(rect1, MaterialType.Squares, Color.Orange, 1f)); _offset = new Vector2(ConvertUnits.ToDisplayUnits(2f), 0f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _agent = new Agent(World, new Vector2(-6.9f, -11f)); // Obstacles for (int i = 0; i < 5; i++) { _obstacles[i] = BodyFactory.CreateRectangle(World, 5f, 1f, 1f); _obstacles[i].IsStatic = true; _obstacles[i].Restitution = 0.2f; _obstacles[i].Friction = 0.2f; } _obstacles[0].Position = new Vector2(-5f, 9f); _obstacles[1].Position = new Vector2(15f, 6f); _obstacles[2].Position = new Vector2(10f, -3f); _obstacles[3].Position = new Vector2(-10f, -9f); _obstacles[4].Position = new Vector2(-17f, 0f); // create sprite based on body _obstacle = new Sprite(ContentWrapper.TextureFromShape(_obstacles[0].FixtureList[0].Shape, "Stripe", ContentWrapper.Gold, ContentWrapper.Black, ContentWrapper.Black, 1.5f)); SetUserAgent(_agent.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _ragdoll = new Ragdoll(World, new Vector2(-20f, -10f)); _obstacles = new Body[9]; Vector2 stairStart = new Vector2(-23f, 0f); Vector2 stairDelta = new Vector2(2.5f, 1.65f); for (int i = 0; i < 9; i++) { _obstacles[i] = BodyFactory.CreateRectangle(World, 5f, 1.5f, 1f, stairStart + stairDelta * i); _obstacles[i].IsStatic = true; } // create sprite based on body _obstacle = new Sprite(ContentWrapper.TextureFromShape(_obstacles[0].FixtureList[0].Shape, "Stripe", ContentWrapper.Red, ContentWrapper.Black, ContentWrapper.Black, 1.5f)); SetUserAgent(_ragdoll.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _ramps = new Body(World); FixtureFactory.AttachEdge(new Vector2(-20f, -11.2f), new Vector2(10f, -3.8f), _ramps); FixtureFactory.AttachEdge(new Vector2(12f, -5.6f), new Vector2(12f, -3.2f), _ramps); FixtureFactory.AttachEdge(new Vector2(-10f, 4.4f), new Vector2(20f, -1.4f), _ramps); FixtureFactory.AttachEdge(new Vector2(-12f, 2.6f), new Vector2(-12f, 5f), _ramps); FixtureFactory.AttachEdge(new Vector2(-20f, 6.8f), new Vector2(10f, 11.5f), _ramps); float[] friction = { 0.75f, 0.45f, 0.28f, 0.17f, 0.0f }; for (int i = 0; i < 5; i++) { _rectangle[i] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _rectangle[i].BodyType = BodyType.Dynamic; _rectangle[i].Position = new Vector2(-18f + 5.2f * i, -13.0f + 1.282f * i); _rectangle[i].Friction = friction[i]; } // create sprite based on body _rectangleSprite = new Sprite(ContentWrapper.TextureFromShape(_rectangle[0].FixtureList[0].Shape, "Square", ContentWrapper.Green, ContentWrapper.Lime, ContentWrapper.Black, 1f)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _obstacles = new Body(World); FixtureFactory.AttachEdge(new Vector2(-16f, -1f), new Vector2(-14f, 1f), _obstacles); FixtureFactory.AttachEdge(new Vector2(-14f, 1f), new Vector2(-12f, -1f), _obstacles); FixtureFactory.AttachEdge(new Vector2(14f, -1f), new Vector2(12f, 5f), _obstacles); FixtureFactory.AttachEdge(new Vector2(14f, -1f), new Vector2(16f, 5f), _obstacles); _angleBody[0] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[0].BodyType = BodyType.Dynamic; _angleBody[0].Friction = 0.7f; _angleBody[0].Position = new Vector2(-15f, -5f); _angleBody[1] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[1].BodyType = BodyType.Dynamic; _angleBody[1].Friction = 0.7f; _angleBody[1].Position = new Vector2(-18f, 5f); _angleBody[2] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[2].BodyType = BodyType.Dynamic; _angleBody[2].Friction = 0.7f; _angleBody[2].Position = new Vector2(-10f, 5f); World.AddJoint(new AngleJoint(_angleBody[0], _angleBody[1])); World.AddJoint(new AngleJoint(_angleBody[0], _angleBody[2])); _distanceBody[0] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[0].BodyType = BodyType.Dynamic; _distanceBody[0].Friction = 0.7f; _distanceBody[0].Position = new Vector2(11.5f, -4f); _distanceBody[1] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[1].BodyType = BodyType.Dynamic; _distanceBody[1].Friction = 0.7f; _distanceBody[1].Position = new Vector2(16.5f, -4f); _distanceBody[2] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[2].BodyType = BodyType.Dynamic; _distanceBody[2].Friction = 0.7f; _distanceBody[2].Position = new Vector2(11.5f, -6f); _distanceBody[3] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[3].BodyType = BodyType.Dynamic; _distanceBody[3].Friction = 0.7f; _distanceBody[3].Position = new Vector2(16.5f, -6f); DistanceJoint softDistance = new DistanceJoint(_distanceBody[0], _distanceBody[1], Vector2.Zero, Vector2.Zero, false); softDistance.DampingRatio = 0.3f; softDistance.Frequency = 5f; World.AddJoint(softDistance); World.AddJoint(new DistanceJoint(_distanceBody[2], _distanceBody[3], Vector2.Zero, Vector2.Zero, false)); // create sprites based on bodies _angleCube = new Sprite(ContentWrapper.TextureFromShape(_angleBody[0].FixtureList[0].Shape, "Square", ContentWrapper.Gold, ContentWrapper.Orange, ContentWrapper.Grey, 1f)); _distanceCube = new Sprite(ContentWrapper.TextureFromShape(_distanceBody[0].FixtureList[0].Shape, "Stripe", ContentWrapper.Red, ContentWrapper.Blue, ContentWrapper.Grey, 4f)); }
public override void LoadContent() { base.LoadContent(); DebugView.AppendFlags(DebugViewFlags.Shape); World.Gravity = Vector2.Zero; _border = new Border(World, ScreenManager, Camera); Texture2D alphabet = ScreenManager.Content.Load<Texture2D>("Samples/alphabet"); uint[] data = new uint[alphabet.Width * alphabet.Height]; alphabet.GetData(data); List<Vertices> list = PolygonTools.CreatePolygon(data, alphabet.Width, 3.5f, 20, true, true); float yOffset = -5f; float xOffset = -14f; for (int i = 0; i < list.Count; i++) { if (i == 9) { yOffset = 0f; xOffset = -14f; } if (i == 18) { yOffset = 5f; xOffset = -12.25f; } Vertices polygon = list[i]; Vector2 centroid = -polygon.GetCentroid(); polygon.Translate(ref centroid); polygon = SimplifyTools.CollinearSimplify(polygon); polygon = SimplifyTools.ReduceByDistance(polygon, 4); List<Vertices> triangulated = Triangulate.ConvexPartition(polygon, TriangulationAlgorithm.Bayazit); #if WINDOWS_PHONE const float scale = 0.6f; #else const float scale = 1f; #endif Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * scale; foreach (Vertices vertices in triangulated) { vertices.Scale(ref vertScale); } BreakableBody breakableBody = new BreakableBody(World, triangulated, 1); breakableBody.MainBody.Position = new Vector2(xOffset, yOffset); breakableBody.Strength = 100; World.AddBreakableBody(breakableBody); xOffset += 3.5f; } }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0, 9.82f); _border = new Border(World, Lines, Framework.GraphicsDevice); _webOfGoo = new WebOfGoo(World, Vector2.Zero, ConvertUnits.ToSimUnits(12), 5, 12); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, ScreenManager, Camera); //load texture that will represent the physics body _polygonTexture = ScreenManager.Content.Load<Texture2D>("Samples/object"); //Create an array to hold the data from the texture uint[] data = new uint[_polygonTexture.Width * _polygonTexture.Height]; //Transfer the texture data to the array _polygonTexture.GetData(data); //Find the vertices that makes up the outline of the shape in the texture Vertices textureVertices = PolygonTools.CreatePolygon(data, _polygonTexture.Width, false); //The tool return vertices as they were found in the texture. //We need to find the real center (centroid) of the vertices for 2 reasons: //1. To translate the vertices so the polygon is centered around the centroid. Vector2 centroid = -textureVertices.GetCentroid(); textureVertices.Translate(ref centroid); //2. To draw the texture the correct place. _origin = -centroid; //We simplify the vertices found in the texture. textureVertices = SimplifyTools.ReduceByDistance(textureVertices, 4f); //Since it is a concave polygon, we need to partition it into several smaller convex polygons List<Vertices> list = Triangulate.ConvexPartition(textureVertices, TriangulationAlgorithm.Bayazit); //Adjust the scale of the object for WP7's lower resolution #if WINDOWS_PHONE _scale = 0.6f; #else _scale = 1f; #endif //scale the vertices from graphics space to sim space Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * _scale; foreach (Vertices vertices in list) { vertices.Scale(ref vertScale); } //Create a single body with multiple fixtures _compound = BodyFactory.CreateCompoundPolygon(World, list, 1f, BodyType.Dynamic); _compound.BodyType = BodyType.Dynamic; }
public override void LoadContent() { base.LoadContent(); HasCursor = false; World.Gravity = new Vector2(0, 9.82f); _border = new Border(World, ScreenManager, Camera); _walker = new TheoJansenWalker(World, ScreenManager, Camera, Vector2.Zero); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0, 9.82f); _border = new Border(World, Lines, Framework.GraphicsDevice); // Bridge // We make a path using 2 points. Path bridgePath = new Path(); bridgePath.Add(new Vector2(-15, 5)); bridgePath.Add(new Vector2(15, 5)); bridgePath.Closed = false; Vertices box = PolygonTools.CreateRectangle(0.125f, 0.5f); PolygonShape shape = new PolygonShape(box, 20); _bridgeBodies = PathManager.EvenlyDistributeShapesAlongPath(World, bridgePath, shape, BodyType.Dynamic, 29); // Attach the first and last fixtures to the world Body anchor = new Body(World, Vector2.Zero); anchor.BodyType = BodyType.Static; World.AddJoint(new RevoluteJoint(_bridgeBodies[0], anchor, _bridgeBodies[0].Position - new Vector2(0.5f, 0f), true)); World.AddJoint(new RevoluteJoint(_bridgeBodies[_bridgeBodies.Count - 1], anchor, _bridgeBodies[_bridgeBodies.Count - 1].Position + new Vector2(0.5f, 0f), true)); PathManager.AttachBodiesWithRevoluteJoint(World, _bridgeBodies, new Vector2(0f, -0.5f), new Vector2(0f, 0.5f), false, true); // Soft body // We make a rectangular path. Path rectanglePath = new Path(); rectanglePath.Add(new Vector2(-6, -11)); rectanglePath.Add(new Vector2(-6, 1)); rectanglePath.Add(new Vector2(6, 1)); rectanglePath.Add(new Vector2(6, -11)); rectanglePath.Closed = true; // Creating two shapes. A circle to form the circle and a rectangle to stabilize the soft body. Shape[] shapes = new Shape[2]; shapes[0] = new PolygonShape(PolygonTools.CreateRectangle(0.5f, 0.5f, new Vector2(-0.1f, 0f), 0f), 1f); shapes[1] = new CircleShape(0.5f, 1f); // We distribute the shapes in the rectangular path. _softBodies = PathManager.EvenlyDistributeShapesAlongPath(World, rectanglePath, shapes, BodyType.Dynamic, 30); // Attach the bodies together with revolute joints. The rectangular form will converge to a circular form. PathManager.AttachBodiesWithRevoluteJoint(World, _softBodies, new Vector2(0f, -0.5f), new Vector2(0f, 0.5f), true, true); // GFX _bridgeBox = new Sprite(ContentWrapper.TextureFromShape(shape, ContentWrapper.Orange, ContentWrapper.Brown)); _softBodyBox = new Sprite(ContentWrapper.TextureFromShape(shapes[0], ContentWrapper.Green, ContentWrapper.Black)); _softBodyBox.Origin += new Vector2(ConvertUnits.ToDisplayUnits(0.1f), 0f); _softBodyCircle = new Sprite(ContentWrapper.TextureFromShape(shapes[1], ContentWrapper.Lime, ContentWrapper.Grey)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, ScreenManager, Camera); _ragdoll = new Ragdoll(World, ScreenManager, Vector2.Zero); LoadObstacles(); SetUserAgent(_ragdoll.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, ScreenManager, Camera); _agent = new Agent(World, ScreenManager, new Vector2(5f, -10f)); _pyramid = new Pyramid(World, ScreenManager, new Vector2(0f, 15f), PyramidBaseBodyCount, 1f); SetUserAgent(_agent.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0, 9.82f); _border = new Border(World, ScreenManager, Camera); /* Bridge */ //We make a path using 2 points. Path bridgePath = new Path(); bridgePath.Add(new Vector2(-15, 5)); bridgePath.Add(new Vector2(15, 5)); bridgePath.Closed = false; Vertices box = PolygonTools.CreateRectangle(0.125f, 0.5f); PolygonShape shape = new PolygonShape(box, 20); _bridgeBodies = PathManager.EvenlyDistributeShapesAlongPath(World, bridgePath, shape, BodyType.Dynamic, 29); _bridgeBox = new Sprite(ScreenManager.Assets.TextureFromShape(shape, MaterialType.Dots, Color.SandyBrown, 1f)); //Attach the first and last fixtures to the world JointFactory.CreateRevoluteJoint(World, HiddenBody, _bridgeBodies[0], new Vector2(0f, -0.5f)); JointFactory.CreateRevoluteJoint(World, HiddenBody, _bridgeBodies[_bridgeBodies.Count - 1], new Vector2(0, 0.5f)); PathManager.AttachBodiesWithRevoluteJoint(World, _bridgeBodies, new Vector2(0f, -0.5f), new Vector2(0f, 0.5f), false, true); /* Soft body */ //We make a rectangular path. Path rectanglePath = new Path(); rectanglePath.Add(new Vector2(-6, -11)); rectanglePath.Add(new Vector2(-6, 1)); rectanglePath.Add(new Vector2(6, 1)); rectanglePath.Add(new Vector2(6, -11)); rectanglePath.Closed = true; //Creating two shapes. A circle to form the circle and a rectangle to stabilize the soft body. List<Shape> shapes = new List<Shape>(2); shapes.Add(new PolygonShape(PolygonTools.CreateRectangle(0.5f, 0.5f, new Vector2(-0.1f, 0f), 0f), 1f)); shapes.Add(new CircleShape(0.5f, 1f)); //We distribute the shapes in the rectangular path. _softBodies = PathManager.EvenlyDistributeShapesAlongPath(World, rectanglePath, shapes, BodyType.Dynamic, 30); _softBodyBox = new Sprite(ScreenManager.Assets.TextureFromShape(shapes[0], MaterialType.Blank, Color.Silver * 0.8f, 1f)); _softBodyBox.Origin += new Vector2(ConvertUnits.ToDisplayUnits(0.1f), 0f); _softBodyCircle = new Sprite(ScreenManager.Assets.TextureFromShape(shapes[1], MaterialType.Waves, Color.Silver, 1f)); //Attach the bodies together with revolute joints. The rectangular form will converge to a circular form. PathManager.AttachBodiesWithRevoluteJoint(World, _softBodies, new Vector2(0f, -0.5f), new Vector2(0f, 0.5f), true, true); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, ScreenManager, Camera); _agent = new Agent(World, ScreenManager, new Vector2(-6.9f, -11f)); LoadObstacles(); SetUserAgent(_agent.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _agent = new Agent(World, new Vector2(5f, -10f)); _pyramid = new Pyramid(World, new Vector2(0f, 15f), PyramidBaseBodyCount, 1f); SetUserAgent(_agent.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, ScreenManager, Camera); //Cat1=Circles, Cat2=Rectangles, Cat3=Gears, Cat4=Stars _agent = new Agent(World, ScreenManager, Vector2.Zero); //Collide with all but stars _agent.CollisionCategories = Category.All & ~Category.Cat4; _agent.CollidesWith = Category.All & ~Category.Cat4; Vector2 startPosition = new Vector2(-20f, -11f); Vector2 endPosition = new Vector2(20, -11f); _circles = new Objects(World, ScreenManager, startPosition, endPosition, 15, 0.6f, ObjectType.Circle); //Collide with itself only _circles.CollisionCategories = Category.Cat1; _circles.CollidesWith = Category.Cat1; startPosition = new Vector2(-20, 11f); endPosition = new Vector2(20, 11f); _rectangles = new Objects(World, ScreenManager, startPosition, endPosition, 15, 1.2f, ObjectType.Rectangle); //Collides with itself only _rectangles.CollisionCategories = Category.Cat2; _rectangles.CollidesWith = Category.Cat2; startPosition = new Vector2(-20, 7); endPosition = new Vector2(-20, -7); _gears = new Objects(World, ScreenManager, startPosition, endPosition, 5, 0.6f, ObjectType.Gear); //Collides with stars _gears.CollisionCategories = Category.Cat3; _gears.CollidesWith = Category.Cat3 | Category.Cat4; startPosition = new Vector2(20, 7); endPosition = new Vector2(20, -7); _stars = new Objects(World, ScreenManager, startPosition, endPosition, 5, 0.6f, ObjectType.Star); //Collides with gears _stars.CollisionCategories = Category.Cat4; _stars.CollidesWith = Category.Cat3 | Category.Cat4; SetUserAgent(_agent.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0, 9.82f); _border = new Border(World, ScreenManager, Camera); #if WINDOWS || XBOX _spiderweb = new Spiderweb(World, HiddenBody, Vector2.Zero, ConvertUnits.ToSimUnits(12), 5, 12); #elif WINDOWS_PHONE _spiderweb = new Spiderweb(World, HiddenBody, Vector2.Zero, ConvertUnits.ToSimUnits(8), 5, 12); #endif _spiderweb.LoadContent(ScreenManager.Content); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, Lines, Framework.GraphicsDevice); _rectangle = BodyFactory.CreateRectangle(World, 5f, 5f, 1f); _rectangle.BodyType = BodyType.Dynamic; SetUserAgent(_rectangle, 100f, 100f); // create sprite based on body _rectangleSprite = new Sprite(ContentWrapper.TextureFromShape(_rectangle.FixtureList[0].Shape, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, Lines, Framework.GraphicsDevice); List<Vertices> tracedObject = Framework.Content.Load<List<Vertices>>("Pipeline/Object"); // Create a single body with multiple fixtures _compound = BodyFactory.CreateCompoundPolygon(World, tracedObject, 1f, Vector2.Zero, 0, BodyType.Dynamic); SetUserAgent(_compound, 200f, 200f); _objectSprite = new Sprite(ContentWrapper.GetTexture("Logo"), ContentWrapper.CalculateOrigin(_compound)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, ScreenManager, Camera); _rectangle = BodyFactory.CreateRectangle(World, 5f, 5f, 1f); _rectangle.BodyType = BodyType.Dynamic; SetUserAgent(_rectangle, 100f, 100f); // create sprite based on body _rectangleSprite = new Sprite(ScreenManager.Assets.TextureFromShape(_rectangle.FixtureList[0].Shape, MaterialType.Squares, Color.Orange, 1f)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, ScreenManager, Camera); _agent = new Agent(World, ScreenManager, new Vector2(0f, 10f)); _spiders = new Spider[8]; for (int i = 0; i < _spiders.Length; i++) { _spiders[i] = new Spider(World, ScreenManager, new Vector2(0f, 8f - (i + 1) * 2f)); } SetUserAgent(_agent.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _agent = new Agent(World, new Vector2(0f, 10f)); _spiders = new JumpySpider[8]; for (int i = 0; i < _spiders.Length; i++) { _spiders[i] = new JumpySpider(World, new Vector2(0f, 8f - (i + 1) * 2f)); } SetUserAgent(_agent.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = (gravityEnd - gravityBegin); _border = new Border(World, ScreenManager, Camera); _rectangle = BodyFactory.CreateRectangle(World, 5f, 5f, 1f); _rectangle.BodyType = BodyType.Dynamic; Camera.TrackingBody = _rectangle; Camera.EnablePositionTracking = true; SetUserAgent(_rectangle, 100f, 100f); // create sprite based on body _rectangleSprite = new Sprite(ScreenManager.Assets.TextureFromShape(_rectangle.FixtureList[0].Shape, MaterialType.Squares, Color.White, 1f)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 10f); _border = new Border(World, Lines, Framework.GraphicsDevice); _farseerBody = Framework.Content.Load<BodyContainer>("Pipeline/FarseerBody"); _heartBody = _farseerBody["Heart"].Create(World); _heart = new Sprite(ContentWrapper.GetTexture("Heart"), ContentWrapper.CalculateOrigin(_heartBody)); _clubBody = _farseerBody["Club"].Create(World); _club = new Sprite(ContentWrapper.GetTexture("Club"), ContentWrapper.CalculateOrigin(_clubBody)); _spadeBody = _farseerBody["Spade"].Create(World); _spade = new Sprite(ContentWrapper.GetTexture("Spade"), ContentWrapper.CalculateOrigin(_spadeBody)); _diamondBody = _farseerBody["Diamond"].Create(World); _diamond = new Sprite(ContentWrapper.GetTexture("Diamond"), ContentWrapper.CalculateOrigin(_diamondBody)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, ScreenManager, Camera); Vector2 position = new Vector2(-15f, -8f); float restitution = 0f; for (int i = 0; i < 6; ++i) { _circle[i] = BodyFactory.CreateCircle(World, 1.5f, 1f, position); _circle[i].BodyType = BodyType.Dynamic; _circle[i].Restitution = restitution; position.X += 6f; restitution += 0.2f; } // create sprite based on body _circleSprite = new Sprite(ScreenManager.Assets.TextureFromShape(_circle[0].FixtureList[0].Shape, MaterialType.Waves, Color.Brown, 1f)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); Vector2 position = new Vector2(-15f, -8f); float restitution = 0f; for (int i = 0; i < 6; ++i) { _circle[i] = BodyFactory.CreateCircle(World, 1.5f, 1f, position); _circle[i].BodyType = BodyType.Dynamic; _circle[i].Restitution = restitution; position.X += 6f; restitution += 0.2f; } // create sprite based on body _circleSprite = new Sprite(ContentWrapper.TextureFromShape(_circle[0].FixtureList[0].Shape, "Square", ContentWrapper.Green, ContentWrapper.Lime, ContentWrapper.Black, 1f)); }
public override void LoadContent() { base.LoadContent(); HasCursor = false; World.Gravity = new Vector2(0, 9.82f); _border = new Border(World, Lines, Framework.GraphicsDevice); CircleShape shape = new CircleShape(0.25f, 1); _grain = new Sprite(ContentWrapper.CircleTexture(0.25f, ContentWrapper.Gold, ContentWrapper.Grey)); _circles = new Body[48]; for (int i = 0; i < 48; i++) { _circles[i] = BodyFactory.CreateBody(World); _circles[i].BodyType = BodyType.Dynamic; _circles[i].Position = new Vector2(-24f + 1f * i, 10f); _circles[i].CreateFixture(shape); } _walker = new TheoJansenWalker(World, Vector2.Zero); }