now the movement of the player is working properly well and being calculated based on the speed of the player

This commit is contained in:
Filipriec
2025-11-15 22:40:23 +01:00
parent de6facff03
commit 8cb6892d30
4 changed files with 42 additions and 7 deletions

View File

@@ -10,12 +10,14 @@
#include "../hardware/uart.h"
#include "../render/player.h"
#include "../timing/speed_controller.h"
#include "../timing/movement_controller.h"
extern BufferedSerial serial_port;
extern DigitalOut led;
// Constants
constexpr int PLAYER_X = 9;
// constexpr int PLAYER_X = 9;
constexpr int PLAYER_X = 29;
constexpr int PLAYER_Y = 6;
void draw_mask(const char *unused_filename, int shift, const char *text);
@@ -24,6 +26,7 @@ void render_loop(int speed) {
WalkingState player_state;
AnimationController animation;
UartReader uart(serial_port);
MovementController mover(PLAYER_X, VIEW_WIDTH);
SpeedController timing;
timing.set_ground_speed(speed);
@@ -33,10 +36,14 @@ void render_loop(int speed) {
bool need_redraw = false;
int tick_counter = 0;
int player_speed = 4;
int player_speed = 5;
while (true) {
tick_counter++;
mover.update_position(player_speed, timing.get_ground_speed());
pos.x = mover.get_position();
need_redraw = false;
UartEvent uart_event = uart.poll();