#include "MetaSpace.h"

/// Construction
MetaSpace::MetaSpace()
: m_buff(0x0), m_w(0), m_h(0)
{
    //ctor
}

MetaSpace::~MetaSpace()
{
    if ( !m_buff )
        SDL_FreeSurface(m_buff) ;
}

/// Méthodes
bool MetaSpace::init(Uint32 w, Uint32 h)
{
    m_w = w ;
    m_h = h ;

    m_buff = SDL_CreateRGBSurface(SDL_HWSURFACE, w, h, 32, 0, 0, 0, 0) ;

    if ( !m_buff )
        return false;
    else
        return true;

    clean();
}

void MetaSpace::clean()
{
    SDL_FillRect(m_buff, 0x0, 0x000000);

    for ( Uint32 i = 0; i < m_h; i++ )
        for ( Uint32 j = 0; j < m_w; j++ )
            m_tab[i][j] = 0 ;
}

bool MetaSpace::isInside(Uint32 y, Uint32 x)
{
    return y < m_h && x < m_w && x >= 0 && y >=0 ;
}

/// Acésseurs
SDL_Surface* MetaSpace::getSurf()
{
    return m_buff;
}
