summary refs log tree commit diff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6e78dab..1c6aa27 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2,6 +2,7 @@
 #include <GL/glew.h>
 #include <GLFW/glfw3.h>
 
+#include "Time.hpp"
 #include "Common/Sizes.hpp"
 #include "GFX/Window.hpp"
 #include "GFX/Camera.hpp"
@@ -23,7 +24,7 @@
 
 void run();
 void render(const MC::GFX::BindableMesh&, const MC::GFX::Texture&);
-void process_input(MC::GFX::Window&, MC::GFX::Camera&);
+void process_input(MC::GFX::Window&, MC::GFX::Camera&, MC::Time&);
 void setup_gl();
 void fix_macos_render(const MC::GFX::Window&);
 
@@ -93,16 +94,17 @@ void run() {
     glFrontFace(GL_CCW);
     glCullFace(GL_BACK);
 
-    U64 time = 0;
+    MC::Time time;
 
     while (!window.should_close()) {
+        time.start_frame();
         window.start_frame();
 
 #ifdef __APPLE__
         fix_macos_render(window);
 #endif
 
-        process_input(window, camera);
+        process_input(window, camera, time);
         clouds.update(time);
 
         glClearColor(sky_color.x(), sky_color.y(), sky_color.z(), 1.0f); // #DBDBDB
@@ -129,7 +131,7 @@ void run() {
 
         clouds.render(camera);
 
-        time++;
+        time.end_frame();
     }
 }
 
@@ -141,7 +143,7 @@ void render(const MC::GFX::BindableMesh& mesh, const MC::GFX::Texture& texture)
     texture.unbind();
 }
 
-void process_input(MC::GFX::Window& window, MC::GFX::Camera& camera) {
+void process_input(MC::GFX::Window& window, MC::GFX::Camera& camera, MC::Time& time) {
     if (window.key(GLFW_KEY_ESCAPE, GLFW_PRESS)) {
         window.close();
     }
@@ -153,10 +155,10 @@ void process_input(MC::GFX::Window& window, MC::GFX::Camera& camera) {
     Real x = key(GLFW_KEY_D) - key(GLFW_KEY_A);
     Real y = key(GLFW_KEY_SPACE) - key(GLFW_KEY_LEFT_SHIFT);
     Real z = key(GLFW_KEY_S) - key(GLFW_KEY_W);
-    Real boost = key(GLFW_KEY_LEFT_CONTROL) * 2.0f;
+    Real boost = key(GLFW_KEY_LEFT_CONTROL) * 75.0f;
 
-    auto move_speed = 0.2f + boost;
-    auto rotation_speed = 0.1f;
+    auto move_speed = (20.0f + boost) * time.delta();
+    auto rotation_speed = 5.0f * time.delta();
 
     camera.move_relative({x * move_speed, 0.0f, z * move_speed});
     camera.move({0.0f, y * move_speed, 0.0f});