Started on GuiIcon, General fixes

This commit is contained in:
Bram Verhulst
2024-05-09 00:46:05 +02:00
parent d3b932df22
commit 8c3a485c2d
22 changed files with 231 additions and 409 deletions

View File

@@ -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) {