-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTileset.h
More file actions
39 lines (32 loc) · 881 Bytes
/
Copy pathTileset.h
File metadata and controls
39 lines (32 loc) · 881 Bytes
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
#ifndef TILESET_H
#define TILESET_H
#include <vector>
struct Tile : public RefClass {
unsigned width, height;
Pixel *pixelData;
Tile(ref<Image> source, unsigned offsetX, unsigned offsetY, unsigned width, unsigned height);
~Tile();
bool compareTo(ref<Tile> otherTile);
Pixel getPixel(unsigned x, unsigned y) {
if (x < width && y < height)
return pixelData[width * y + x];
return 0;
}
void setPixel(unsigned x, unsigned y, Pixel value) {
if (x < width && y < height)
pixelData[width * y + x] = value;
}
};
class Tileset : public RefClass {
public:
std::vector< ref<Tile> > tileData;
Tileset();
void addTile(ref<Tile> tile);
ref<Tile> getTile(unsigned tileNo) const {
if (tileNo < numberOfTiles())
return tileData[tileNo];
return 0;
}
unsigned numberOfTiles() const { return tileData.size(); }
};
#endif