示例#1
0
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     //if checks if player has ammo
     if (ammo > 0 && reloadTimer.Enabled == false)
     {
         //play shooting sound
         shootSound.play();
         //subtract 1 from players ammo
         ammo--;
         //for loop to run through
         for (int i = 0; i < duckRect.Count; i++)
         {
             //check for hit
             if (duckRect[i].Contains(e.Location))
             {
                 //add to score
                 playerScore += 250;
                 //if runs if ammo
                 if (ammo < 3)
                 {
                     //refund ammo
                     ammo++;
                 }
                 //stop horizontal movement
                 duckDX[i] = 0;
                 //start falling movement
                 duckDY[i] = gravity;
             }
         }
         //start reload timer
         reloadTimer.Start();
     }
 }
示例#2
0
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            //moves the rectangle up 5 pixels
            dy = -15;

            //adds a rectangle from the list
            bulletRect.Add(new Rectangle(player.Left + player.Width / 2, player.Top, 5, 5));

            //plays shooting sound
            shootSound.play();
        }