コード例 #1
0
ファイル: Level.cs プロジェクト: AlexanderLee1012/Platform
        public int bulletCollisionPlayer(int playerX, int playerY, int pHeight, int pWidth, bool duck, Projectile bullet)
        {
            int projX = (int)bullet.bulletX();
            int projY = (int)bullet.bulletY();

            if (checkCollision(projX, projY, true))
            {
                bullet.bulletCollision();
                return(0);
            }
            else if (projX > playerX - pWidth / 2 && projX < playerX + pWidth / 2)
            {
                if (duck)
                {
                    if (projY < playerY + pHeight / 2 && projY > playerY)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                if (projY < playerY + pHeight / 2 && projY > playerY - pHeight / 2)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
コード例 #2
0
ファイル: Level.cs プロジェクト: AlexanderLee1012/Platform
 public int bulletCollisionPlayer(int playerX, int playerY, int pHeight, int pWidth, bool duck, Projectile bullet)
 {
     int projX = (int)bullet.bulletX();
     int projY = (int)bullet.bulletY();
     if (checkCollision(projX, projY, true))
     {
         bullet.bulletCollision();
         return 0;
     }
     else if (projX > playerX - pWidth/2 && projX < playerX + pWidth/2)
     {
         if (duck)
             if (projY < playerY + pHeight / 2 && projY > playerY)
                 return 1;
             else
                 return 0;
         else
             if (projY < playerY + pHeight / 2 && projY > playerY - pHeight / 2)
                 return 1;
             else
                 return 0;
     }
     else
         return 0;
 }