コード例 #1
0
ファイル: Form1.cs プロジェクト: caspros/RiverRaid
        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;
                }
            }
        }
コード例 #2
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();
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// start timers method
 /// </summary>
 private void StartTimers()
 {
     MoveBackground.Start();
     RightTimer.Start();
     LeftTimer.Start();
     MoveEnemiesTimer.Start();
     MunitionTimer.Start();
     EnemiesMunitionTimer.Start();
 }