calculations

This commit is contained in:
Priec
2025-11-14 17:31:37 +01:00
parent d8da84cffc
commit cda395d6b9
3 changed files with 40 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
// src/render/loop.cpp
#include "loop.h"
#include "../background_dark_inverted.h"
#include "player_positioning.h"
#include "background.h"
#include "mbed.h"
#include "player.h"
@@ -25,11 +26,6 @@ struct WalkingState {
Timer state_timer;
};
struct PlayerPosition {
int x;
int y;
};
static char rx_buffer[BUFFER_SIZE];
static char message[BUFFER_SIZE];
static bool message_active = false;
@@ -133,7 +129,7 @@ void render_loop(int speed) {
anim_timer.start();
int shift = 0;
PlayerPosition pos = {9, 3};
PlayerPosition pos = {9, 9};
const char *bg_file = "background_dark_inverted.txt";
bool need_redraw = false;
@@ -162,7 +158,8 @@ void render_loop(int speed) {
if (need_redraw) {
draw_mask(bg_file, shift, message_active ? message : nullptr);
int player_frame = get_player_frame(player_state.current_state);
draw_player(pos.x, pos.y, player_frame);
PlayerPosition draw_pos = get_aligned_frame_position(pos, player_frame);
draw_player(draw_pos.x, draw_pos.y, player_frame);
// alternate between frame 0 and 1 when not crawling
if (player_state.current_state != PlayerState::Crawl1) {