Files
dae16-VerhulstBram-GameProject/Game/GridSystem/WorldGridManager.cpp
Bram Verhulst 0f9bb76973 Reformat + Basic animation system
General fixes
2024-04-01 10:27:37 +02:00

30 lines
838 B
C++

#include "WorldGridManager.h"
WorldGridManager::WorldGridManager() {
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
m_worldTiles[x][y] = nullptr;
}
}
}
WorldGridManager::~WorldGridManager() {
}
WorldTile * WorldGridManager::GetTileAtIndex(const int x, const int y) const {
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {
return nullptr;
}
return m_worldTiles[x][y];
}
WorldTile * WorldGridManager::GetTileAtWorldPos(const Point2f& pos) const {
int x = int(pos.x / TILE_WIDTH + WORLD_WIDTH / 2);
int y = int(-pos.y / TILE_HEIGHT);
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {
return nullptr;
}
return m_worldTiles[x][y];
}
void WorldGridManager::SetTileAtIndex(const int x, const int y, WorldTile* tile) {
m_worldTiles[x][y] = tile;
}