Skip to content

Commit

Permalink
Removing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosegala committed Apr 12, 2019
1 parent 543c80e commit e139648
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/TileMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace penguin {

void SetTileSet(TileSet*);

unsigned int Pos(unsigned int, unsigned int, unsigned int);
unsigned int Pos(int, int, int);

int& At(int, int, int z = 0);

Expand Down
29 changes: 16 additions & 13 deletions src/TileMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ namespace penguin {


getline(fs, line, ',');
auto x = (unsigned int) std::stoi(line);
auto x = std::stoi(line);
getline(fs, line, ',');
auto y = (unsigned int) std::stoi(line);
auto y = std::stoi(line);
getline(fs, line, ',');
auto z = (unsigned int) std::stoi(line);
auto z = std::stoi(line);

unsigned int n = x * y * z;
auto n = static_cast<unsigned int>(x * y * z);

this->mapDepth = (int) z;
this->mapHeight = (int) y;
this->mapWidth = (int) x;
this->tileMatrix.resize(n);
this->mapDepth = z;
this->mapHeight = y;
this->mapWidth = x;

for (unsigned int k = 0; k < z; k++){
for (unsigned int i = 0; i < x; i++){
for (unsigned int j = 0; j < y; j++){
for (auto k = 0; k < z; k++){
for (auto i = 0; i < x; i++){
for (auto j = 0; j < y; j++){
getline(fs, line, ',');
unsigned int idx = Pos(j, i, k);
auto idx = Pos(j, i, k);
this->tileMatrix[idx] = std::stoi(line);
this->tileMatrix[idx]--;
}
Expand All @@ -57,8 +57,11 @@ namespace penguin {
this->tileSet = ts;
}

unsigned int TileMap::Pos(unsigned int x, unsigned int y, unsigned int z) {
return (z * (this->mapWidth * this->mapHeight) + y * (this->mapWidth) + x);
unsigned int TileMap::Pos(int x, int y, int z) {
auto mapSize = (this->mapWidth * this->mapHeight);
auto columnSize = (this->mapWidth);

return static_cast<unsigned int>(z * mapSize + y * columnSize + x);
}

int& TileMap::At(int x, int y, int z) {
Expand Down
7 changes: 4 additions & 3 deletions src/TileSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ namespace penguin {
auto n = GetQuantityTiles();

if (index < n) {
auto i = (index % this->columns);
auto j = (index / this->columns);
auto cols = static_cast<unsigned int>(this->columns);
auto i = static_cast<int>(index % cols);
auto j = static_cast<int>(index / cols);

this->tileSet.SetClip(i * this->tileWidth, j * this->tileHeight, this->tileWidth, this->tileHeight);
this->tileSet.Render(x * this->tileWidth, y * this->tileHeight);
}
}

unsigned int TileSet::GetQuantityTiles() const {
return this->tileWidth * this->tileHeight;
return static_cast<unsigned int>(this->tileWidth * this->tileHeight);
}

int TileSet::GetTileWidth() const {
Expand Down

0 comments on commit e139648

Please sign in to comment.