Exemple #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();
     }
 }
Exemple #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();
            }
        }
Exemple #3
0
 private static void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.ControlKey)
     {
         bullet = new Bullet(new Point(ship.Rect.X + 60, ship.Rect.Y + 30), new Point(50, 0), new Size(1, 5));
     }
     if (e.KeyCode == Keys.Up)
     {
         ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         ship.Down();
     }
 }
Exemple #4
0
 /// <summary>
 /// Обрабатывает событие нажатия кнопки
 /// По нажатию Control - вылетает пуля. По нажатию стрелок "Вверх" и "Вниз" корабль перемещается в соответствующем направлении
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.ControlKey)
     {
         _bullets.Add(getNewBullet(new Point(_ship.Rect.X + 10, _ship.Rect.Y + 4)));
     }
     if (e.KeyCode == Keys.Up)
     {
         _ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         _ship.Down();
     }
 }
Exemple #5
0
 /// <summary>
 /// Обработчик нажатия кнопок
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.ControlKey)
     {
         _bullets.Add(new Bullet(new Point(_ship.rect.X + 30, _ship.rect.Y + 18), new Point(4, 0), new Size(4, 1)));
     }
     if (e.KeyCode == Keys.Up)
     {
         _ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         _ship.Down();
     }
 }
Exemple #6
0
 /// <summary>
 /// Обработчик события нажатия на клавишу
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.ControlKey)
     {
         bullets.Add(new Bullet(new Point(ship.Rect.Right, ship.Rect.Y + 3), new Point(25, 0), new Size(50, 15)));
         shot.Play();
     }
     if (e.KeyCode == Keys.Up)
     {
         ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         ship.Down();
     }
 }
Exemple #7
0
 private static void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.ControlKey)
     {
         _bullet = new Bullet(new Point(_ship.Rect.X + 10, _ship.Rect.Y + 4), new Point(50, 0), new Size(20, 1));
         _ship.GetEnergy(rnd.Next(-3, -1));
     }
     if (e.KeyCode == Keys.Up)
     {
         _ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         _ship.Down();
     }
 }
Exemple #8
0
 /// <summary>
 /// Реализация управления космическим кораблем с клавиатуры
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Space)
     {
         _bullets.Add(new Bullet(new Point(_ship.Rect.X + 10, _ship.Rect.Y + 4), new Point(4, 0), new Size(12, 7)));
         _bullets[_bullets.Count - 1].MessageCreate();
     }
     if (e.KeyCode == Keys.Up)
     {
         _ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         _ship.Down();
     }
 }
Exemple #9
0
 private static void Form_KeyDown(object sender, KeyEventArgs e)
 {
     //if (e.KeyCode == Keys.ControlKey)
     //{//_bullet = new Bullet(new Point(_ship.Rect.X + 10, _ship.Rect.Y + 4), new Point(4, 0), new Size(4, 1));
     //    //_bullet = new Bullet(new Point(_ship.Rect.X + 10, _ship.Rect.Y + 4), new Point(10, 0), new Size(30, 20));
     //}
     if (e.KeyCode == Keys.ControlKey)
     {
         _bullets.Add(new Bullet(new Point(_ship.Rect.X + 10, _ship.Rect.Y + 4), new Point(10, 0), new Size(10, 1)));
     }
     if (e.KeyCode == Keys.Up)
     {
         _ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         _ship.Down();
     }
 }
Exemple #10
0
 /// <summary>
 /// Обработка нажатия клавиш для управления кораблем
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Space)
     {
         _bullets.Add(new Bullet(new Point(_ship.Rect.X + 10, _ship.Rect.Y + 4), new Point(50, 0), new Size(10, 2)));
     }
     if (e.KeyCode == Keys.Up)
     {
         _ship.Up();
     }
     if (e.KeyCode == Keys.Down)
     {
         _ship.Down();
     }
     if (e.KeyCode == Keys.P)
     {
         _timer.Stop();
     }
     if (e.KeyCode == Keys.Enter)
     {
         _timer.Start();
     }
 }