mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 20:41:47 +01:00
Temp commit. Textures not working anymor :(
This commit is contained in:
@@ -13,25 +13,23 @@
|
||||
|
||||
WorldLevel::WorldLevel(Camera* camera, Rectf viewport):
|
||||
Level(camera),
|
||||
m_gridManager(WorldGridManager()),
|
||||
m_player(Player { Point2f { 0, 100 } }),
|
||||
m_mousePos { 0, 0 },
|
||||
m_viewport(viewport),
|
||||
m_gridManager(WorldGridManager())
|
||||
m_viewport(viewport)
|
||||
{
|
||||
// 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) {
|
||||
int actualX = x - WORLD_WIDTH / 2;
|
||||
Point2f pos = Point2f{ float(actualX * TILE_WIDTH), -float(y * TILE_HEIGHT) - TILE_HEIGHT};
|
||||
GroundTileTypes type = rand() % 2 == 0 ? GroundTileTypes::Dirt : GroundTileTypes::Dirt;
|
||||
m_gridManager.SetTileAtIndex(x,y, new WorldTile{ pos, type, TextureManager::GetInstance() });
|
||||
GroundTileType type = rand() % 2 == 0 ? Tiles::DIRT : Tiles::DIRT;
|
||||
m_gridManager.SetTileAtIndex(x,y, new WorldTile{ pos, Tiles::DIRT, TextureManager::GetInstance() });
|
||||
}
|
||||
}
|
||||
//
|
||||
// for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
// m_gridManager.GetTileAtIndex(x, 0)->SetTileType(GroundTileTypes::Dirt);
|
||||
// }
|
||||
|
||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
m_gridManager.GetTileAtIndex(x, 0)->SetTileType(Tiles::AIR);
|
||||
}
|
||||
}
|
||||
WorldLevel::~WorldLevel() {
|
||||
//delete m_pTextTexture;
|
||||
@@ -56,7 +54,7 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
}
|
||||
if(selectedTile != nullptr) {
|
||||
if(utils::isMouseDown(SDL_BUTTON_LEFT)) {
|
||||
selectedTile->SetTileType(GroundTileTypes::Air);
|
||||
selectedTile->SetTileType(Tiles::AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +62,7 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
|
||||
WorldTile* t = m_gridManager.GetTileAtWorldPos(m_mousePos);
|
||||
if(t != nullptr) {
|
||||
t->SetTileType(GroundTileTypes::Air);
|
||||
t->SetTileType(Tiles::AIR);
|
||||
}
|
||||
|
||||
//Point2f playerPos = m_player.GetPosition();
|
||||
@@ -82,13 +80,8 @@ void WorldLevel::Draw() const {
|
||||
utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
|
||||
}
|
||||
|
||||
Point2f RayPoint = Point2f{m_pCamera->Viewport.width, m_pCamera->Viewport.height};
|
||||
Point2f RayDir = Point2f{m_mousePos.x - RayPoint.x, m_mousePos.y - RayPoint.y};
|
||||
|
||||
utils::SetColor(Colors::WHITE);
|
||||
utils::DrawLine(RayPoint, m_mousePos);
|
||||
|
||||
utils::FillEllipse(m_mousePos, 20, 20);
|
||||
utils::FillEllipse(m_mousePos, 2, 2);
|
||||
|
||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
@@ -99,7 +92,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() == GroundTileTypes::Dirt) {
|
||||
if(m_gridManager.GetTileAtIndex(x,y)->GetTileType() == Tiles::DIRT) {
|
||||
Collision::CollisionRect rect = m_gridManager.GetTileAtIndex(x,y)->GetCollisionRect().getCollisionRect();
|
||||
utils::SetColor(Colors::GREEN);
|
||||
utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
|
||||
@@ -157,15 +150,7 @@ void WorldLevel::ProcessImGui() {
|
||||
ImGui::Begin("Player Info", &m_ShowPlayerInfo, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::Text("Player Position: (%f, %f)", m_player.GetPosition().x, m_player.GetPosition().y);
|
||||
ImGui::Text("Player Velocity: (%f, %f)", m_player.GetVelocity().x, m_player.GetVelocity().y);
|
||||
//PLAYER COLLISIONS
|
||||
ImGui::Text("Player Collisions:");
|
||||
// for (std::pair<Collision::CollisionDirection, Collision::CollisionRect*> contact : m_player.GetContactMap()) {
|
||||
// ImGui::Text("Direction: %d", contact.first);
|
||||
// ImGui::Text("Position: (%f, %f)", contact.second->pos.x, contact.second->pos.y);
|
||||
// ImGui::Text("Size: (%f, %f)", contact.second->size.x, contact.second->size.y);
|
||||
// }
|
||||
ImGui::End();
|
||||
|
||||
m_player.ProcessImGui();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user