Ejemplo n.º 1
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;
            var path = new SimplePath();

            path.Points.Add(new Vector2(0, size.y / 2));
            path.Points.Add(new Vector2(size.x / 8, size.y * 3 / 4));
            path.Points.Add(new Vector2(size.x / 2, (size.y / 2) - 50));
            path.Points.Add(new Vector2(size.x, size.y / 2));
            AddChild(path);

            const int boidsCount = 50;
            var       spawner    = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var boid = new SimpleBoid()
                    {
                        VehicleGroupList = boids,
                        Position         = pos,
                        TargetPath       = path
                    };
                    boids.Add(boid);
                    return(boid);
                }
            };

            AddChild(spawner);

            for (int i = 0; i < boidsCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Ejemplo n.º 2
0
        public override void _Ready()
        {
            const int boidsCount = 50;
            var       size       = GetViewportRect().Size;
            var       spawner    = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var boid = new LateralMovingBoid()
                    {
                        VehicleGroupList = boids,
                        Position         = pos
                    };
                    boids.Add(boid);
                    return(boid);
                }
            };

            AddChild(spawner);

            for (int i = 0; i < boidsCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Ejemplo n.º 3
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    return(new AntigravityBox()
                    {
                        BodySize = new Vector2(20, 20),
                        GlobalPosition = position
                    });
                }
            };

            AddChild(spawner);

            const int boxCount = 10;

            for (int i = 0; i < boxCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Ejemplo n.º 4
0
        public override void _Ready()
        {
            var size      = GetViewportRect().Size;
            var attractor = new PhysicsAttractor()
            {
                Position = size / 2
            };

            AddChild(attractor);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    var body = new SimpleBall()
                    {
                        GravityScale   = 0,
                        Mass           = 2,
                        GlobalPosition = position
                    };
                    body.AddToGroup("rigidbody");
                    return(body);
                }
            };

            AddChild(spawner);

            // Two initial balls
            spawner.SpawnBody(new Vector2(size.x * 0.25f, size.y * 0.25f));
            spawner.SpawnBody(new Vector2(size.x * 0.75f, size.y * 0.75f));
        }
Ejemplo n.º 5
0
        public override void _Ready()
        {
            var size     = GetViewportRect().Size;
            var windmill = new Windmill()
            {
                Position = new Vector2(size.x / 2, size.y - 100)
            };

            AddChild(windmill);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    return(new SimpleBall()
                    {
                        Mass = 0.25f,
                        Radius = 10,
                        GlobalPosition = position
                    });
                }
            };

            AddChild(spawner);
        }
Ejemplo n.º 6
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var vehicle = new RoundVehicle()
                    {
                        VehicleGroupList  = vehicles,
                        SeparationEnabled = true,
                        Position          = pos
                    };
                    vehicles.Add(vehicle);
                    return(vehicle);
                }
            };

            AddChild(spawner);

            for (int i = 0; i < vehicleCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Ejemplo n.º 7
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;
            var path = new SimplePath();

            path.Points.Add(new Vector2(size.x * 1 / 4, size.y * 1 / 4));
            path.Points.Add(new Vector2(size.x * 3 / 4, size.y * 1 / 4));
            path.Points.Add(new Vector2(size.x * 3 / 4, size.y * 3 / 4));
            path.Points.Add(new Vector2((size.x * 1 / 4) - 20, size.y * 3 / 4));
            path.Looping = true;
            AddChild(path);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var vehicle = new RandomVehicle()
                    {
                        VehicleGroupList  = vehicles,
                        Position          = pos,
                        TargetPath        = path,
                        SeparationEnabled = true
                    };
                    vehicles.Add(vehicle);
                    return(vehicle);
                }
            };

            AddChild(spawner);

            for (int i = 0; i < vehicleCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Ejemplo n.º 8
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;
            var wall = new CurveWall();

            AddChild(wall);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    return(new SimpleBall()
                    {
                        GlobalPosition = position
                    });
                }
            };

            AddChild(spawner);

            const int ballCount = 10;

            for (int i = 0; i < ballCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y / 2));
            }
        }
Ejemplo n.º 9
0
        public override void _Ready()
        {
            var       size        = GetViewportRect().Size;
            const int floorHeight = 25;
            const int offset      = 50;

            // Add left floor
            var leftFloor = new SimpleWall()
            {
                BodySize = new Vector2(size.x / 2.5f, floorHeight),
                Position = new Vector2((size.x / 2.5f / 2) + offset, size.y)
            };

            AddChild(leftFloor);

            // Add right floor
            var rightFloor = new SimpleWall()
            {
                BodySize = new Vector2(size.x / 2.5f, floorHeight),
                Position = new Vector2(size.x - (size.x / 2.5f / 2) - offset, size.y - (offset * 2))
            };

            AddChild(rightFloor);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    return(new DoubleBall()
                    {
                        Distance = 20,
                        Radius = 10,
                        RotationDegrees = MathUtils.RandRangef(0, 360),
                        GlobalPosition = position
                    });
                }
            };

            AddChild(spawner);

            const int bodyCount = 10;

            for (int i = 0; i < bodyCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(offset * 2, size.x - (offset * 2), offset * 2, size.y - (offset * 2)));
            }
        }
Ejemplo n.º 10
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;

            var wall = new SimpleWall()
            {
                BodySize = new Vector2(size.x, 50),
                Position = new Vector2(size.x / 2, size.y)
            };

            AddChild(wall);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    var           chance  = MathUtils.RandRangef(0, 3);
                    SimplePolygon polygon = null;
                    if (chance < 1)
                    {
                        polygon = new Polygon1();
                    }
                    else if (chance < 2)
                    {
                        polygon = new Polygon2();
                    }
                    else
                    {
                        polygon = new Polygon3();
                    }

                    polygon.GlobalPosition = position;
                    return(polygon);
                }
            };

            AddChild(spawner);

            const int polygonCount = 10;

            for (int i = 0; i < polygonCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Ejemplo n.º 11
0
        public override void _Ready()
        {
            var       size        = GetViewportRect().Size;
            const int floorHeight = 25;
            const int offset      = 50;

            // Add left floor
            var leftFloor = new SimpleWall()
            {
                BodySize = new Vector2(size.x / 2.5f, floorHeight),
                Position = new Vector2((size.x / 2.5f / 2) + offset, size.y)
            };

            AddChild(leftFloor);

            // Add right floor
            var rightFloor = new SimpleWall()
            {
                BodySize = new Vector2(size.x / 2.5f, floorHeight),
                Position = new Vector2(size.x - (size.x / 2.5f / 2) - offset, size.y - (offset * 2))
            };

            AddChild(rightFloor);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    return(new Polygon()
                    {
                        GlobalPosition = position
                    });
                }
            };

            AddChild(spawner);

            const int polygonCount = 10;

            for (int i = 0; i < polygonCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(offset * 2, size.x - (offset * 2), offset * 2, size.y - (offset * 2)));
            }
        }
Ejemplo n.º 12
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var vehicle = new RoundVehicle()
                    {
                        VehicleGroupList  = vehicles,
                        SeparationEnabled = true,
                        Target            = targetMover,
                        Position          = pos,

                        // Scale forces
                        SeparationForceFactor = 1.5f,
                        SeekForceFactor       = 0.5f
                    };

                    vehicles.Add(vehicle);
                    return(vehicle);
                }
            };

            AddChild(spawner);

            // Create target
            targetMover = new SimpleMover()
            {
                Position = size / 2,
                Modulate = Colors.LightBlue.WithAlpha(128)
            };
            AddChild(targetMover);

            // Create initial bodies
            for (int i = 0; i < vehicleCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Ejemplo n.º 13
0
        public override void _Ready()
        {
            var size     = GetViewportRect().Size;
            var leftWall = new SineWall()
            {
                Position = new Vector2(size.x / 4, size.y / 2),
                Length   = size.x / 2
            };

            AddChild(leftWall);

            var rightWall = new PerlinWall()
            {
                Position = new Vector2(size.x / 1.25f, size.y / 2),
                Length   = size.x / 2
            };

            AddChild(rightWall);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    return(new SimpleBall()
                    {
                        GlobalPosition = position
                    });
                }
            };

            AddChild(spawner);

            const int ballCount = 10;

            for (int i = 0; i < ballCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, (size.y / 2) - 100));
            }
        }
Ejemplo n.º 14
0
        public override void _Ready()
        {
            var size  = GetViewportRect().Size;
            var floor = new SimpleWall()
            {
                BodySize = new Vector2(size.x, 100),
                Position = new Vector2(size.x / 2, size.y)
            };

            AddChild(floor);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    return(new CollisionBall()
                    {
                        GlobalPosition = position
                    });
                }
            };

            AddChild(spawner);
        }
Ejemplo n.º 15
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;

            var wall = new C5Exercise3.WaveWall()
            {
                Length    = size.x,
                Frequency = 0.1f,
                Amplitude = 100,
                Position  = new Vector2(size.x / 2, size.y - 200)
            };

            AddChild(wall);

            var car = new Car()
            {
                Position = new Vector2(size.x / 8, size.y / 2)
            };

            AddChild(car);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (position) =>
                {
                    return(new SimpleBall()
                    {
                        Radius = 5,
                        Mass = 0.00001f,
                        GlobalPosition = position
                    });
                }
            };

            AddChild(spawner);
        }