Ejemplo n.º 1
0
 public Form1()
 {
     InitializeComponent();
     random = new Random();
     game = new Game(random, this.ClientRectangle);  // initialize game with boundary size
     game.GameOver += new EventHandler(game_GameOver);
 }
Ejemplo n.º 2
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Q)
                Application.Exit();

            if (gameOver)
                if (e.KeyCode == Keys.S)
                {
                    // code to reset the game and restart the timers
                    game = new Game(random, this.ClientRectangle);
                    gameTimer.Start();
                    gameOver = false;
                    return;
                }
            if (e.KeyCode == Keys.Space)
                game.FireShot();
            if (keysPressed.Contains(e.KeyCode))
                keysPressed.Remove(e.KeyCode);
            keysPressed.Add(e.KeyCode);
        }