Ejemplo n.º 1
0
        /* Checks collision with static cells (bricks and solids) + still movable obstacles (not moving bombs) */
        private bool CheckStillCellsCollisions(MovableCell movable)
        {
            int cx = movable.cx;
            int cy = movable.cy;

            int stepX = Math.Sign(movable.px - movable.CellCenterPx());
            int stepY = Math.Sign(movable.py - movable.CellCenterPy());

            bool hasStepX = stepX != 0;
            bool hasStepY = stepY != 0;

            bool hasCollision = false;

            hasCollision |= CheckStillCollisions(movable, GetSlot(cx, cy));

            if (hasStepX && hasStepY)
            {
                hasCollision |= CheckStillCollisions(movable, GetSlot(cx + stepX, cy));
                hasCollision |= CheckStillCollisions(movable, GetSlot(cx, cy + stepY));
                hasCollision |= CheckStillCollisions(movable, GetSlot(cx + stepX, cy + stepY));
            }
            else if (hasStepX)
            {
                hasCollision |= CheckStillCollisions(movable, GetSlot(cx + stepX, cy));
            }
            else if (hasStepY)
            {
                hasCollision |= CheckStillCollisions(movable, GetSlot(cx, cy + stepY));
            }

            return hasCollision;
        }