diff options
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/map.cpp b/src/map.cpp index 78171ca9..949b00bd 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -607,6 +607,18 @@ bool Map::occupied(int x, int y) const return false; } +Vector Map::getTileCenter(int x, int y) +{ + Vector tileCenterPos; + + if (!contains(x, y)) + return tileCenterPos; + + tileCenterPos.x = x * mTileWidth + mTileWidth / 2; + tileCenterPos.y = y * mTileHeight + mTileHeight / 2; + return tileCenterPos; +} + bool Map::contains(int x, int y) const { return x >= 0 && y >= 0 && x < mWidth && y < mHeight; |