예제 #1
0
        public static DialogResult Show()
        {
            pauseForm = new PauseForm();

            pauseForm.ShowDialog();
            return(buttonResult);
        }
예제 #2
0
        private void GameScreen_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            // opens a pause screen is escape is pressed. Depending on what is pressed
            // on pause screen the program will either continue or exit to main menu
            if (e.KeyCode == Keys.Escape && gameTimer.Enabled)
            {
                winloseLabel.Visible = false;
                gameTimer.Enabled    = false;
                gamePlayer.Stop();
                rightArrowDown = leftArrowDown = zDown = xDown = downArrowDown = upArrowDown = false;

                DialogResult result = PauseForm.Show();

                if (result == DialogResult.Cancel)
                {
                    gameTimer.Enabled = true;
                }
                else if (result == DialogResult.Abort)
                {
                    MainForm.ChangeScreen(this, "MenuScreen");
                }
            }


            //player 1 button presses
            switch (e.KeyCode)
            {
            case Keys.Left:
                leftArrowDown = true;
                break;

            case Keys.Down:
                downArrowDown = true;
                break;

            case Keys.Right:
                rightArrowDown = true;
                break;

            case Keys.Z:
                if (!jumping && heroY == groundY - heroSize)
                {
                    jumping = true;
                }
                zDown = true;
                break;

            case Keys.X:
                xDown = true;
                break;

            case Keys.Up:
                upArrowDown = true;
                break;
            }
        }