コード例 #1
0
        private void lbl_BackToMainForm_Click(object sender, EventArgs e) // Go back StartForm
        {
            frm_StartGame form = new frm_StartGame();

            Hide();
            form.Show();
        }
コード例 #2
0
        private void frm_ManuelGameMod_KeyDown(object sender, KeyEventArgs e)
        {
            if (pb_Pacman.Left < 0 && e.KeyCode == Keys.Left)
            {
                return;
            }
            else if (pb_Pacman.Top < 40 && e.KeyCode == Keys.Up)
            {
                return;
            }
            else if (pb_Pacman.Right > Size.Width - pb_Pacman.Width && e.KeyCode == Keys.Right)
            {
                return;
            }
            else if (pb_Pacman.Bottom > Size.Height - pb_Pacman.Height && e.KeyCode == Keys.Down)
            {
                return;
            }

            switch (e.KeyCode)
            {
            case Keys.Up:
                pb_Pacman.Top -= 20;
                break;

            case Keys.Right:
                pb_Pacman.Left += 20;
                break;

            case Keys.Down:
                pb_Pacman.Top += 20;
                break;

            case Keys.Left:
                pb_Pacman.Left -= 20;
                break;

            default:
                break;
            }

            CatchControl(); // my catch control function.

            if (pb_target1.Visible == false && pb_target2.Visible == false && pb_target3.Visible == false && pb_target4.Visible == false && pb_target5.Visible == false)
            {
                DialogResult result = MessageBox.Show("You collected all targets. Do you want to play again?",
                                                      "Well done!",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    frm_ManuelGameMod form = new frm_ManuelGameMod();
                    Hide();
                    form.Show();
                }
                else
                {
                    frm_StartGame form = new frm_StartGame();
                    Hide();
                    form.Show();
                }
            }
        }