Преглед на файлове

Using a time scale of timer ticks -> 1/100th precision.

Eiyeron Fulmincendii преди 10 години
родител
ревизия
4c5eaa18da
променени са 2 файла, в които са добавени 8 реда и са изтрити 6 реда
  1. 4 2
      src/engine/StateMachine.cpp
  2. 4 4
      src/engine/main.cpp

+ 4 - 2
src/engine/StateMachine.cpp

@@ -5,6 +5,8 @@
 #include "render/Text.h"
 #include "version.h"
 #include "Input.h"
+#include <iostream>
+using namespace std;
 
 using namespace WalrusRPG::Graphics;
 using namespace WalrusRPG::States;
@@ -45,7 +47,7 @@ void STATEMACHINE::run()
     {
         update_stamp = Timing::gettime();
         update_time = update_stamp - last_update;
-        stack.back()->update(update_time);
+        stack.back()->update(100*update_time/TIMER_FREQ);
         last_update = update_stamp;
 
         if (Timing::gettime() < loop_next)
@@ -53,7 +55,7 @@ void STATEMACHINE::run()
             frame_stamp = Timing::gettime();
             frame_time = frame_stamp - last_frame;
             Graphics::frame_begin();
-            stack.back()->render(frame_time);
+            stack.back()->render(100*frame_time/TIMER_FREQ);
             last_frame = frame_stamp;
 
             Text::print_format(0, 0, "WalrusRPG test build %s", git_version);

+ 4 - 4
src/engine/main.cpp

@@ -69,10 +69,10 @@ int main(int argc, char *argv[])
     Map map(20, 20, dungeonTest, dungeonTest2);
     tinystl::vector<Frame> stripe21;
     tinystl::vector<Frame> stripe22;
-    stripe21.push_back({21, 23 * 546});
-    stripe21.push_back({22, 31 * 546});
-    stripe22.push_back({22, 37 * 546});
-    stripe22.push_back({21, 41 * 546});
+    stripe21.push_back({21, 23});
+    stripe21.push_back({22, 31});
+    stripe22.push_back({22, 37});
+    stripe22.push_back({21, 41});
     map.anim.add_animation(21, {stripe21, true, 0});
     map.anim.add_animation(22, {stripe22, true, 0});