summaryrefslogtreecommitdiffhomepage
path: root/src/critter.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-29 21:34:46 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-01 06:06:53 +0100
commit5afe42d6a81eeb81db08d4bd2107ac4c71f6671e (patch)
treebab0a6f354047377742fb9cbd8be5d067400c6c1 /src/critter.cpp
parent74387a4aa6117abcc814bc26c3c9ede98fdfa5bc (diff)
wip debug code
Diffstat (limited to 'src/critter.cpp')
-rw-r--r--src/critter.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/critter.cpp b/src/critter.cpp
index 77933b77..1a4f77a1 100644
--- a/src/critter.cpp
+++ b/src/critter.cpp
@@ -9,7 +9,8 @@
#include <cmath>
#include <utility>
#include <algorithm>
-#include <Magnum/Math/Functions.h>
+#include <mg/Functions.h>
+#include <mg/Timeline.h>
namespace floormat {
@@ -168,10 +169,13 @@ void critter::update_movement(size_t i, float dt, rotation new_r)
int nframes = allocate_frame_time(dt * speed);
if (nframes == 0)
+ {
+ static unsigned foo;
+ Debug{} << ++foo << "stopped";
return;
+ }
const auto rotations = rotation_to_similar(new_r);
-
const unsigned nvecs = (int)new_r & 1 ? 3 : 1;
if (r != new_r)
@@ -180,6 +184,23 @@ void critter::update_movement(size_t i, float dt, rotation new_r)
c->ensure_passability();
+ static Timeline TL{};
+ static double TIME;
+ static unsigned FRAMES;
+
+ if (++FRAMES == 0)
+ TL.start();
+ else
+ TIME += (double)dt;
+
+ if (++FRAMES > 30)
+ {
+ Debug{} << "player time" << TIME;
+ TL.stop();
+ TIME = 0;
+ FRAMES = 0;
+ }
+
for (int k = 0; k < nframes; k++)
{
for (unsigned j = 0; j < nvecs; j++)