Exemplo n.º 1
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     RightTimer.Stop();
     LeftTimer.Stop();
     JumpTimer.Stop();
     PhysicTimer.Stop();
 }
Exemplo n.º 2
0
 private void Form1_KeyUp(object sender, KeyEventArgs e)
 {
     LeftTimer.Stop();
     RightTimer.Stop();
     UpTimer.Stop();
     DownTimer.Stop();
 }
Exemplo n.º 3
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Left) || (e.KeyCode == Keys.A))
            {
                LeftTimer.Start();
            }
            if ((e.KeyCode == Keys.Right) || (e.KeyCode == Keys.D))
            {
                RightTimer.Start();
            }
            if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.W))
            {
                UpTimer.Start();
            }
            if ((e.KeyCode == Keys.Down) || (e.KeyCode == Keys.S))
            {
                DownTimer.Start();
            }

            if (e.KeyCode == Keys.Space)
            {
                int i = shootNr % 3;
                bullets[i].Location = new Point(plane.Location.X + 20, plane.Location.Y - 30);
                bullets[i].Visible  = true;
                shootNr++;
                if (shootNr == 6)
                {
                    shootNr = 3;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Method responsible for start moving
        /// </summary>
        /// <param name="sender">The event sender</param>
        /// <param name="e">The event object</param>
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (!pause)
            {
                if (e.KeyCode == Keys.Right)
                {
                    if (speedLvl < 5)//improve speed
                    {
                        RightTimer.Interval = 5 - speedLvl;
                    }
                    RightTimer.Start();
                }
                if (e.KeyCode == Keys.Left)
                {
                    if (speedLvl < 5)//imporve speed
                    {
                        LeftTimer.Interval = 5 - speedLvl;
                    }
                    LeftTimer.Start();
                }

                //start fire
                if (e.KeyCode == Keys.A)
                {
                    if (bullets <= 3) //more bullets, more intervals of shooting
                    {
                        MunitionTimer.Interval = 31 - 10 * bullets;
                    }
                    MunitionTimer.Start();
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// start timers method
 /// </summary>
 private void StartTimers()
 {
     MoveBackground.Start();
     RightTimer.Start();
     LeftTimer.Start();
     MoveEnemiesTimer.Start();
     MunitionTimer.Start();
     EnemiesMunitionTimer.Start();
 }
Exemplo n.º 6
0
        /// <summary>
        ///Method responsible for stop moving
        /// </summary>
        /// <param name="sender">The even sender</param>
        /// <param name="e">The event object</param>
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            RightTimer.Stop();
            LeftTimer.Stop();

            //pause the game
            if (e.KeyCode == Keys.Space)
            {
                if (!gameIsOver)
                {
                    if (pause)
                    {
                        StartTimers();
                        label1.Visible = false;
                        pause          = false;
                    }
                    else
                    {
                        label1.Location = new Point(this.Width / 2 - 120, 150);
                        label1.Text     = "PAUSED";
                        label1.Visible  = true;
                        StopTimers();
                        pause = true;
                    }
                }
            }

            //end fire
            if (e.KeyCode == Keys.S)
            {
                MunitionTimer.Stop();
                for (int i = 0; i < munitions.Length; i++)
                {
                    munitions[i].Visible = false;
                }
            }
        }