コード例 #1
0
ファイル: Game.cs プロジェクト: Jespyr/Invasion-Grid
        public void Run()
        {
            //initialization
            window.SetActive();

            Clock clock = new Clock();
            clock.Restart();
            //loop
            while(window.IsOpen)
            {
                //make sure windows events are handled
                window.DispatchEvents();

                //handle logic here
                Time elapsed = clock.Restart(); //elapsed is the amount of time elapsed since the last loop
                GameStates.Peek().Update(elapsed);

                //clear the window
                window.Clear();

                //draw objects here
                GameStates.Peek().Draw(window);

                //draw the object we placed on our frame
                window.Display();
            }

            //clean up
            GameStates.Clear();
                
        }
コード例 #2
0
 public void SpawnEnemy()
 {
     if (timer.ElapsedTime > deltaTime)
     {
         c.AddShip(ShipFactory.CreateRandomShip(world));
         time = new Time();
         timer.Restart();
     }
 }
コード例 #3
0
        public void Run()
        {
            Logger.Debug("Initialising GameController.");

            ShowSplashScreen();

            _configurationManager.LoadFromFile(PathHelpers.ExecutableRelativeFile("client_config.toml"));

            _resourceManager.LoadBaseResources();
            _resourceManager.LoadLocalResources();

            //Setup Cluwne first, as the rest depends on it.
            SetupCluwne();
            CleanupSplashScreen();

            //Initialization of private members
            _messageLogger.Initialize();
            _entityNetworkManager.Initialize();
            _tileDefinitionManager.InitializeResources();

            var prototypeManager = IoCManager.Resolve <IPrototypeManager>();

            prototypeManager.LoadDirectory(PathHelpers.ExecutableRelativeFile("Prototypes"));
            prototypeManager.Resync();
            _networkManager.Initialize();
            _netGrapher.Initialize();
            _userInterfaceManager.Initialize();

            _stateManager.RequestStateChange <MainScreen>();

            FrameEventArgs _frameEvent;

            // EventArgs _frameEventArgs;
            _clock = new Clock();

            while (CluwneLib.IsRunning == true)
            {
                var lastFrameTime = _clock.ElapsedTime.AsSeconds();
                _clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color.Black);
                CluwneLib.Screen.DispatchEvents();
                CluwneLib.RunIdle(this, _frameEvent);
                CluwneLib.Screen.Display();
            }
            _networkManager.Disconnect();
            CluwneLib.Terminate();
            Logger.Info("GameController terminated.");

            IoCManager.Resolve <IConfigurationManager>().SaveToFile();
        }
コード例 #4
0
ファイル: Game.cs プロジェクト: Xavrax/tetris-sfml-net
        public void Run()
        {
            var clock = new Sfs.Clock();

            SetEventHandlers();
            while (_window.IsOpen)
            {
                _window.Clear();
                _window.DispatchEvents();
                Update(clock.ElapsedTime);
                clock.Restart();
                Render();
                _window.Display();
            }
        }