示例#1
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
     {
         mainPlayer.Image = Properties.Resources.cowboy_run;
         if (e.KeyCode == Keys.Left)
         {
             LeftMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Right)
         {
             RightMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Up)
         {
             UpMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Down)
         {
             DownMoveTimer.Start();
         }
     }
     if (e.KeyCode == Keys.Space)
     {
         ShootingTimer.Start();
     }
     if (e.KeyCode == Keys.Escape)
     {
         Process.GetCurrentProcess().Kill();
     }
 }
示例#2
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (!pause)
     {
         if (e.KeyCode == Keys.Right)
         {
             RightMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Left)
         {
             LeftMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Up)
         {
             UpMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Down)
         {
             DownMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Space)
         {
             if (currentAmmo < limAmmo)
             {
                 currentAmmo++;
                 fire = true;
             }
         }
     }
 }
示例#3
0
        // This is when key is pressed
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (!pause)
            {
                if (e.KeyCode == Keys.Right)
                {
                    RightMoveTimer.Start();
                }

                if (e.KeyCode == Keys.Left)
                {
                    LeftMoveTimer.Start();
                }

                if (e.KeyCode == Keys.Down)
                {
                    DownMoveTimer.Start();
                }

                if (e.KeyCode == Keys.Up)
                {
                    UpMoveTimer.Start();
                }
            }
        }
示例#4
0
 private void StartTimers()
 {
     LeftMoveTimer.Start();
     RightMoveTimer.Start();
     LaserTimer.Start();
     EnemiesTimer.Start();
 }
示例#5
0
        private void StartTimers()
        {
            int milliseconds = 2000;

            Thread.Sleep(milliseconds);

            LeftMoveTimer.Start();
            RightMoveTimer.Start();
            UpMoveTimer.Start();
            DownMoveTimer.Start();

            MoveBgTimer.Start();
            MoveEnemiesTimer.Start();
            MoveAmmunitionTimer.Start();
            EnemiesAmmunitionTimer.Start();
        }
示例#6
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Left)
            {
                if (Spaceship.spaceshipX > 20)
                {
                    LeftMoveTimer.Start();
                }
                else
                {
                    LeftMoveTimer.Stop();
                    Spaceship.spaceshipV = 0;
                }
            }
            if (e.KeyCode == Keys.Right)
            {
                if (Spaceship.spaceshipX < 580)
                {
                    RightMoveTimer.Start();
                }
                else
                {
                    RightMoveTimer.Stop();
                    Spaceship.spaceshipV = 0;
                }
            }

            if (e.KeyCode == Keys.Space)
            {
                LaserTimer.Start();
            }

            if (e.KeyCode == Keys.R)
            {
                ResetGame();
            }
        }