Added Buildings

Fixed rendering bugs with edges
This commit is contained in:
Bram Verhulst
2024-04-22 00:32:06 +02:00
parent 5477b8a7f2
commit e578a77d84
10 changed files with 66 additions and 19 deletions

View File

@@ -104,6 +104,14 @@ void WorldTile::DrawSide(const TileDirection& direction) {
const WorldTile* tile = m_SurroundingTiles.GetTile(direction);
if(tile != nullptr) {
const GroundTileTypes type = tile->GetTileType()->getType();
if(direction == TileDirection::BottomMiddle || direction == TileDirection::BottomLeft || direction == TileDirection::BottomRight) {
if(type == Tiles::Special::GRASS->getType() || type == Tiles::Special::HARD_LEFT->getType() || type == Tiles::Special::HARD_MIDDLE->getType() || type == Tiles::Special::HARD_RIGHT->getType()) {
//Fix for edges being renderd on grass / hard tiles
//TODO: Possible fix if i have time
return;
}
}
if(type != Tiles::AIR->getType()) {
m_SideTextures[direction]->Draw(m_Position);
}

View File

@@ -10,6 +10,7 @@ enum class GroundTileTypes
{
Air,
Dirt,
Grass,
Hard,
Stone,
Iron
@@ -97,7 +98,7 @@ namespace Tiles
static GroundTileType* HARD_RIGHT = new GroundTileType("tiles/dirt/special/hardRight.png", GroundTileTypes::Hard);
static GroundTileType* HARD_MIDDLE = new GroundTileType("tiles/dirt/special/hardMiddle.png", GroundTileTypes::Hard);
static GroundTileType* GRASS = new RandomGroundTile("tiles/dirt/special/grass[0].png", GroundTileTypes::Dirt, 2);
static GroundTileType* GRASS = new RandomGroundTile("tiles/dirt/special/grass[0].png", GroundTileTypes::Grass, 2);
}
}

View File

@@ -45,12 +45,36 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
}
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
m_gridManager.GetTileAtIndex(x, 0)->SetTileType(Tiles::AIR);
m_gridManager.GetTileAtIndex(x, 1)->SetTileType(Tiles::IRON);
m_gridManager.GetTileAtIndex(x, 1)->SetTileType(Tiles::Special::GRASS);
}
m_refeulBuilding = new Building { "buildings/fuelStation.png", Vector2f { -700, -50 }, TextureManager::GetInstance() };
m_refeulBuilding = new Building { "buildings/fuelStation.png", Vector2f { -700, -52 }, TextureManager::GetInstance() };
m_gridManager.GetTileAtWorldPos(Vector2f { -700, -50 })->SetTileType(Tiles::Special::HARD_LEFT);
m_gridManager.GetTileAtWorldPos(Vector2f { -650, -50 })->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f { -600, -50 })->SetTileType(Tiles::Special::HARD_RIGHT);
m_mineralBuilding = new Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, TextureManager::GetInstance() };
m_gridManager.GetTileAtWorldPos(Vector2f {-400, -50})->SetTileType(Tiles::Special::HARD_LEFT);
m_gridManager.GetTileAtWorldPos(Vector2f {-350, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {-300, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {-250, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {-200, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {-150, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
m_junkBuilding = new Building { "buildings/junkStation.png", Vector2f { 250, -52 }, TextureManager::GetInstance() };
m_gridManager.GetTileAtWorldPos(Vector2f {200, -50})->SetTileType(Tiles::Special::HARD_LEFT);
m_gridManager.GetTileAtWorldPos(Vector2f {250, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {300, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {350, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {400, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {450, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
m_repairBuilding = new Building { "buildings/repairStation.png", Vector2f { 700, -52 }, TextureManager::GetInstance() };
m_gridManager.GetTileAtWorldPos(Vector2f {650, -50})->SetTileType(Tiles::Special::HARD_LEFT);
m_gridManager.GetTileAtWorldPos(Vector2f {700, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {750, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
m_gridManager.GetTileAtWorldPos(Vector2f {800, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
}
WorldLevel::~WorldLevel() {
//delete m_pTextTexture;
@@ -137,6 +161,9 @@ void WorldLevel::Draw() const {
}
m_refeulBuilding->Draw();
m_mineralBuilding->Draw();
m_junkBuilding->Draw();
m_repairBuilding->Draw();
m_player.Draw();
utils::SetColor(Colors::GREEN);

View File

@@ -40,6 +40,9 @@ private:
WorldTile* m_pSelectedTile { nullptr };
Building* m_refeulBuilding;
Building* m_mineralBuilding;
Building* m_junkBuilding;
Building* m_repairBuilding;
float testLerp{ 0.0f };