26 lines
812 B
C++
26 lines
812 B
C++
// src/render/player_positioning.cpp
|
|
#include "player_positioning.h"
|
|
#include "../assets/background_frame.h"
|
|
#include <cstdio>
|
|
|
|
// Convert a pivot coordinate (bottom-left) to the top-left draw position
|
|
CharacterPosition get_aligned_frame_position(CharacterPosition base, CharacterFrame frame) {
|
|
int frame_index = static_cast<int>(frame);
|
|
if (frame_index < 0 || frame_index >= CHARACTER_FRAME_COUNT)
|
|
frame_index = 0;
|
|
|
|
int character_height = 0;
|
|
if (frame_index == 0)
|
|
character_height = CHARACTER_HEIGHT_1;
|
|
else if (frame_index == 1)
|
|
character_height = CHARACTER_HEIGHT_2;
|
|
else
|
|
character_height = CHARACTER_HEIGHT_3;
|
|
|
|
CharacterPosition draw_pos;
|
|
draw_pos.x = base.x;
|
|
draw_pos.y = (VIEW_HEIGHT - base.y) - character_height;
|
|
|
|
return draw_pos;
|
|
}
|