コード例 #1
0
        private static void Main()
        {
            var       app = new ExampleApplication();
            GameState gameState;

            try
            {
                gameState = (GameState)Serialize.ObjFromBinFile(GetGameStateFilePath());                 //try to load the game state from a file at start of program
            }
            catch
            {
                gameState = new GameState();                 //loading failed -> reset
            }

            app.GameWindow.Closing += (s, e) => gameState.ObjIntoBinFile(GetGameStateFilePath());             //save game state at end of program
            app.GameWindow.KeyDown += (s, e) => { if (e.Key == OpenTK.Input.Key.R)
                                                  {
                                                      gameState = new GameState();
                                                  }
            };                                                                                                                 //reset
            app.GameWindow.MouseDown += (s, e) =>
            {
                var coord = app.CalcNormalized(e.X, e.Y);                 //convert mouse coordinates from pixel to [0,1]²
                HandleInput(gameState, (int)e.Button, coord.X, coord.Y);
            };
            //todo student: app.Resize += (width, height) => //todo student: react on window changes (update apsect ratio of game)
            app.Render += () => Visual.DrawScreen(gameState);             //this draws the game using OpenGL
            //app.Render += () => VisualConsole.DrawScreen(gameState); //this draws the game to the console
            app.Run();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Jonnyf16/Framework
        private static void Main()
        {
            var app    = new ExampleApplication();
            var visual = new MainVisual();

            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            LoadResources(app.ResourceManager);

            Stopwatch globalTime       = new Stopwatch();
            bool      doPostProcessing = false;

            app.Render += () =>
            {
                float time = (float)globalTime.Elapsed.TotalSeconds;
                if (doPostProcessing)
                {
                    visual.DrawWithPostProcessing(time);
                }
                else
                {
                    visual.Draw();
                }
            };

            app.Update += (t) => doPostProcessing = !Keyboard.GetState()[Key.Space];
            app.Resize += visual.Resize;
            app.GameWindow.ConnectEvents(visual.OrbitCamera);

            globalTime.Start();
            app.Run();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Jonnyf16/Framework
        private static void Main()
        {
            var app    = new ExampleApplication();
            var visual = new MyVisual();

            app.Render += visual.Render;
            app.Run();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Jonnyf16/Framework
        private static void Main()
        {
            var app        = new ExampleApplication();
            var controller = new Controller();

            app.Render += controller.Render;
            app.Update += controller.Update;
            app.Run();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Jonnyf16/Framework
        private static void Main()
        {
            var app    = new ExampleApplication();
            var visual = new MyVisual(app.GameWindow.Width, app.GameWindow.Height);

            app.Render += visual.Render;
            app.Update += visual.Update;
            app.Run();
        }
コード例 #6
0
        private static void Main()
        {
            var app = new ExampleApplication();
            //run the update loop, which calls our registered callbacks
            var visual = new MyVisual();

            app.Render += visual.Render;
            app.Run();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: Jonnyf16/Framework
        private static void Main()
        {
            var app    = new ExampleApplication();
            var visual = new MainVisual();

            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            LoadResources(app.ResourceManager);
            app.Render += visual.Render;
            app.Run();
        }
コード例 #8
0
        public static void Main()
        {
            var app        = new ExampleApplication();
            var canvas     = new Canvas();
            var rasterizer = new Rasterizer(10, 10, canvas.Draw);

            app.Render += rasterizer.Render;
            //app.Render += () => Screenshot();
            app.Run();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: octogame/Zenseless
        private static void Main()
        {
            var app    = new ExampleApplication();
            var visual = new MainVisual();

            app.GameWindow.ConnectEvents(visual.OrbitCamera);
            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            LoadResources(app.ResourceManager);
            app.Render += visual.Render;
            app.Run();
        }
コード例 #10
0
        private static void Main()
        {
            var app = new ExampleApplication();
            //app.IsRecording = true;
            var visual = new MainVisual();

            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            LoadResources(app.ResourceManager);

            app.Render += visual.Render;
            app.Update += visual.Update;
            app.Run();
        }
コード例 #11
0
        private static void Main()
        {
            var app    = new ExampleApplication();
            var model  = new Model();
            var visual = new MainVisual();

            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            LoadResources(app.ResourceManager);
            app.Render += () => visual.Render(model.Bodies);
            app.Update += model.Update;
            app.GameWindow.ConnectEvents(visual.Camera);
            app.Run();
        }
コード例 #12
0
        private static void Main()
        {
            var app        = new ExampleApplication();
            var controller = new Controller();
            var logic      = new GameLogic();
            var renderer   = new Renderer();

            logic.NewPosition += (name, x, y) => renderer.UpdateSprites(name, x, y);
            LoadLevelData(LevelData.level1, logic, renderer);

            app.Resize += (width, height) => renderer.Resize(width, height);
            app.Render += () => renderer.Render(logic.Bounds);
            app.Update += (updatePeriod) => HandleInput(updatePeriod, logic);
            app.Run();
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: Jonnyf16/Framework
        private static void Main()
        {
            var app = new ExampleApplication();

            LoadResources(app.ResourceManager);
            var controller = new Controller();
            var visual     = new MainVisual();

            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            var timeSource = new Stopwatch();

            app.GameWindow.ConnectEvents(visual.OrbitCamera);
            app.Render += visual.Render;
            app.Update += (t) => visual.Update((float)timeSource.Elapsed.TotalSeconds);
            timeSource.Start();
            app.Run();
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: Jonnyf16/Framework
        private static void Main()
        {
            var app = new ExampleApplication();

            Resources.LoadResources(app.ResourceManager);
            var visual = new MainVisual();
            Action <MouseEventArgs> updateMouseState = (a) =>
            {
                var mouseState = new MouseState();
                mouseState.position  = app.CalcNormalized(a.X, a.Y);
                mouseState.drawState = GetDrawState(a.Mouse);
                visual.MouseState    = mouseState;
            };

            app.GameWindow.MouseMove += (s, a) => updateMouseState(a);
            app.GameWindow.MouseDown += (s, a) => updateMouseState(a);
            app.Render += visual.Render;
            app.Run();
        }
コード例 #15
0
        private static void Main()
        {
            var app    = new ExampleApplication();
            var visual = new MainVisual();

            app.ResourceManager.ShaderChanged += visual.ShaderChanged;
            LoadResources(app.ResourceManager);
            app.GameWindow.MouseMove += (s, e) =>
            {
                if (ButtonState.Pressed == e.Mouse.LeftButton)
                {
                    visual.CameraAzimuth   += 300 * e.XDelta / (float)app.GameWindow.Width;
                    visual.CameraElevation += 300 * e.YDelta / (float)app.GameWindow.Height;
                }
            };
            app.GameWindow.MouseWheel += (s, e) => visual.CameraDistance *= (float)Math.Pow(1.05, e.DeltaPrecise);
            app.Update += visual.Update;
            app.Render += visual.Render;
            app.Run();
        }