sinus speed is displaying frames of the animation now
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// src/game/state.cpp
|
||||
#include "state.h"
|
||||
#include <cmath>
|
||||
#include "../render/player.h"
|
||||
#include "../timing/speed_controller.h"
|
||||
|
||||
@@ -19,8 +20,14 @@ void WalkingState::start_crawl() {
|
||||
}
|
||||
|
||||
// TODO THIS NEEDS REDESIGN ACCORDING TO SPEED
|
||||
void WalkingState::toggle_walk_frame(int step) {
|
||||
run_index = (run_index + step) % 7;
|
||||
void WalkingState::toggle_walk_frame(float player_speed, int tick_counter) {
|
||||
constexpr int FRAME_COUNT = 8;
|
||||
float phase_speed = player_speed * 0.1f; // tune this scaling for animation tempo
|
||||
|
||||
float phase = fmodf(tick_counter * phase_speed, 1.0f);
|
||||
int frame = static_cast<int>((1.0f - fabsf(sinf(phase * M_PI))) * (FRAME_COUNT - 1));
|
||||
|
||||
run_index = frame;
|
||||
}
|
||||
// void RunningState::toggle_run_frame() {
|
||||
// if (++run_index >= 7) run_index = 0;
|
||||
|
||||
Reference in New Issue
Block a user