コード例 #1
0
ファイル: TRexGame.cs プロジェクト: Level1Rookie/TrexRunner
        public bool StartGame()
        {
            if (State != GameState.Initial)
            {
                return(false);
            }

            State = GameState.Transition;
            _trex.BeginJump();

            return(true);
        }
コード例 #2
0
        private bool StartGame()
        {
            if (State != GameState.Initial)
            {
                return(false);
            }

            _scoreBoard.Score = 0;
            State             = GameState.Transition;
            _trex.BeginJump();

            return(true);
        }
コード例 #3
0
ファイル: TrexRunner.cs プロジェクト: Aplefen1/GameOne
        private bool StartGame()
        {
            if (State != GameState.Initial)
            {
                return(false);
            }

            State = GameState.Transition;
            trex.BeginJump();
            _groundManager.Initialize();
            _backroundManager.Initilaize();

            return(true);
        }
コード例 #4
0
        public void ProcessControls(GameTime gameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            if (!_isBlocked)
            {
                bool isJumpKeyPressed  = keyboardState.IsKeyDown(Keys.Up) || keyboardState.IsKeyDown(Keys.Space);
                bool wasJumpKeyPressed = _previousKeyboardState.IsKeyDown(Keys.Up) || _previousKeyboardState.IsKeyDown(Keys.Space);

                if (isJumpKeyPressed && !wasJumpKeyPressed)
                {
                    if (_trex.State != TrexState.Jumping)
                    {
                        _trex.BeginJump();
                    }
                }
                // if we check _previousKeyboardState.IsKeyDown
                // Cancel Jump will only be called on the frame the keyboard is released
                else if (!isJumpKeyPressed && _trex.State == TrexState.Jumping)
                {
                    _trex.CancelJump();
                }

                else if (keyboardState.IsKeyDown(Keys.Down))
                {
                    if (_trex.State == TrexState.Jumping || _trex.State == TrexState.Falling)
                    {
                        _trex.Drop();
                    }
                    else
                    {
                        _trex.Duck();
                    }
                }

                else if (_trex.State == TrexState.Ducking && !keyboardState.IsKeyDown(Keys.Down))
                {
                    _trex.Getup();
                }
            }

            // keyboardState is a struct, so it won't be referencing the same instance
            _previousKeyboardState = keyboardState;
            _isBlocked             = false;
        }
コード例 #5
0
        public void ProcessControls(GameTime gameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Up) && !_previousKeyboardState.IsKeyDown(Keys.Up))
            {
                if (_trex.State != TrexState.Jumping)
                {
                    _trex.BeginJump();
                }
            }
            else if (!keyboardState.IsKeyDown(Keys.Up) && _trex.State == TrexState.Jumping)
            {
                _trex.CancelJump();
            }

            _previousKeyboardState = keyboardState;
        }
コード例 #6
0
        public void ProcessControls(GameTime gameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            if (!_isBlocked)
            {
                bool isJumpKeyPressed  = keyboardState.IsKeyDown(Keys.Up) || keyboardState.IsKeyDown(Keys.Space);
                bool wasJumpKeyPressed = _previousKeyboardState.IsKeyDown(Keys.Up) || _previousKeyboardState.IsKeyDown(Keys.Space);

                if (!wasJumpKeyPressed && isJumpKeyPressed)
                {
                    if (_trex.State != TrexState.Jumping)
                    {
                        _trex.BeginJump();
                    }
                }
                else if (_trex.State == TrexState.Jumping && !isJumpKeyPressed)
                {
                    _trex.CancelJump();
                }
                else if (keyboardState.IsKeyDown(Keys.Down))
                {
                    if (_trex.State == TrexState.Jumping || _trex.State == TrexState.Falling)
                    {
                        _trex.Drop();
                    }
                    else
                    {
                        _trex.Duck();
                    }
                }
                else if (_trex.State == TrexState.Ducking && !keyboardState.IsKeyDown(Keys.Down))
                {
                    _trex.GetUp();
                }
            }

            _previousKeyboardState = keyboardState;

            _isBlocked = false;
        }