mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 20:41:47 +01:00
Fixed sidePieces (Need to add more cases tho)
This commit is contained in:
@@ -15,10 +15,17 @@ WorldTile::WorldTile(const Point2f& position, GroundTileType* groundTileType, Te
|
||||
// m_pTexture = new Texture(dirtPath);
|
||||
m_pTexture = pTextureManager->GetTexture(groundTileType->getPath());
|
||||
|
||||
m_pBottomLeftTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/bottomRight.png");
|
||||
m_pBottomRightTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/bottomLeft.png");
|
||||
m_pTopLeftTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/topRight.png");
|
||||
m_pTopRightTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/topLeft.png");
|
||||
m_pBottomLeftTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/bottomLeft.png");
|
||||
m_pBottomRightTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/bottomRight.png");
|
||||
m_pTopLeftTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/topLeft.png");
|
||||
m_pTopRightTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/topRight.png");
|
||||
|
||||
m_pMiddleBottomTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/middleBottom.png");
|
||||
m_pMiddleTopTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/middleTop.png");
|
||||
m_pMiddleLeftTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/middleLeft.png");
|
||||
m_pMiddleRightTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/middleRight.png");
|
||||
|
||||
m_pAllTexture = pTextureManager->GetTexture("tiles/dirt/sidepieces/all.png");
|
||||
}
|
||||
WorldTile::~WorldTile() {
|
||||
delete m_pTexture;
|
||||
@@ -32,25 +39,117 @@ void WorldTile::Draw() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(m_Hightlight) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
WorldTile* tile = m_SurroundingTiles.GetTile(static_cast<TileDirection>(i));
|
||||
if(tile != nullptr) { //Tile exists
|
||||
//TODO: Wow Big mess
|
||||
GroundTileTypes type = tile->GetTileType()->getType();
|
||||
if(type == Tiles::AIR->getType()) {
|
||||
utils::SetColor(Colors::BLACK);
|
||||
utils::FillRect(Rectf{tile->GetPosition(), Point2f{50,50}});
|
||||
continue;
|
||||
}
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
utils::SetColor(Colors::YELLOW);
|
||||
utils::FillRect(Rectf{tile->GetPosition(), Point2f{50,50}});
|
||||
}
|
||||
//check if it's all around dirt
|
||||
bool allDirt = true;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
WorldTile* tile = m_SurroundingTiles.GetTile(static_cast<TileDirection>(i));
|
||||
if(tile != nullptr) { //Tile exists
|
||||
GroundTileTypes type = tile->GetTileType()->getType();
|
||||
if(type != Tiles::DIRT->getType()) {
|
||||
allDirt = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(allDirt) {
|
||||
m_pAllTexture->Draw(m_Position);
|
||||
return;
|
||||
}
|
||||
|
||||
if(*m_GroundTileType == Tiles::AIR) {
|
||||
WorldTile* topLeft = m_SurroundingTiles.GetTile(TileDirection::TopLeft);
|
||||
if(topLeft != nullptr) {
|
||||
GroundTileTypes type = topLeft->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pTopLeftTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
WorldTile* topRight = m_SurroundingTiles.GetTile(TileDirection::TopRight);
|
||||
if(topRight != nullptr) {
|
||||
GroundTileTypes type = topRight->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pTopRightTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
WorldTile* bottomLeft = m_SurroundingTiles.GetTile(TileDirection::BottomLeft);
|
||||
if(bottomLeft != nullptr) {
|
||||
GroundTileTypes type = bottomLeft->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pBottomLeftTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
WorldTile* bottomRight = m_SurroundingTiles.GetTile(TileDirection::BottomRight);
|
||||
if(bottomRight != nullptr) {
|
||||
GroundTileTypes type = bottomRight->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pBottomRightTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
WorldTile* middleTop = m_SurroundingTiles.GetTile(TileDirection::TopMiddle);
|
||||
if(middleTop != nullptr) {
|
||||
GroundTileTypes type = middleTop->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pMiddleTopTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
WorldTile* middleBottom = m_SurroundingTiles.GetTile(TileDirection::BottomMiddle);
|
||||
if(middleBottom != nullptr) {
|
||||
GroundTileTypes type = middleBottom->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pMiddleBottomTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
WorldTile* middleLeft = m_SurroundingTiles.GetTile(TileDirection::MiddleLeft);
|
||||
if(middleLeft != nullptr) {
|
||||
GroundTileTypes type = middleLeft->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pMiddleLeftTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
WorldTile* middleRight = m_SurroundingTiles.GetTile(TileDirection::MiddleRight);
|
||||
if(middleRight != nullptr) {
|
||||
GroundTileTypes type = middleRight->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pMiddleRightTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
WorldTile* bottomMiddle = m_SurroundingTiles.GetTile(TileDirection::BottomMiddle);
|
||||
if(bottomMiddle != nullptr) {
|
||||
GroundTileTypes type = bottomMiddle->GetTileType()->getType();
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_pMiddleBottomTexture->Draw(m_Position);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// if(m_Hightlight) {
|
||||
// for (int i = 0; i < 8; i++) {
|
||||
// WorldTile* tile = m_SurroundingTiles.GetTile(static_cast<TileDirection>(i));
|
||||
// if(tile != nullptr) { //Tile exists
|
||||
// //TODO: Wow Big mess
|
||||
// GroundTileTypes type = tile->GetTileType()->getType();
|
||||
// if(type == Tiles::AIR->getType()) {
|
||||
// utils::SetColor(Colors::BLACK);
|
||||
// utils::FillRect(Rectf{tile->GetPosition(), Point2f{50,50}});
|
||||
// continue;
|
||||
// }
|
||||
// if(type != Tiles::AIR->getType()) {
|
||||
// utils::SetColor(Colors::YELLOW);
|
||||
// utils::FillRect(Rectf{tile->GetPosition(), Point2f{50,50}});
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//Tile is air, So check 8 tiles around
|
||||
// Check the 4 tiles diagonally
|
||||
|
||||
Reference in New Issue
Block a user