proper positioning works now

This commit is contained in:
Priec
2025-11-14 18:50:57 +01:00
parent cda395d6b9
commit 9170524d33
4 changed files with 10 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
// src/render/player_positioning.cpp
#include "player_positioning.h"
#include "../background_dark_inverted.h"
#include <cstdio>
// Convert a pivot coordinate (bottom-left) to the top-left draw position
@@ -15,11 +16,9 @@ PlayerPosition get_aligned_frame_position(PlayerPosition base, int frame_index)
else
sprite_height = PLAYER_MASK_LINES_FRAME_3;
// The X coordinate stays the same (left edge aligned)
// The Y coordinate moves upward by the sprite height,
// because the pivot is bottom-left, but rendering starts from top-left
PlayerPosition draw_pos;
draw_pos.x = base.x;
draw_pos.y = base.y - sprite_height + 1; // align to feet baseline
draw_pos.y = (VIEW_HEIGHT - base.y) - sprite_height;
return draw_pos;
}