Vulkan demo: Improve movements

This commit is contained in:
Lynix 2017-08-14 01:54:15 +02:00
parent 037274a57f
commit e2248ce543
1 changed files with 17 additions and 15 deletions

View File

@ -658,6 +658,7 @@ int main()
window.EnableEventPolling(true); window.EnableEventPolling(true);
Nz::Clock updateClock;
Nz::Clock secondClock; Nz::Clock secondClock;
unsigned int fps = 0; unsigned int fps = 0;
while (window.IsOpen()) while (window.IsOpen())
@ -692,23 +693,24 @@ int main()
updateUniforms = true; updateUniforms = true;
break; break;
} }
}
}
case Nz::WindowEventType_KeyPressed: if (updateClock.GetMilliseconds() > 1000 / 60)
{ {
switch (event.key.code) float elapsedTime = updateClock.GetSeconds();
{ updateClock.Restart();
case Nz::Keyboard::Up:
viewerPos += camQuat * Nz::Vector3f::Forward();
updateUniforms = true;
break;
case Nz::Keyboard::Down: if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up))
viewerPos += camQuat * Nz::Vector3f::Backward(); {
updateUniforms = true; viewerPos += camQuat * Nz::Vector3f::Forward() * elapsedTime;
break; updateUniforms = true;
} }
break;
} if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down))
{
viewerPos += camQuat * Nz::Vector3f::Backward() * elapsedTime;
updateUniforms = true;
} }
} }