예제 #1
0
 public void CheckPlatfrom()
 {
     if (CExtends.IsIntersected(bullet.GetExtends(), platform.GetExtends()))
     {
         if (GameStarted)
         {
             bullet.InvertYSpeed();
         }
     }
 }
예제 #2
0
        public void CheckBorder(Bullet bul)
        {
            CExtends extends = bul.GetExtends();

            if ((extends.LeftX <= 0) || (extends.RightX >= FormWidth - 15))
            {
                bullet.InvertXSpeed();
            }
            if (extends.UpperY <= 0)
            {
                bullet.InvertYSpeed();
            }
        }
예제 #3
0
        public bool CheckFault()
        {
            CExtends extends = bullet.GetExtends();

            if (extends.UpperY >= FormHeight)
            {
                Lose();
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
 public static bool IsIntersected(CExtends one, CExtends two)
 {
     if ((one.BottomY >= two.UpperY) && (one.UpperY <= two.BottomY))
     {
         if ((one.RightX >= two.LeftX) && (one.LeftX <= two.RightX))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
예제 #5
0
        public bool CheckCollision(Block block)
        {
            if (CExtends.IsIntersected(block.GetExtends(), bullet.GetExtends()))
            {
                CExtends BlockExtends  = block.GetExtends();
                CExtends BulletExtends = bullet.GetExtends();
                Point    bulpt         = BulletExtends.Center;
                Point    blockpt       = BlockExtends.Center;
                int      dx            = blockpt.X - (bulpt.X - bullet.SpeedX);
                int      dy            = blockpt.Y - (bulpt.Y - bullet.SpeedY);
                float    tga           = 1;
                try
                {
                    tga = Math.Abs(dx) / Math.Abs(dy);
                }
                catch (DivideByZeroException)
                {
                }

                if (tga >= 1)
                {
                    bullet.InvertXSpeed();
                }
                //   if (tga==1)
                // {
                //     if (bul.XSpeedCorrected == false) bul.SpeedX = -bul.SpeedX;
                //    bul.XSpeedCorrected = true;
                //       if (bul.YSpeedCorrected == false) bul.SpeedY = -bul.SpeedY;
                //       bul.YSpeedCorrected = true;
                //    }
                if (tga < 1)
                {
                    bullet.InvertYSpeed();
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
        public CExtends GetExtends()
        {
            CExtends ext = new CExtends(PosX, PosY, Width, Height);

            return(ext);
        }