summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-04-02 19:17:07 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-04-02 19:17:07 (GMT)
commitbc0abcc53c4c4ce24e24037e3d3465e1a2c1924c (patch)
tree73547b3ef9caf53527aafe1de419ccc5d4fc00ef
parent9991451dcc1174b970f89c726405aa34ed63c06b (diff)
Hopefully improve jump detection
-rw-r--r--src/displayapp/screens/Motion.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index 0b9aab7..e667d52 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -76,14 +76,16 @@ void Motion::Refresh() {
if (started) {
TickType_t current_frame_ms = current_time - last_frame_time;
double G_scaled = G * G_SCALE;
- if (G_scaled < 0.382) {
+ if (G_scaled < 1.000) {
if (!jumping) {
jump_started_or_ended = true;
current_jump_speed = 0;
current_jump_length = 0;
jumping = true;
}
- double current_jump_accel = (1.0 - G_scaled) * 9.8;
+ double jump_ratio = 1.0 - G_scaled;
+ double jump_ratio *= jump_ratio;
+ double current_jump_accel = jump_ratio * 9.8;
double current_frame_s = current_frame_ms * 0.001;
current_jump_speed += current_jump_accel * current_frame_s;
current_jump_length += current_jump_speed * current_frame_s;