mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 20:41:47 +01:00
Fix digging
This commit is contained in:
@@ -32,6 +32,51 @@ WorldTile::~WorldTile() {
|
||||
delete m_pTexture;
|
||||
}
|
||||
void WorldTile::Draw() {
|
||||
|
||||
|
||||
switch (m_GroundTileType->getType()) {
|
||||
case GroundTileTypes::Air: {
|
||||
//check if it's all around dirt
|
||||
bool allDirt = true;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
const WorldTile* tile = m_SurroundingTiles.GetTile(static_cast<TileDirection>(i));
|
||||
if(tile != nullptr) { //Tile exists
|
||||
const 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) {
|
||||
this->DrawSide(TileDirection::TopLeft);
|
||||
this->DrawSide(TileDirection::TopRight);
|
||||
this->DrawSide(TileDirection::BottomLeft);
|
||||
this->DrawSide(TileDirection::BottomRight);
|
||||
|
||||
this->DrawSide(TileDirection::TopMiddle);
|
||||
this->DrawSide(TileDirection::BottomMiddle);
|
||||
this->DrawSide(TileDirection::MiddleLeft);
|
||||
this->DrawSide(TileDirection::MiddleRight);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
case GroundTileTypes::Dirt:
|
||||
case GroundTileTypes::Hard:
|
||||
case GroundTileTypes::Stone:
|
||||
case GroundTileTypes::Iron:
|
||||
m_pTexture->Draw(m_Position);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (*m_GroundTileType != Tiles::AIR) {
|
||||
m_pTexture->Draw(m_Position);
|
||||
if (m_Hightlight) {
|
||||
@@ -40,35 +85,9 @@ void WorldTile::Draw() {
|
||||
}
|
||||
}
|
||||
|
||||
//check if it's all around dirt
|
||||
bool allDirt = true;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
const WorldTile* tile = m_SurroundingTiles.GetTile(static_cast<TileDirection>(i));
|
||||
if(tile != nullptr) { //Tile exists
|
||||
const 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) {
|
||||
this->DrawSide(TileDirection::TopLeft);
|
||||
this->DrawSide(TileDirection::TopRight);
|
||||
this->DrawSide(TileDirection::BottomLeft);
|
||||
this->DrawSide(TileDirection::BottomRight);
|
||||
|
||||
this->DrawSide(TileDirection::TopMiddle);
|
||||
this->DrawSide(TileDirection::BottomMiddle);
|
||||
this->DrawSide(TileDirection::MiddleLeft);
|
||||
this->DrawSide(TileDirection::MiddleRight);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WorldTile::Update(const Camera* camera) {
|
||||
|
||||
Reference in New Issue
Block a user