예제 #1
0
파일: Form1.cs 프로젝트: a65576557/iproject
 private void timer1_Tick(object sender, EventArgs e)
 {
     interval++;
     if (interval % 5 == 0)
     {
         newBomb();
     }
     else if (interval % 2 == 0)
     {
         foreach (Control t in this.Controls)
         {
             if (t is CBomb)
             {
                 CBomb b = t as CBomb;
                 b.Top += b.speed;
                 if (isManTouched(b.Left, b.Top) ||
                     isManTouched(b.Left, b.Top + b.Height) ||
                     isManTouched(b.Left + b.Width, b.Top) ||
                     isManTouched(b.Left + b.Width, b.Top + b.Height))
                 {
                     timer1.Enabled = false;
                     MessageBox.Show("Game Over");
                     return;
                 }
             }
         }
     }
 }
예제 #2
0
파일: Form1.cs 프로젝트: a65576557/iproject
        private void newBomb()
        {
            CBomb pic = new CBomb();

            pic.Width    = 32;
            pic.Height   = 64;
            pic.SizeMode = PictureBoxSizeMode.StretchImage;
            pic.Image    = Bitmap.FromFile(@"C:\Cs sample\pics\bomb.png");
            pic.Top      = 0;
            pic.speed    = rand.Next(10, 100);
            pic.Left     = rand.Next(0, this.Width);
            pic.BringToFront();
            this.Controls.Add(pic);
        }