proves3
This commit is contained in:
@@ -446,31 +446,6 @@ auto Player::handleBorders() const -> Room::Border {
|
||||
return Room::Border::NONE;
|
||||
}
|
||||
|
||||
// Reposiciona al jugador al hacer commit definitivo a la room adyacente.
|
||||
// Se llama cuando el rectángulo completo del jugador ha salido de bounds.
|
||||
void Player::commitToRoom(Room::Border border) {
|
||||
switch (border) {
|
||||
case Room::Border::TOP:
|
||||
y_ += PlayArea::HEIGHT;
|
||||
last_grounded_position_ = static_cast<int>(y_);
|
||||
break;
|
||||
case Room::Border::BOTTOM:
|
||||
y_ -= PlayArea::HEIGHT;
|
||||
last_grounded_position_ = static_cast<int>(y_);
|
||||
break;
|
||||
case Room::Border::RIGHT:
|
||||
x_ -= PlayArea::WIDTH;
|
||||
break;
|
||||
case Room::Border::LEFT:
|
||||
x_ += PlayArea::WIDTH;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
border_ = Room::Border::NONE;
|
||||
syncSpriteAndCollider();
|
||||
}
|
||||
|
||||
void Player::setAdjacentRoom(std::shared_ptr<Room> room, Room::Border direction) {
|
||||
adjacent_room_ = std::move(room);
|
||||
adjacent_direction_ = direction;
|
||||
@@ -481,23 +456,6 @@ void Player::clearAdjacentRoom() {
|
||||
adjacent_direction_ = Room::Border::NONE;
|
||||
}
|
||||
|
||||
auto Player::isFullyOutOfBounds() const -> bool {
|
||||
switch (adjacent_direction_) {
|
||||
case Room::Border::TOP:
|
||||
return (y_ + HEIGHT) <= PlayArea::TOP;
|
||||
case Room::Border::BOTTOM:
|
||||
return y_ >= PlayArea::BOTTOM;
|
||||
case Room::Border::LEFT:
|
||||
return (x_ + WIDTH) <= PlayArea::LEFT;
|
||||
case Room::Border::RIGHT:
|
||||
return x_ >= PlayArea::RIGHT;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Devuelve el TileCollider correcto y los offsets de traducción de coordenadas
|
||||
// según en qué room está el centro del jugador.
|
||||
auto Player::getCollisionContext() const -> CollisionContext {
|
||||
if (!adjacent_room_) {
|
||||
return {room_->getTileCollider(), 0.0F, 0.0F};
|
||||
@@ -534,6 +492,29 @@ auto Player::getCollisionContext() const -> CollisionContext {
|
||||
return {room_->getTileCollider(), 0.0F, 0.0F};
|
||||
}
|
||||
|
||||
void Player::switchBorders() {
|
||||
switch (border_) {
|
||||
case Room::Border::TOP:
|
||||
y_ += PlayArea::HEIGHT;
|
||||
last_grounded_position_ = static_cast<int>(y_);
|
||||
break;
|
||||
case Room::Border::BOTTOM:
|
||||
y_ -= PlayArea::HEIGHT;
|
||||
last_grounded_position_ = static_cast<int>(y_);
|
||||
break;
|
||||
case Room::Border::RIGHT:
|
||||
x_ -= PlayArea::WIDTH;
|
||||
break;
|
||||
case Room::Border::LEFT:
|
||||
x_ += PlayArea::WIDTH;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
border_ = Room::Border::NONE;
|
||||
syncSpriteAndCollider();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Geometría y renderizado
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user