Example #1
0
 public void CheckPlatfrom()
 {
     if (CExtends.IsIntersected(bullet.GetExtends(), platform.GetExtends()))
     {
         if (GameStarted)
         {
             bullet.InvertYSpeed();
         }
     }
 }
Example #2
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);
            }
        }