diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-12 17:09:16 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-12 17:09:16 +0200 |
commit | 45de7d0537d2caec7d0a7ede48e2b72301bc9da9 (patch) | |
tree | af17dd093da09dc77a3a07a3d4835a1b5e5b85f6 /src/Render.cpp | |
parent | 2017-08-07 (diff) | |
download | AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.gz AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.bz2 AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.lz AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.xz AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.zst AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Render.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Render.cpp b/src/Render.cpp index 38a6ab0..aec60aa 100644 --- a/src/Render.cpp +++ b/src/Render.cpp @@ -125,6 +125,9 @@ void Render::HandleEvents() { case sf::Keyboard::D: EventAgregator::PushEvent(EventType::KeyPressed, KeyPressedData{ sf::Keyboard::D }); break; + case sf::Keyboard::Space: + EventAgregator::PushEvent(EventType::KeyPressed, KeyPressedData{ sf::Keyboard::Space }); + break; default: break; } @@ -143,6 +146,9 @@ void Render::HandleEvents() { case sf::Keyboard::D: EventAgregator::PushEvent(EventType::KeyReleased, KeyReleasedData{ sf::Keyboard::D }); break; + case sf::Keyboard::Space: + EventAgregator::PushEvent(EventType::KeyReleased, KeyReleasedData{ sf::Keyboard::Space }); + break; default: break; } @@ -158,7 +164,7 @@ void Render::HandleMouseCapture() { sf::Mouse::setPosition(center, *window); mouseXDelta = (mousePos - center).x, mouseYDelta = (center - mousePos).y; const float Sensetivity = 0.7f; - EventAgregator::DirectEventCall(EventType::MouseMoved, MouseMovedData{ mouseXDelta * Sensetivity, mouseYDelta }); + EventAgregator::DirectEventCall(EventType::MouseMoved, MouseMovedData{ mouseXDelta * Sensetivity, mouseYDelta * Sensetivity}); } void Render::SetMouseCapture(bool IsCaptured) { @@ -203,7 +209,7 @@ void Render::ExecuteRenderLoop() { window->setTitle("Connecting"); }); - LoopExecutionTimeController timer(std::chrono::milliseconds(16)); + LoopExecutionTimeController timer(std::chrono::milliseconds(32)); while (isRunning) { HandleEvents(); if (isMouseCaptured) HandleMouseCapture(); @@ -212,8 +218,8 @@ void Render::ExecuteRenderLoop() { RenderFrame(); while (listener.IsEventsQueueIsNotEmpty()) listener.HandleEvent(); - if (renderWorld) - window->setTitle("FPS: "+std::to_string(1.0/timer.GetDeltaMs()*1000.0)); + if (renderWorld) + window->setTitle("FPS: " + std::to_string(1.0 / timer.GetRealDeltaS())); timer.Update(); } EventAgregator::PushEvent(EventType::Exit, ExitData{}); |