MetaSpace.cpp 796 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "MetaSpace.h"
  2. /// Construction
  3. MetaSpace::MetaSpace()
  4. : m_buff(0x0), m_w(0), m_h(0)
  5. {
  6. //ctor
  7. }
  8. MetaSpace::~MetaSpace()
  9. {
  10. if ( !m_buff )
  11. SDL_FreeSurface(m_buff) ;
  12. }
  13. /// Méthodes
  14. bool MetaSpace::init(Uint32 w, Uint32 h)
  15. {
  16. m_w = w ;
  17. m_h = h ;
  18. m_buff = SDL_CreateRGBSurface(SDL_HWSURFACE, w, h, 32, 0, 0, 0, 0) ;
  19. if ( !m_buff )
  20. return false;
  21. else
  22. return true;
  23. clean();
  24. }
  25. void MetaSpace::clean()
  26. {
  27. SDL_FillRect(m_buff, 0x0, 0x000000);
  28. for ( Uint32 i = 0; i < m_h; i++ )
  29. for ( Uint32 j = 0; j < m_w; j++ )
  30. m_tab[i][j] = 0 ;
  31. }
  32. bool MetaSpace::isInside(Uint32 y, Uint32 x)
  33. {
  34. return y < m_h && x < m_w && x >= 0 && y >=0 ;
  35. }
  36. /// Acésseurs
  37. SDL_Surface* MetaSpace::getSurf()
  38. {
  39. return m_buff;
  40. }