better cam controls

This commit is contained in:
2023-06-07 12:33:10 +02:00
parent 148b5f397a
commit 368bc450ce
3 changed files with 8 additions and 7 deletions

View File

@@ -33,7 +33,6 @@ void WorldRenderer::LoadModels() {
WorldRenderer::WorldRenderer(game::World* world, client::ClientGame* client) : m_Client(client), m_Renderer(m_Client->GetRenderer()), m_World(world), m_Zoom(0.1) {
m_Renderer->SetZoom(m_Zoom);
m_Renderer->SetCamMovement({});
m_TowerPlacePopup = std::make_unique<gui::TowerPlacePopup>(m_Client->GetClient());
m_TowerUpgradePopup = std::make_unique<gui::TowerUpgradePopup>(m_Client->GetClient());
m_MobTooltip = std::make_unique<gui::MobTooltip>(m_Client->GetClient());
@@ -52,8 +51,9 @@ void WorldRenderer::Update() {
ImGuiIO& io = ImGui::GetIO();
if (io.MouseDown[0] && !ImGui::IsAnyItemActive() && !ImGui::IsAnyItemHovered()) {
ImVec2 mousePos = ImGui::GetIO().MousePos;
ImVec2 mouseDelta = ImGui::GetIO().MouseDelta;
m_Renderer->SetCamMovement({ mouseDelta.x, mouseDelta.y });
m_Renderer->SetCamMovement({mousePos.x - mouseDelta.x, mousePos.y - mouseDelta.y}, { mousePos.x, mousePos.y });
}
if (io.MouseDown[1] && !ImGui::IsAnyItemActive() && !ImGui::IsAnyItemHovered()) {