Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            LoadDB();
            //Form1.
            MainScreen ms = new MainScreen();

            ms.Location = new Point((this.Width - ms.Width) / 2, (this.Height - ms.Height) / 2);
            this.Controls.Add(ms);
        }
        private void restartButton_Click(object sender, EventArgs e)
        {
            Form f = this.FindForm();

            f.Controls.Remove(this);

            MainScreen ms = new MainScreen();

            f.Controls.Add(ms);

            victoryLabel.Visible  = false;
            restartButton.Visible = false;
            exitButton3.Visible   = false;
            scoreTitle.Visible    = false;
            scoreOutput.Visible   = false;
        }
Example #3
0
        private void continueButton_Click(object sender, EventArgs e)
        {
            Form f = this.FindForm();

            f.Controls.Remove(this);

            MainScreen ms = new MainScreen();

            f.Controls.Add(ms);

            gameoverLabel.Visible  = false;
            continueButton.Visible = false;
            exitButton2.Visible    = false;
            scoreTitle.Visible     = false;
            scoreLabel.Visible     = false;

            SoundPlayer player1 = new SoundPlayer(Properties.Resources.squash);

            player1.Play();
        }
Example #4
0
        private void GameScreen_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            //player 1 button presses
            switch (e.KeyCode)
            {
            case Keys.A:
                leftArrowDown = true;
                break;

            case Keys.D:
                rightArrowDown = true;
                break;

            case Keys.Left:
                leftArrowDown = true;
                break;

            case Keys.Right:
                rightArrowDown = true;
                break;

            case Keys.Escape:
                gameLoop.Stop();
                Form f = this.FindForm();
                f.Controls.Remove(this);

                MainScreen ms = new MainScreen();
                ms.Location = new Point((f.Width - ms.Width) / 2, (f.Height - ms.Height) / 2);
                f.Controls.Add(ms);
                ms.Focus();
                break;

            default:
                break;
            }
        }