Example #1
0
        static void Main()
        {
            using (Game = new Game()) {
                SetupInputs();
                var physicsSytem   = Game.CreatePhysicsSystem();
                var render2DSystem = Game.CreateRender2DSystem();
                var render3DSystem = Game.CreateRender3DSystem();

                var player = new Entity(Game)
                {
                    Position       = new Vector3(-100f, 0f, 0f),
                    PhysicsSystem  = physicsSytem,
                    Render2DSystem = render2DSystem,
                    Render3DSystem = render3DSystem,
                    Rotation       = new Vector3(0f, 0f, 1f)
                };
                player.AddComponent(new PlayerBehavior(0));
                var cube = new Entity(Game)
                {
                    Position       = new Vector3(0f, 0f, 0f),
                    PhysicsSystem  = physicsSytem,
                    Render3DSystem = render3DSystem,
                };
                cube.AddComponent(new CubeBehavior("models/cube"));
                var cameraEntity = new Entity(Game)
                {
                    Render2DSystem = render2DSystem,
                    Render3DSystem = render3DSystem,
                };
                var camera = new CameraComponent()
                {
                    Position      = new Vector3(-100f, 0, 100f),
                    FarPlane      = 10000000f,
                    IsPerspective = true,
                    Zoom          = 1f,
                    Target        = player,
                };
                cameraEntity.AddComponent(camera);
                cameraEntity.AddComponent(new CameraBehavior(camera, 0));
                camera.SetActive();

                render2DSystem = Game.CreateRender2DSystem();
                var counterEntity = new Entity(Game)
                {
                    Render2DSystem = render2DSystem,
                };
                counterEntity.AddComponent(new FPSCounterBehavior());
                cameraEntity = new Entity(Game)
                {
                    Position       = new Vector3(0f, 0f, 0f),
                    Render2DSystem = render2DSystem,
                };
                camera = new CameraComponent()
                {
                    FarPlane      = 10000000f,
                    IsPerspective = false,
                    Position      = new Vector3(0f, 0f, 100f),
                };
                cameraEntity.AddComponent(camera);
                camera.SetActive();

                Game.Run();
            }
        }
Example #2
0
        static void Main()
        {
            using (Game = new Game()) {
                SetupInputs();

                var render2DSystem = Game.CreateRender2DSystem();
                var render3DSystem = Game.CreateRender3DSystem();

                // Perspective scene
                var player1Entity = new Entity(Game)
                {
                    Position       = new Vector3(0f, 0f, 0f),
                    Render2DSystem = render2DSystem,
                };
                player1Entity.AddComponent(new PlayerBehavior(0));
                var player2Entity = new Entity(Game)
                {
                    Position       = new Vector3(0f, 0f, 0f),
                    Render3DSystem = render3DSystem,
                };
                player2Entity.AddComponent(new CubeBehavior("models/cube"));
                var cameraEntity = new Entity(Game)
                {
                    Position       = new Vector3(0f, 50f, 200f),
                    Render2DSystem = render2DSystem,
                    Render3DSystem = render3DSystem,
                };
                var camera = new CameraComponent()
                {
                    Position      = new Vector3(0, 0, 100f),
                    FarPlane      = 10000000f,
                    IsPerspective = true,
                    Zoom          = 1f,
                    Target        = player1Entity,
                };
                cameraEntity.AddComponent(camera);
                cameraEntity.AddComponent(new CameraBehavior(camera, 0));
                camera.SetActive();

                // Orthographic scene
                render2DSystem = Game.CreateRender2DSystem();
                var counterEntity = new Entity(Game)
                {
                    Render2DSystem = render2DSystem,
                };
                counterEntity.AddComponent(new FPSCounterBehavior());
                cameraEntity = new Entity(Game)
                {
                    Position       = new Vector3(0f, 0f, 0f),
                    Render2DSystem = render2DSystem,
                };
                camera = new CameraComponent()
                {
                    FarPlane      = 10000000f,
                    IsPerspective = false,
                    Position      = new Vector3(0f, 0f, 100f),
                };
                cameraEntity.AddComponent(camera);
                camera.SetActive();

                Game.Run();
            }
        }