SDL: How would I add tile layers with my area class as a singleton?

Posted by Tony on Game Development See other posts from Game Development or by Tony
Published on 2012-09-15T23:01:59Z Indexed on 2012/10/17 23:22 UTC
Read the original article Hit count: 185

Filed under:
|
|

I´m trying to wrap my head around how to get this done, if at all possible. So basically I have a Area class, Map class and Tile class. My Area class is a singleton, and this is causing some confusion. I´m trying to draw like this: Background / Tiles / Entities / Overlay Tiles / UI.

void C_Application::OnRender()
{
    // Fill the screen black
    SDL_FillRect( Surf_Screen, &Surf_Screen->clip_rect, SDL_MapRGB( Surf_Screen->format, 0x00, 0x00, 0x00 ) );

    // Draw background

    // Draw tiles
    C_Area::AreaControl.OnRender(Surf_Screen, -C_Camera::CameraControl.GetX(), -C_Camera::CameraControl.GetY());

    // Draw entities
    for(unsigned int i = 0;i < C_Entity::EntityList.size();i++)
    {
        if( !C_Entity::EntityList[i] )
        {
            continue;
        }

        C_Entity::EntityList[i]->OnRender( Surf_Screen );
    }

    // Draw overlay tiles

    // Draw UI

    // Update the Surf_Screen surface
    SDL_Flip( Surf_Screen);
}

Would be nice if someone could give a little input. Thanks.

© Game Development or respective owner

Related posts about c++

Related posts about tiles