示例#1
0
 public void Form1_KeyUp(object sender, KeyEventArgs e)
 {
     RihtMoveTimer.Stop();
     LeftMoveTimer.Stop();
     BackMoveTimer.Stop();
     ForwardMoveTimer.Stop();
     if (firstPlane)
     {
         Player.Image = Properties.Resources.Plane_1_place;
     }
     else if (secondPlane)
     {
         Player.Image = Properties.Resources.Plane_2_place;
     }
     else if (thirdPlane)
     {
         Player.Image = Properties.Resources.Plane_3_place;
     }
 }
示例#2
0
        public void gameover()
        {
            RihtMoveTimer.Stop();
            LeftMoveTimer.Stop();
            BackMoveTimer.Stop();
            ForwardMoveTimer.Stop();
            enemyMoveTimer.Stop();


            isDead         = true;
            Player.Visible = false;

            Play.Enabled         = false;
            ReplayButton.Visible = true;
            ReplayButton.Enabled = true;
            PointsLabel.Visible  = false;

            for (int i = 0; i < stars.Length; i++)
            {
                stars[i].Visible = false;
            }
        }
示例#3
0
        public void Form1_KeyDown(object sender, KeyEventArgs e) // Function that performs movements in 2D space for 3 models of spacecraft
        {
            e.SuppressKeyPress = true;
            if (!paused)
            {
                switch (e.KeyCode)
                {
                case Keys.D:         // Button D
                    if (firstPlane)
                    {
                        Player.Image = Properties.Resources.Plane_1_right;
                    }
                    else if (secondPlane)
                    {
                        Player.Image = Properties.Resources.Plane_2_right;
                    }
                    else if (thirdPlane)
                    {
                        Player.Image = Properties.Resources.Plane_3_right;
                    }
                    RihtMoveTimer.Start();
                    break;

                case Keys.A:         // Button A
                    if (firstPlane)
                    {
                        Player.Image = Properties.Resources.Plane_1_left;
                    }
                    else if (secondPlane)
                    {
                        Player.Image = Properties.Resources.Plane_2_left;
                    }
                    else if (thirdPlane)
                    {
                        Player.Image = Properties.Resources.Plane_3_left;
                    }
                    LeftMoveTimer.Start();
                    break;

                case Keys.S:         // Button S
                    if (firstPlane)
                    {
                        Player.Image = Properties.Resources.Plane_1_down;
                    }
                    else if (secondPlane)
                    {
                        Player.Image = Properties.Resources.Plane_2_place;
                    }
                    else if (thirdPlane)
                    {
                        Player.Image = Properties.Resources.Plane_3_down;
                    }
                    BackMoveTimer.Start();
                    break;

                case Keys.W:         // Button W
                    if (firstPlane)
                    {
                        Player.Image = Properties.Resources.Plane_1_up;
                    }
                    else if (secondPlane)
                    {
                        Player.Image = Properties.Resources.Plane_2_up;
                    }
                    else if (thirdPlane)
                    {
                        Player.Image = Properties.Resources.Plane_3_up;
                    }
                    ForwardMoveTimer.Start();
                    break;

                case Keys.Space:         //Button Space
                    if (!isDead)
                    {
                        if (paused)
                        {
                            StartTimers();
                        }
                        else
                        {
                            ShootSound.controls.play();
                            MoveBullets();
                        }
                    }

                    break;

                case Keys.P:
                    if (isstarted)
                    {
                        StopTimers();
                        Menu_On();
                    }
                    break;
                }
            }
            else
            {
                if (e.KeyCode == Keys.C)
                {
                    if (isstarted)
                    {
                        StartTimers();
                        Menu_Off();
                    }
                }
            }
        }