mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-18 20:29:20 +01:00
Started on GuiIcon, General fixes
This commit is contained in:
@@ -20,31 +20,15 @@ WorldGridManager::~WorldGridManager() {
|
||||
delete m_worldTiles[x][y];
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Deleting static" << std::endl;
|
||||
// delete Tiles::AIR;
|
||||
// delete Tiles::DIRT;
|
||||
//
|
||||
// delete Tiles::Hazards::LAVA;
|
||||
// delete Tiles::Hazards::STONE;
|
||||
//
|
||||
// delete Tiles::Ores::BRONZE;
|
||||
// delete Tiles::Ores::GOLD;
|
||||
// delete Tiles::Ores::IRON;
|
||||
//
|
||||
// delete Tiles::Special::GRASS;
|
||||
// delete Tiles::Special::HARD_LEFT;
|
||||
// delete Tiles::Special::HARD_MIDDLE;
|
||||
// delete Tiles::Special::HARD_RIGHT;
|
||||
}
|
||||
|
||||
surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_tile) {
|
||||
surroundingTiles tiles;
|
||||
Vector2f pos = world_tile->GetPosition();
|
||||
Vector2f gridCoords = this->GetIndexFromPosition(pos);
|
||||
int x = gridCoords.x;
|
||||
const int x = (int)gridCoords.x;
|
||||
//TODO: Stupid fix, fix this
|
||||
int y = gridCoords.y - 1;
|
||||
const int y = (int)gridCoords.y - 1;
|
||||
|
||||
tiles.SetTile(TileDirection::TopLeft, this->GetTileAtIndex(x - 1, y - 1));
|
||||
tiles.SetTile(TileDirection::TopMiddle, this->GetTileAtIndex(x, y - 1));
|
||||
@@ -58,12 +42,12 @@ surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_ti
|
||||
tiles.SetTile(TileDirection::BottomRight, this->GetTileAtIndex(x + 1, y + 1));
|
||||
|
||||
return tiles;
|
||||
|
||||
|
||||
}
|
||||
Vector2f WorldGridManager::GetIndexFromPosition(Vector2f position) {
|
||||
int x = int(position.x / TILE_WIDTH + WORLD_WIDTH / 2);
|
||||
int y = int(-position.y / TILE_HEIGHT);
|
||||
return Vector2f{ float(x), float(y) };
|
||||
return Vector2f { float(x), float(y) };
|
||||
}
|
||||
WorldTile * WorldGridManager::GetTileAtIndex(const int x, const int y) const {
|
||||
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {
|
||||
|
||||
@@ -14,8 +14,7 @@ static const int TILE_HEIGHT = 50;
|
||||
|
||||
class WorldTile;
|
||||
|
||||
enum TileDirection
|
||||
{
|
||||
enum TileDirection {
|
||||
TopLeft,
|
||||
TopMiddle,
|
||||
TopRight,
|
||||
@@ -29,41 +28,31 @@ enum TileDirection
|
||||
BottomRight
|
||||
};
|
||||
|
||||
struct surroundingTiles
|
||||
{
|
||||
struct surroundingTiles {
|
||||
|
||||
std::vector<WorldTile *> m_tiles{ 8, nullptr};
|
||||
std::vector<WorldTile *> m_tiles { 8, nullptr };
|
||||
|
||||
void SetTile(TileDirection direction, WorldTile* tile) {
|
||||
m_tiles[static_cast<int>(direction)] = tile;
|
||||
}
|
||||
|
||||
WorldTile* GetTile(TileDirection direction) {
|
||||
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
|
||||
{
|
||||
class WorldGridManager {
|
||||
public:
|
||||
WorldGridManager();
|
||||
~WorldGridManager();
|
||||
surroundingTiles GetSurroundingTiles(const WorldTile* world_tile);
|
||||
Vector2f GetIndexFromPosition(Vector2f position);
|
||||
static Vector2f GetIndexFromPosition(Vector2f position);
|
||||
|
||||
WorldGridManager(const WorldGridManager& other) = default;
|
||||
WorldGridManager(const WorldGridManager& other) = delete;
|
||||
WorldGridManager(WorldGridManager&& other) = default;
|
||||
WorldGridManager& operator=(const WorldGridManager& other) = delete;
|
||||
WorldGridManager& operator=(WorldGridManager&& other) = delete;
|
||||
|
||||
|
||||
WorldTile * GetTileAtIndex(const int x, const int y) const;
|
||||
WorldTile * GetTileAtWorldPos(const Vector2f& pos) const;
|
||||
|
||||
Reference in New Issue
Block a user