mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-18 17:59:21 +01:00
Rework Tile detection system
This commit is contained in:
@@ -23,8 +23,23 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport):
|
||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
int actualX = x - WORLD_WIDTH / 2;
|
||||
Point2f pos = Point2f{ float(actualX * TILE_WIDTH), -float(y * TILE_HEIGHT) - TILE_HEIGHT};
|
||||
GroundTileType type = rand() % 2 == 0 ? Tiles::DIRT : Tiles::DIRT;
|
||||
m_gridManager.SetTileAtIndex(x,y, new WorldTile{ pos, Tiles::DIRT, TextureManager::GetInstance() });
|
||||
GroundTileType* type = Tiles::AIR;
|
||||
switch(utils::randRange(0,2)) {
|
||||
case 0:
|
||||
type = Tiles::DIRT;
|
||||
break;
|
||||
case 1:
|
||||
type = Tiles::IRON;
|
||||
break;
|
||||
case 2:
|
||||
//AIR
|
||||
break;
|
||||
default:
|
||||
std::cout << "??" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
m_gridManager.SetTileAtIndex(x,y, new WorldTile{ pos, type, TextureManager::GetInstance() });
|
||||
}
|
||||
}
|
||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
@@ -92,7 +107,7 @@ void WorldLevel::Draw() const {
|
||||
//loop over worldtiles
|
||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
if(m_gridManager.GetTileAtIndex(x,y)->GetTileType() == Tiles::DIRT) {
|
||||
if(*m_gridManager.GetTileAtIndex(x,y)->GetTileType() != Tiles::AIR) {
|
||||
Collision::CollisionRect rect = m_gridManager.GetTileAtIndex(x,y)->GetCollisionRect().getCollisionRect();
|
||||
utils::SetColor(Colors::GREEN);
|
||||
utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
|
||||
|
||||
Reference in New Issue
Block a user