コード例 #1
0
        public void Update(GameTime gameTime)
        {
            _gameFactory.AddBlock(_blocks, gameTime);

            if (Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                _catcher.MoveLeft(gameTime);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                _catcher.MoveRight(gameTime);
            }

            foreach (var b in _blocks)
            {
                b.Update(gameTime);
            }

            _collisionDetection.CheckCollision(_blocks, _catcher);

            if (Keyboard.GetState().IsKeyDown(Keys.Escape) && _previousState.IsKeyUp(Keys.Escape))
            {
                _myGame.CurrentScene = new EscMenuScene(_myGame, this);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.F1) && _previousState.IsKeyUp(Keys.F1))
            {
                Task.Run(() => FileIO.WriteSave(new GameObjects(_blocks, _catcher, _score, _gameFactory.TimeSinceLastBlock, _gameFactory.BlockInterval, _gameFactory.Difficulty)));
            }

            _previousState = Keyboard.GetState();
        }