ajtgarber

map (Tile.cpp)

May 5th, 2011
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include "Tile.h"
  2.  
  3. Tile::Tile() : surface(NULL), x(-1), y(-1), size(-1), sx(-1), sy(-1) {}
  4.  
  5. Tile::Tile(SDL_Surface* surface, int x, int y, int size, int sx, int sy) : surface(surface), x(x), y(y), size(size), sx(sx), sy(sy) {}
  6.  
  7. SDL_Surface* Tile::getSheet() {
  8.     return surface;
  9. }
  10. int Tile::getX() {
  11.     return x;
  12. }
  13. int Tile::getY() {
  14.     return y;
  15. }
  16. int Tile::getSize() {
  17.     return size;
  18. }
  19. int Tile::getSheetX() {
  20.     return sx;
  21. }
  22. int Tile::getSheetY() {
  23.     return sy;
  24. }
  25.  
  26. void Tile::setX(int x) {
  27.     this->x = x;
  28. }
  29. void Tile::setY(int y) {
  30.     this->y = y;
  31. }
  32. void Tile::setSheetX(int x) {
  33.     this->sx = x;
  34. }
  35. void Tile::setSheetY(int y) {
  36.     this->sy = y;
  37. }
  38. void Tile::setSheet(SDL_Surface* surface) {
  39.     this->surface = surface;
  40. }
  41.  
  42. void Tile::render(SDL_Surface* screen, int xtrans, int ytrans) {
  43.     cout << "Tile::render" << endl;
  44.  
  45.     if(xtrans == 1) {
  46.         cout << "render 1" << endl;
  47.     }
  48.  
  49.     if(surface == NULL || screen == NULL) {
  50.         cout << "Tile::render surface is null" << endl;
  51.         return;
  52.     }
  53.     SDL_Rect offset;
  54.     offset.x = x+xtrans;
  55.     offset.y = y+ytrans;
  56.    
  57.     SDL_Rect clip;
  58.     clip.x = sx;
  59.     clip.y = sy;
  60.     clip.w = size;
  61.     clip.h = size;
  62.  
  63.     SDL_BlitSurface(surface, &clip, screen, &offset);
  64.     cout << "Tile::render end" << endl;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment