Beispiel #1
0
        public override void GetInput()
        {
            base.GetInput();

            if (input.ButtonPressed(Buttons.A) || input.KeyPressed(Keys.Enter))
            {
                menu_sound.PlaySound();

                switch (currentSelected)
                {
                case SelectedWinBtn.PlayAgain:
                    Main.CurrenGameState = GameState.NewGame;
                    break;

                case SelectedWinBtn.Menu:
                    Main.NewGame();
                    Main.CurrenGameState = GameState.Menu;
                    break;

                default:
                    break;
                }

                win_sound.StopSound();
            }
        }
        private float DoJump(float velocityY)
        {
            if (IsJumping)
            {
                if ((!wasJumping && IsOnGround) || jumpTime > 0.0f)
                {
                    if (jumpTime == 0.0f)
                    {
                        jump_sound.PlaySound();
                    }

                    jumpTime += (float)Globals.gameTime.ElapsedGameTime.TotalSeconds;
                }

                if (0.0f < jumpTime && jumpTime <= Globals.MAX_JUMP_TIME)
                {
                    velocityY = Globals.JUMP_VELOCITY * (1.0f - (float)Math.Pow(jumpTime / Globals.MAX_JUMP_TIME, Globals.JUMP_POWER));
                }
                else
                {
                    jumpTime = 0.0f;
                }
            }
            else
            {
                jump_sound.StopSound();
                jumpTime = 0.0f;
            }

            if (!IsOnGround)
            {
                PlayerState = Anim.Jump;
            }
            else
            {
                PlayerState = Anim.Idle;
            }

            wasJumping = IsJumping;

            return(velocityY);
        }