コード例 #1
0
ファイル: MainController.cs プロジェクト: RinorSvarca/Maze
        private static void Main()
        {
            GameTime gameTime = new GameTime();
            var      window   = new ExampleWindow();


            var orbit = window.GameWindow.CreateOrbitingCameraController(50f, 90, 0.1f, 500f);

            orbit.View.Azimuth   = 250;
            orbit.View.Elevation = 45;
            orbit.View.TargetY   = 10;
            var visual = new MainView(window.RenderContext.RenderState, window.ContentLoader);
            var model  = new MainModel();

            window.Update             += (period) => model.Update(gameTime.DeltaTime);
            window.Render             += () => visual.Render(model.Entities.ToViewEntities(), gameTime.AbsoluteTime, orbit);
            window.Resize             += visual.Resize;
            window.GameWindow.KeyDown += (sender, e) =>
            {
                if (e.Key == OpenTK.Input.Key.Space)
                {
                    visual.Bloom = !visual.Bloom;
                }
            };
            window.Run();
        }
コード例 #2
0
        private static void Main()
        {
            var window = new ExampleWindow();
            var logic  = new GameLogic();            //TODO student: load the game state
            var view   = new View(window.RenderContext.RenderState, window.ContentLoader);

            window.GameWindow.Closing += (s, e) => { /*TODO student: save the game state */ };
            window.Resize             += (w, h) => view.Resize(logic.GameState, w, h);
            window.Render             += () =>
            {
                var score = $"white:{logic.CountWhite} black:{logic.CountBlack}";
                window.GameWindow.Title = score;
                view.Render(logic.GameState);
                if (GameLogic.Result.PLAYING != logic.CurrentGameResult)
                {
                    var winner = logic.CurrentGameResult.ToString();
                    view.PrintMessage(winner);
                }
            };
            window.GameWindow.MouseDown += (s, e) =>
            {
                if (e.Button != MouseButton.Left)
                {
                    return;                                                           //only accept left mouse button
                }
                var coord   = window.GameWindow.ConvertWindowPixelCoords(e.X, e.Y);   //convert pixel coordinates to [-1,1]²
                var gridPos = view.CalcGridPos(new OpenTK.Vector2(coord.X, coord.Y)); //convert mouse coordinates into grid coordinates
                logic.Move(gridPos);                                                  //do move
            };
            window.Run();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: octogame/Zenseless
        private static void Main()
        {
            var window     = new ExampleWindow();
            var controller = new Controller();

            window.Render += controller.Render;
            window.Update += (dt) => controller.Update(dt);
            window.Run();
        }
コード例 #4
0
ファイル: Pong.cs プロジェクト: twentySeven7/Zenseless
        private static void Main()
        {
            var window = new ExampleWindow();
            var logic  = new Logic();
            var visual = new MyVisual(window.RenderContext.RenderState, window.ContentLoader);

            window.Update += (t) => Window_Update(window.Input, logic, t);
            window.Render += () => visual.Render(logic.Paddle1, logic.Paddle2, logic.Ball, logic.Player1Points, logic.Player2Points);
            window.Run();
        }
コード例 #5
0
        private static void Main()
        {
            ExampleWindow window = new ExampleWindow();
            //window.GameWindow.WindowState = OpenTK.WindowState.Fullscreen;
            var controller = new Controller();

            window.Render += controller.Render;
            window.Update += (t) => controller.Update(t * 1f);
            window.Resize += (width, height) => controller.onResize(width, height);
            window.Run();
        }
コード例 #6
0
        static void Main(string[] args)
        {
            var window = new ExampleWindow();
            //var camera = window.GameWindow.CreateOrbitingCameraController(1f, 70f, 0.01f, 20f);
            //camera.View.Elevation = 30;

            var camera = window.GameWindow.CreateFirstPersonCameraController(0.1f, new Vector3(0.4f, 0.4f, 0.95f), 70f, 0.01f, 30f);

            var visual = new MainVisual(window.RenderContext, window.ContentLoader);

            window.Render += () => visual.Render(camera);
            window.Run();
        }
コード例 #7
0
        static void Main(string[] args)
        {
            var window = new ExampleWindow();
            var camera = window.GameWindow.CreateOrbitingCameraController(1f, 70f, 0.01f, 20f);

            camera.View.Elevation = 30;

            //var movementState = window.GameWindow.AddFirstPersonCameraEvents(visual.Camera); //TODO: implement
            //window.Update += (dt) => movementState.Update(visual.Camera, dt);

            var visual = new MainVisual(window.RenderContext, window.ContentLoader);

            window.Render += () => visual.Render(camera);
            window.Run();
        }
コード例 #8
0
        static void Main(string[] args)
        {
            var window = new ExampleWindow();
            var view   = new View(window.RenderContext.RenderState, window.ContentLoader);

            window.Render               += () => view.Render();
            window.Update               += (dt) => view.Update(dt);
            window.GameWindow.KeyDown   += view.Event_KeyDown;
            window.GameWindow.KeyUp     += view.Event_KeyRelease;
            window.Resize               += (width, height) => view.Resize(width, height);
            window.GameWindow.MouseDown += (sender, e) => view.GameWindow_MouseDown(sender, e);
            window.GameWindow.MouseUp   += (sender, e) => view.GameWindow_MouseUp(sender, e);
            //window.Render += () => Draw();
            window.Run();
        }
コード例 #9
0
        private static void Main()
        {
            var       window    = new ExampleWindow();
            var       view      = new View(window.RenderContext.RenderState, window.ContentLoader);
            GameLogic gameLogic = new GameLogic(view.Renderer);

            GameTime time = new GameTime();

            window.Update += (t) => HandleInput(gameLogic, time.AbsoluteTime);
            window.Resize += view.ResizeWindow;
            window.Render += () => view.DrawScreen(GameLogic.visibleFrame, gameLogic.Points);
            window.Render += () => time.NewFrame();
            window.Render += () => window.GameWindow.Title = $"{time.FPS}FPS";

            window.Run();
        }
コード例 #10
0
        public MainController(IInitializationHandler initializationHandler)
        {
            _app = new ExampleWindow();
            _app.RemoveDefaultKeyHandler();
            _inputHandler   = initializationHandler.InitializeInputHandler((GameWindow)_app.GameWindow);
            _stateHandler   = initializationHandler.InitializeStateHandler();
            _modelRegistry  = initializationHandler.InitalizeModelRegistry();
            _viewRegistry   = initializationHandler.InitializeViewRegistry();
            _inactiveModels = new List <IModel>();
            SetModelViewInstances(initializationHandler.InitialState);

            _timeSource = new Stopwatch();

            _app.Update += Update;
            _app.Render += Render;
            _app.Resize += Resize;

            _timeSource.Start();
            _app.Run();
        }
コード例 #11
0
        private static void Main()
        {
            GameTime gameTime = new GameTime();
            var      window   = new ExampleWindow();


            var orbit = window.GameWindow.CreateOrbitingCameraController(15f, 90, 0.1f, 500f);

            orbit.View.Azimuth   = 250;
            orbit.View.Elevation = 40;
            orbit.View.TargetY   = 10;

            Voronoi voronoi = new Voronoi(30, 30, new Vector3(10, 5, 10));

            var additionalMeshes = new Dictionary <Shared.Enums.EntityType, Tuple <DefaultMesh, Vector4> >();

            additionalMeshes.Add(Shared.Enums.EntityType.Voronoi, Tuple.Create(voronoi.Mesh, new Vector4(.1f, 1, 0.5f, 0)));

            var visual = new MainView(window.RenderContext.RenderState, window.ContentLoader, additionalMeshes);
            var model  = new MainModel();

            foreach (var key in voronoi.Crystals.Keys)
            {
                foreach (var crystal in voronoi.Crystals[key])
                {
                    model.AddEntity(key, crystal.Position, Vector3.UnitY * crystal.RotationFactor, crystal.ScaleFactor);
                }
            }

            window.Update             += (period) => model.Update(gameTime.DeltaTime);
            window.Render             += () => visual.Render(model.Entities.ToViewEntities(), gameTime.AbsoluteTime, orbit);
            window.Resize             += visual.Resize;
            window.GameWindow.KeyDown += (sender, e) =>
            {
                if (e.Key == OpenTK.Input.Key.Space)
                {
                    visual.Bloom = !visual.Bloom;
                }
            };
            window.Run();
        }
コード例 #12
0
        private static void Main()
        {
            using (var window = new ExampleWindow())
            {
                var model = new Model();
                var view  = new View(window.ContentLoader);
                var sound = new Sound(window.ContentLoader);
                model.OnShoot        += (sender, args) => { sound.Shoot(); };
                model.OnEnemyDestroy += (sender, args) => { sound.DestroyEnemy(); };
                model.OnLost         += (sender, args) => { sound.Lost(); };
                sound.Background();

                window.Render += () =>
                {
                    view.Clear();
                    view.DrawEnemies(model.Enemies);
                    view.DrawBullets(model.Bullets);
                    view.DrawPlayer(model.Player);
                };
                window.Update += (dt) => Update(model);
                window.Run();
            }
        }