This commit is contained in:
2026-04-07 13:36:18 +02:00
parent e6eeb3396a
commit a50223fcd7
4 changed files with 257 additions and 143 deletions

View File

@@ -63,7 +63,7 @@ class Player {
void update(float delta_time);
[[nodiscard]] auto isOnBorder() const -> bool { return border_ != Room::Border::NONE; }
[[nodiscard]] auto getBorder() const -> Room::Border { return border_; }
void switchBorders();
void commitToRoom(Room::Border border);
auto getRect() -> SDL_FRect { return {.x = x_, .y = y_, .w = WIDTH, .h = HEIGHT}; }
auto getCollider() -> SDL_FRect& { return collider_box_; }
auto getSpawnParams() -> SpawnData { return {.x = x_, .y = y_, .vx = vx_, .vy = vy_, .last_grounded_position = last_grounded_position_, .state = state_, .flip = sprite_->getFlip()}; }
@@ -71,6 +71,9 @@ class Player {
void setSkin(const std::string& skin_name);
static auto skinToAnimationPath(const std::string& skin_name) -> std::string;
void setRoom(std::shared_ptr<Room> room) { room_ = std::move(room); }
void setAdjacentRoom(std::shared_ptr<Room> room, Room::Border direction);
void clearAdjacentRoom();
[[nodiscard]] auto isFullyOutOfBounds() const -> bool;
[[nodiscard]] auto isAlive() const -> bool { return is_alive_; }
void setPaused(bool value) { is_paused_ = value; }
void setIgnoreInput(bool value) { ignore_input_ = value; }
@@ -86,8 +89,18 @@ class Player {
static constexpr int WIDTH = 12;
static constexpr int HEIGHT = 24;
// --- Contexto de colisión (selección de room + traducción de coordenadas) ---
struct CollisionContext {
const TileCollider& tc;
float offset_x;
float offset_y;
};
auto getCollisionContext() const -> CollisionContext;
// --- Objetos y punteros ---
std::shared_ptr<Room> room_;
std::shared_ptr<Room> adjacent_room_;
Room::Border adjacent_direction_{Room::Border::NONE};
std::unique_ptr<AnimatedSprite> sprite_;
// --- Posición y física ---