Ejemplo n.º 1
0
 static private void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.ControlKey)
     {
         bullet.Add(new Bullet(new Point(ship.Rect.X + 10, ship.Rect.Y + 2), new Point(20, 0), new Size(4, 1)));
     }
     if (e.KeyCode == Keys.Up)
     {
         ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         ship.Down();
     }
     if (e.KeyCode == Keys.Left)
     {
         ship.Left();
     }
     if (e.KeyCode == Keys.Right)
     {
         ship.Right();
     }
     if (e.KeyCode == Keys.Escape)
     {
         Application.Exit();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Обработчик событий нажатия клавиш
        /// </summary>
        private static void Form_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F)
            {
                _bullets.Add(new Bullet(new Point(_ship.Rect.X + 15, _ship.Rect.Y + 10), new Point(4, 0), new Size(8, 3)));
            }
            if (e.KeyCode == Keys.W || e.KeyCode == Keys.Up)
            {
                _ship.Up();
            }
            if (e.KeyCode == Keys.S || e.KeyCode == Keys.Down)
            {
                _ship.Down();
            }
            if (e.KeyCode == Keys.A || e.KeyCode == Keys.Left)
            {
                _ship.Left();
            }
            if (e.KeyCode == Keys.D || e.KeyCode == Keys.Right)
            {
                _ship.Right();
            }
            if (e.KeyCode == Keys.E || e.KeyCode == Keys.Shift)
            {
                _ship.BostSpeed();
                if (_ship.flag == true)
                {
                    delLog.Costum("Boost On\t Energy going down");
                }
                else
                {
                    delLog.Costum("Boost Off");
                }
            }
            if (e.KeyCode == Keys.N)
            {
                SaundPlayer();
            }
            if (_SndPlr != null & e.KeyCode == Keys.M)
            {
                _SndPlr.Stop(); delLog.Costum("Music Off");
            }

            if (e.KeyCode == Keys.Escape)
            {
                BestScore();

                Application.ExitThread();
            }
        }