Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Tile.h"
- Tile::Tile() : surface(NULL), x(-1), y(-1), size(-1), sx(-1), sy(-1) {}
- 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) {}
- SDL_Surface* Tile::getSheet() {
- return surface;
- }
- int Tile::getX() {
- return x;
- }
- int Tile::getY() {
- return y;
- }
- int Tile::getSize() {
- return size;
- }
- int Tile::getSheetX() {
- return sx;
- }
- int Tile::getSheetY() {
- return sy;
- }
- void Tile::setX(int x) {
- this->x = x;
- }
- void Tile::setY(int y) {
- this->y = y;
- }
- void Tile::setSheetX(int x) {
- this->sx = x;
- }
- void Tile::setSheetY(int y) {
- this->sy = y;
- }
- void Tile::setSheet(SDL_Surface* surface) {
- this->surface = surface;
- }
- void Tile::render(SDL_Surface* screen, int xtrans, int ytrans) {
- cout << "Tile::render" << endl;
- if(xtrans == 1) {
- cout << "render 1" << endl;
- }
- if(surface == NULL || screen == NULL) {
- cout << "Tile::render surface is null" << endl;
- return;
- }
- SDL_Rect offset;
- offset.x = x+xtrans;
- offset.y = y+ytrans;
- SDL_Rect clip;
- clip.x = sx;
- clip.y = sy;
- clip.w = size;
- clip.h = size;
- SDL_BlitSurface(surface, &clip, screen, &offset);
- cout << "Tile::render end" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment