forked from hashr25/StarPusher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.cpp
More file actions
95 lines (76 loc) · 1.7 KB
/
Tile.cpp
File metadata and controls
95 lines (76 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "Tile.h"
/// //////////////////////////////////////////////////////////////////////////////
///Constructors and Destructors
Tile::Tile()
{
image = NULL;
}
Tile::Tile( int newMapX, int newMapY, TileType newType, SDL_Texture* newImage ) :
mapX(newMapX), mapY(newMapY), type(newType), image(newImage)
{
}
Tile::~Tile()
{
image = NULL;
}
/// /////////////////////////////////////////////////////////////////////////////
///Getters and Setters
//Getters
int Tile::getMapX()
{
return mapX;
}
int Tile::getMapY()
{
return mapY;
}
TileType Tile::getType()
{
return type;
}
SDL_Texture* Tile::getImage()
{
return image;
}
//Setters
void Tile::setMapX( int mapX )
{
this -> mapX = mapX;
}
void Tile::setMapY( int mapY )
{
this -> mapY = mapY;
}
void Tile::setType( TileType type )
{
this -> type = type;
}
void Tile::setImage( SDL_Texture* image )
{
this -> image = image;
}
/// ///////////////////////////////////////////////////////////////////
///Methods
void Tile::displayTile( SDL_Renderer* renderer )
{
SDL_Rect positionRect;
SDL_Rect cutRect;
positionRect.x = mapX * TILE_WIDTH;
positionRect.y = mapY * TILE_FLOOR_HEIGHT;
positionRect.h = TILE_HEIGHT;
positionRect.w = TILE_WIDTH;
if( mapY != 0 )
{
cutRect.x = 0;
cutRect.y = 25;
cutRect.h = TILE_HEIGHT;
cutRect.w = TILE_WIDTH;
SDL_RenderCopy( renderer, image, &cutRect, &positionRect );
}
else
{
SDL_RenderCopy( renderer, image, NULL, &positionRect );
}
std::cout << "Printing grass at " << positionRect.x << ", " << positionRect.y << std::endl;
std::cout << "Printing grass at " << mapX << ", " << mapY << std::endl;
}