Ejemplo n.º 1
0
        public async Task Run()
        {
            await Initialize();
            await Load();

            await gameLoop.Run();
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public void MainLoop()
        {
            if (_mainLoop == null)
            {
                _mainLoop = new GameLoop(_time)
                {
                    SleepMode      = SleepMode.Delay,
                    DetectSoftLock = true
                };
            }

            _uptimeStopwatch.Start();

            _mainLoop.Tick += (sender, args) => Update(args);

            _mainLoop.Update += (sender, args) =>
            {
                ServerUpTime.Set(_uptimeStopwatch.Elapsed.TotalSeconds);
            };

            // set GameLoop.Running to false to return from this function.
            _mainLoop.Run();

            _time.InSimulation = true;
            Cleanup();

            _shutdownEvent.Set();
        }
Ejemplo n.º 3
0
        public void StartGame(IGameLoop gameLoop, IGame game)
        {
            do
            {
                string key;
                do
                {
                    Console.WriteLine("1. New game");
                    Console.WriteLine("2. Quit");
                    key = Console.ReadLine();
                    Console.Clear();
                } while (key != "1" && key != "2");
                switch (key)
                {
                case "1":
                    game.Initialize();
                    gameLoop.Run(game);
                    break;

                case "2":
                    Environment.Exit(0);
                    break;
                }
                Console.Clear();
            } while (true);
        }
Ejemplo n.º 4
0
 public void Run()
 {
     Initialize();
     _stopWatch.Restart();
     _lastUpdate = _stopWatch.ElapsedMilliseconds / 1000.0f;
     _gameLoop.Run(Window, Tick);
     _stopWatch.Stop();
     Cleanup();
 }
Ejemplo n.º 5
0
        /// <inheritdoc />
        public void MainLoop()
        {
            if (_mainLoop == null)
            {
                _mainLoop = new GameLoop(_time)
                {
                    SleepMode = SleepMode.Delay
                };
            }

            _mainLoop.Tick += (sender, args) => Update(args.DeltaSeconds);

            // set GameLoop.Running to false to return from this function.
            _mainLoop.Run();
            Cleanup();
        }
Ejemplo n.º 6
0
        public void MainLoop(DisplayMode mode)
        {
            if (_mainLoop == null)
            {
                _mainLoop = new GameLoop(_gameTiming)
                {
                    SleepMode = mode == DisplayMode.Headless ? SleepMode.Delay : SleepMode.None
                };
            }

            _mainLoop.Tick += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    Tick(args);
                }
            };

            _mainLoop.Render += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    _gameTiming.CurFrame++;
                    _clyde.Render();
                }
            };
            _mainLoop.Input += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    Input(args);
                }
            };

            _mainLoop.Update += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    Update(args);
                }
            };

            // set GameLoop.Running to false to return from this function.
            _mainLoop.Run();

            Cleanup();
        }
Ejemplo n.º 7
0
        public void MainLoop(DisplayMode mode)
        {
            if (_mainLoop == null)
            {
                _mainLoop = new GameLoop(_gameTiming)
                {
                    SleepMode = mode == DisplayMode.Headless ? SleepMode.Delay : SleepMode.None
                };
            }

            _mainLoop.Tick += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    Update(args.DeltaSeconds);
                }
            };

            _mainLoop.Render += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    _gameTiming.CurFrame++;
                    _clyde.Render(new FrameEventArgs(args.DeltaSeconds));
                }
            };
            _mainLoop.Input += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    _clyde.ProcessInput(new FrameEventArgs(args.DeltaSeconds));
                }
            };

            _mainLoop.Update += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    _frameProcessMain(args.DeltaSeconds);
                }
            };

            // set GameLoop.Running to false to return from this function.
            _mainLoop.Run();
        }
Ejemplo n.º 8
0
        /// <inheritdoc />
        public void MainLoop()
        {
            if (_mainLoop == null)
            {
                _mainLoop = new GameLoop(_time)
                {
                    SleepMode      = SleepMode.Delay,
                    DetectSoftLock = true
                };
            }

            _mainLoop.Tick += (sender, args) => Update(args);

            // set GameLoop.Running to false to return from this function.
            _mainLoop.Run();

            _time.InSimulation = true;
            Cleanup();
        }
Ejemplo n.º 9
0
        public void MainLoop(GameController.DisplayMode mode)
        {
            _mainLoop = new GameLoop(_gameTiming);

            _mainLoop.Tick += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    ProcessUpdate(args);
                }
            };

            _mainLoop.Render += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    _gameTiming.CurFrame++;
                    _clyde.Render();
                }
            };
            _mainLoop.Input += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    _clyde.ProcessInput(args);
                }
            };

            _mainLoop.Update += (sender, args) =>
            {
                if (_mainLoop.Running)
                {
                    RenderFrameProcess(args);
                }
            };

            _mainLoop.Run();
        }