mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 04:21:48 +01:00
76 lines
1.5 KiB
C++
76 lines
1.5 KiB
C++
#pragma once
|
|
#include <array>
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
#include "structs.h"
|
|
|
|
class GroundTileType;
|
|
static const int WORLD_WIDTH = 34;
|
|
static const int WORLD_HEIGHT = 34;
|
|
|
|
static const int TILE_WIDTH = 50;
|
|
static const int TILE_HEIGHT = 50;
|
|
|
|
class WorldTile;
|
|
|
|
enum TileDirection
|
|
{
|
|
TopLeft,
|
|
TopMiddle,
|
|
TopRight,
|
|
|
|
MiddleLeft,
|
|
//me
|
|
MiddleRight,
|
|
|
|
BottomLeft,
|
|
BottomMiddle,
|
|
BottomRight
|
|
};
|
|
|
|
struct surroundingTiles
|
|
{
|
|
|
|
std::vector<WorldTile *> m_tiles{ 8, nullptr};
|
|
|
|
void SetTile(TileDirection direction, WorldTile* tile) {
|
|
m_tiles[static_cast<int>(direction)] = tile;
|
|
}
|
|
|
|
WorldTile* GetTile(TileDirection direction) {
|
|
return m_tiles[static_cast<int>(direction)];
|
|
}
|
|
|
|
// bool IsAllType(const GroundTileType& type) {
|
|
// for (const auto& tile : m_tiles) {
|
|
// if (tile.second == nullptr) {
|
|
// return false;
|
|
// }
|
|
// if (tile.second->GetTileType() != &type) {
|
|
// return false;
|
|
// }
|
|
// }
|
|
// return true;
|
|
// }
|
|
};
|
|
|
|
class WorldGridManager
|
|
{
|
|
public:
|
|
WorldGridManager();
|
|
~WorldGridManager();
|
|
surroundingTiles GetSurroundingTiles(const WorldTile* world_tile);
|
|
Vector2f GetIndexFromPosition(Vector2f position);
|
|
|
|
WorldGridManager(const WorldGridManager& other) = default;
|
|
|
|
WorldTile * GetTileAtIndex(const int x, const int y) const;
|
|
WorldTile * GetTileAtWorldPos(const Vector2f& pos) const;
|
|
|
|
void SetTileAtIndex(const int x, const int y, WorldTile* tile);
|
|
|
|
private:
|
|
std::array<std::array<WorldTile *, WORLD_WIDTH>, WORLD_HEIGHT> m_worldTiles;
|
|
};
|