mirror of
https://github.com/dylanbenzi/pacmen-sfml.git
synced 2026-11-27 08:26:59 +00:00
add method to get id of tiles
This commit is contained in:
+5
-3
@@ -132,7 +132,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int convert2DCoords(int row, int col, int width) {
|
int convert2DCoords(int row, int col) {
|
||||||
return col + (row * width);
|
return col + (row * width);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,9 +141,11 @@ public:
|
|||||||
//tileX increases going right
|
//tileX increases going right
|
||||||
//tileY increases going down
|
//tileY increases going down
|
||||||
|
|
||||||
int index = convert2DCoords(tileY, tileX, 28);
|
int index = convert2DCoords(tileY, tileX);
|
||||||
|
|
||||||
return 0;
|
int tileId = tiles.at(index);
|
||||||
|
|
||||||
|
return tileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ int main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int intTileId = mazeMap.getTileId(0, 0);
|
||||||
|
tileId.setString(std::to_string(intTileId));
|
||||||
|
|
||||||
window.clear();
|
window.clear();
|
||||||
|
|
||||||
window.draw(map);
|
window.draw(map);
|
||||||
|
|||||||
Reference in New Issue
Block a user