Exemple #1
0
void gameMap::Draw(QuadTree<bool> &bw, int x, int y, int w, int h, const fsRendererGL& renderer)
{
    if (bw.object() == false)
    {
        if (bw.layers() == 0)
            return;
        Draw(bw[1](0, 0),  x,         y,         w / 2, h / 2, renderer);
        Draw(bw[1](1, 0), x + w / 2, y,         w / 2, h / 2, renderer);
        Draw(bw[1](0, 1),  x,         y + h / 2, w / 2, h / 2, renderer);
        Draw(bw[1](1, 1), x + w / 2, y + h / 2, w / 2, h / 2 , renderer);
    }
    else
    {
        SDL_Rect r;
        r.x = x + 1;
        r.y = y + 1;
        r.w = w - 1;
        r.h = h - 1;
        SDL_FillRect(SDL_GetVideoSurface(), &r, 0x00CCAA77);
        
        renderer.setColor( c_black );
        renderer.setAlpha( .6 );
        renderer.renderRect(x,y,x+w,y+h);
        renderer.setAlpha( .2 );
        renderer.renderRectFill(x,y,x+w,y+h);
    }
}
Exemple #2
0
void gameMap::BreakUp(int x, int y)
{
    int blockx = x / (m_iWidth / (*m_pQuadTree)[-1].width());
    int blocky = y / (m_iHeight / (*m_pQuadTree)[-1].width());
    
    QuadTree<bool> *qt = &(*m_pQuadTree)[-1](blockx, blocky);
    
    while (true)
    {
        if (qt->object() == true && qt->layers() > 0)
        {
            qt->setAllObjects(false);
            (*qt)[1](0, 0).object() = true;
            (*qt)[1](0, 1).object() = true;
            (*qt)[1](1, 0).object() = true;
            (*qt)[1](1, 1).object() = true;
            return;
        }
        if (qt->hasParent())
            qt = &qt->parent();
            else
                break;
    }
}