Beispiel #1
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Q)
     {
         Application.Exit();
     }
     if (e.KeyCode == Keys.S)
     {
         // code to reset the game
         gameOver       = false;
         game           = new Game(random, FormArea);
         game.GameOver += new EventHandler(game_GameOver);
         gameTimer.Start();
         return;
     }
     if (e.KeyCode == Keys.Space)
     {
         game.FireShot();
     }
     if (keysPressed.Contains(e.KeyCode))
     {
         keysPressed.Remove(e.KeyCode);
     }
     keysPressed.Add(e.KeyCode);
 }
Beispiel #2
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            Keys pressedKey = e.KeyCode;

            if (pressedKey == Keys.Q)
            {
                Application.Exit();
            }

            if (gameOver)
            {
                if (pressedKey == Keys.S)
                {
                    //kod do ponownego uruchomienia i restatru zegarów
                }
            }

            if (pressedKey == Keys.Space)
            {
                game.FireShot();
            }

            if (keysPressed.Contains(pressedKey))
            {
                keysPressed.Remove(pressedKey);
            }

            keysPressed.Add(pressedKey);
        }
Beispiel #3
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     start = "PAUSE";
     if (e.KeyCode == Keys.P)
     {
         if (aux)
         {
             gameTimer.Stop();
             aux = false;
             CreateLabel(ref start);
         }
         else
         {
             gameTimer.Start();
             aux = true;
             this.Controls.Remove(namelabel);
         }
     }
     if (e.KeyCode == Keys.Q)
     {
         this.principal.Show();
         this.Close();
     }
     if (e.KeyCode == Keys.S)
     {
         // code to reset the game
         this.Controls.Remove(namelabel);
         gameOver       = false;
         game           = new Game(random, FormArea);
         game.GameOver += new EventHandler(game_GameOver);
         gameTimer.Start();
         return;
     }
     if (e.KeyCode == Keys.Space)
     {
         game.FireShot();
     }
     if (keysPressed.Contains(e.KeyCode))
     {
         keysPressed.Remove(e.KeyCode);
     }
     keysPressed.Add(e.KeyCode);
 }
Beispiel #4
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Q)
     {
         Application.Exit();
     }
     if (gameOver)
     {
         if (e.KeyCode == Keys.S)
         {
             RestartGame();
             return;
         }
     }
     if (e.KeyCode == Keys.Space)
     {
         game.FireShot();
     }
     if (keysPressed.Contains(e.KeyCode))
     {
         keysPressed.Remove(e.KeyCode);
     }
     keysPressed.Add(e.KeyCode);
 }