Beispiel #1
0
 public SharedData(PhysicsObjectsFactory objectsFactory, GameplayData gameplayData, PhysicsData physicsData, RenderData renderData, KeyState keys)
 {
     ObjectsFactory = objectsFactory;
     GameplayData   = gameplayData;
     PhysicsData    = physicsData;
     RenderData     = renderData;
     Keys           = keys;
 }
Beispiel #2
0
        private static void AddMesh(PhysicsObjectsFactory factory)
        {
            var triangles = new Triangle[]
            {
                new (new Vector2(0, 0), new Vector2(1, 2), new Vector2(3, 1)),
                new (new Vector2(1, 2), new Vector2(5, 2), new Vector2(5, 0)),
                new (new Vector2(5, 0), new Vector2(5, 2), new Vector2(8, 1)),
            };
            var mesh = Mesh.CreateMesh(triangles);

            var bodyPosition = new Vector2(5.5f - 3.7894738f, 5 - 1.140351f);

            factory.CreateMesh(mesh, 10f, 0.4f, bodyPosition, 0f);
        }
Beispiel #3
0
        private static void TestStrings(PhysicsObjectsFactory factory)
        {
            var ballPosition1    = new Vector2(11, 9);
            var ballPosition2    = new Vector2(11, 8);
            var attachmentPoint1 = new Vector2(9, 7);
            var attachmentPoint2 = new Vector2(13, 7);

            var testBall  = CreateMediumBall(ballPosition1, factory);
            var testBall2 = CreateMediumBall(ballPosition2, factory);

            factory.AttachSpring(testBall, Vector2.Zero, attachmentPoint1, (attachmentPoint1 - ballPosition1).Length(), 40);
            factory.AttachSpring(testBall, Vector2.Zero, attachmentPoint2, (attachmentPoint2 - ballPosition1).Length(), 40);
            factory.AttachSpring(testBall2, testBall, Vector2.Zero, Vector2.Zero, (ballPosition2 - ballPosition1).Length(), 40);
        }
Beispiel #4
0
        private static void CreateWalls(PhysicsObjectsFactory factory)
        {
            const float left   = 0.5f;
            const float right  = 14.5f;
            const float top    = 11.5f;
            const float bottom = 0.5f;

            factory.CreateSegment(new Vector2(left, bottom), new Vector2(left, top), 0.9f);
            factory.CreateSegment(new Vector2(left, top), new Vector2(right, top), 0.9f);
            factory.CreateSegment(new Vector2(right, top), new Vector2(right, bottom), 0.9f);
            factory.CreateSegment(new Vector2(right, bottom), new Vector2(left, bottom), 0.9f);

            factory.CreateAABox(new Vector2(2, 10), new Vector2(6, 11), 0.9f);
        }
Beispiel #5
0
        private static void CreateBalls(PhysicsObjectsFactory factory)
        {
            var offset = new Vector2(2, 7);

            for (var i = 0; i < 20; ++i)
            {
                for (var j = 0; j < 5; ++j)
                {
                    CreateSmallBall(offset + new Vector2(i, j) * 0.3f, factory);
                }
            }

            for (var i = 11; i < 14; ++i)
            {
                for (var j = 0; j < 2; ++j)
                {
                    CreateMediumBall(offset + new Vector2(i, j) * 0.6f, factory);
                }
            }
        }
Beispiel #6
0
 private static int CreateMediumBall(Vector2 center, PhysicsObjectsFactory factory)
 {
     return(factory.CreateCircle(center, 0.3f, 2f, 0.95f));
 }
Beispiel #7
0
 private static int CreateSmallBall(Vector2 center, PhysicsObjectsFactory factory)
 {
     return(factory.CreateCircle(center, 0.15f, 1f, 0.7f));
 }