Files
prog2/Game/GridSystem/WorldGridManager.h
Bram Verhulst 71d364d9d8 Added inheritance for the screen system
basic edge detection for tile rendering
2024-04-04 13:49:38 +02:00

49 lines
1.0 KiB
C++

#pragma once
#include <array>
#include <vector>
#include "structs.h"
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;
struct surroundingTiles
{
std::array<WorldTile *, 8> tiles;
//Center of the surrounding tiles is 0, 0
void SetTile(int x, int y, WorldTile* tile) {
tiles[x + y * 3] = tile;
}
WorldTile * GetTile(int x, int y) {
return tiles[x + y * 3];
}
};
class WorldGridManager
{
public:
WorldGridManager();
~WorldGridManager();
std::vector<WorldTile*> GetSurroundingTiles(const WorldTile* world_tile);
Point2f GetIndexFromPosition(Point2f position);
WorldGridManager(const WorldGridManager& other) = default;
WorldTile * GetTileAtIndex(const int x, const int y) const;
WorldTile * GetTileAtWorldPos(const Point2f& pos) const;
void SetTileAtIndex(const int x, const int y, WorldTile* tile);
private:
std::array<std::array<WorldTile *, WORLD_WIDTH>, WORLD_HEIGHT> m_worldTiles;
};