Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create an instance of the MainScreen
            newGame ng = new newGame();

            // Add the User Control to the Form
            this.Controls.Add(ng);

            ng.Location = new Point((this.Width - ng.Width) / 2, (this.Height - ng.Height) / 2);
        }
Beispiel #2
0
        private void gameOverScreen_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                Application.Exit();
            }
            if (e.KeyCode == Keys.Space)
            {
                //close currents screen
                Form f = this.FindForm();
                f.Controls.Remove(this);

                // Re-create newGame screen
                newGame ng = new newGame();

                // Add the User Control to the Form
                f.Controls.Add(ng);

                ng.Location = new Point((f.Width - ng.Width) / 2, (f.Height - ng.Height) / 2);

                gameOver = false;
            }
        }