Reformat + Basic animation system

General fixes
This commit is contained in:
Bram Verhulst
2024-04-01 10:27:37 +02:00
parent 3b9c96ea8d
commit 0f9bb76973
28 changed files with 918 additions and 546 deletions

View File

@@ -0,0 +1,29 @@
#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;
}