mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 14:41:49 +01:00
Reformat + Basic animation system
General fixes
This commit is contained in:
29
Game/GridSystem/WorldGridManager.cpp
Normal file
29
Game/GridSystem/WorldGridManager.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user