mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 18:41:48 +01:00
Add more ores
Add weighted random distribution
This commit is contained in:
@@ -21,26 +21,12 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
m_viewport(viewport),
|
||||
m_screenManager(ScreenManager::GetInstance()) {
|
||||
// The grid is 34 x 50 big, the top center is 0,0 in world coords
|
||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
const int actualX = x - WORLD_WIDTH / 2;
|
||||
Vector2f pos = Vector2f { float(actualX * TILE_WIDTH), -float(y * TILE_HEIGHT) - TILE_HEIGHT };
|
||||
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 << "??" << '\n';
|
||||
}
|
||||
|
||||
m_gridManager.SetTileAtIndex(x, y, new WorldTile { pos, Tiles::DIRT, TextureManager::GetInstance(), &m_gridManager });
|
||||
GroundTileType* type = getRandomGroundTile();
|
||||
m_gridManager.SetTileAtIndex(x, y, new WorldTile { pos, type, TextureManager::GetInstance(), &m_gridManager });
|
||||
}
|
||||
}
|
||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
@@ -257,9 +243,11 @@ void WorldLevel::ProcessImGui() {
|
||||
if (m_ShowCameraWindow) {
|
||||
ImGui::Begin("Camera", &m_ShowCameraWindow, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::Text("Camera Position: (%f, %f)", m_pCamera->GetPosition().x, m_pCamera->GetPosition().y);
|
||||
ImGui::Text("Camera Scale: %f", m_pCamera->GetScale());
|
||||
ImGui::Text("Is Right Mouse Down: %s", utils::isMouseDown(0) ? "true" : "false");
|
||||
if (ImGui::Button("Reset Camera")) {
|
||||
m_pCamera->SetPosition(Vector2f { -m_viewport.width / 2, -m_viewport.height / 2 });
|
||||
m_pCamera->SetScale(1.0f);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user