canvi de pc

This commit is contained in:
2025-02-27 07:37:39 +01:00
parent e6fd4225a2
commit c6474cb2da
26 changed files with 903 additions and 991 deletions

View File

@@ -16,106 +16,38 @@
#include "screen.h"
// Constructor
Player::Player(player_t player)
Player::Player(PlayerData player)
: renderer_(Screen::get()->getRenderer()),
input_(Input::get()),
resource_(Resource::get()),
asset_(Asset::get()),
debug_(Debug::get()),
room_(player.room)
{
// Crea objetos
sprite_ = std::make_shared<AnimatedSprite>(resource_->getTexture(player.png), resource_->getAnimation(player.animation));
// Inicializa algunas variables
initSprite(player.texture, player.animation);
setColor();
applySpawnValues(player.spawn);
placeSprite();
initSounds();
// Inicializa variables
reLoadPalette();
is_on_border_ = false;
border_ = BORDER_TOP;
auto_movement_ = false;
is_alive_ = true;
is_paused_ = false;
jump_init_pos_ = player.spawn.jump_init_pos;
state_ = player.spawn.state;
previous_state_ = state_;
x_ = player.spawn.x;
y_ = player.spawn.y;
vx_ = player.spawn.vx;
vy_ = player.spawn.vy;
w_ = 8;
h_ = 16;
sprite_->setPosX(player.spawn.x);
sprite_->setPosY(player.spawn.y);
sprite_->setWidth(8);
sprite_->setHeight(16);
sprite_->setFlip(player.spawn.flip);
sprite_->setCurrentAnimation("walk");
sprite_->update();
last_position_ = getRect();
collider_box_ = getRect();
const SDL_Point p = {0, 0};
collider_points_.insert(collider_points_.end(), {p, p, p, p, p, p, p, p});
under_feet_.insert(under_feet_.end(), {p, p});
feet_.insert(feet_.end(), {p, p});
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump1.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump2.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump3.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump4.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump5.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump6.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump7.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump8.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump9.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump10.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump11.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump12.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump13.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump14.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump15.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump16.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump17.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump18.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump19.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump20.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump21.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump22.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump23.wav").c_str()));
jumping_sound_.push_back(JA_LoadSound(asset_->get("jump24.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump11.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump12.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump13.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump14.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump15.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump16.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump17.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump18.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump19.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump20.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump21.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump22.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump23.wav").c_str()));
falling_sound_.push_back(JA_LoadSound(asset_->get("jump24.wav").c_str()));
jumping_counter_ = 0;
falling_counter_ = 0;
collider_points_.resize(collider_points_.size() + 8, {0, 0});
under_feet_.resize(under_feet_.size() + 2, {0, 0});
feet_.resize(feet_.size() + 2, {0, 0});
#ifdef DEBUG
rx = {0, 0, 0, 0};
ry = {0, 0, 0, 0};
debugColor = {0, 255, 0};
debugPoint = {0, 0};
debug_rect_x_ = {0, 0, 0, 0};
debug_rect_y_ = {0, 0, 0, 0};
debug_color_ = {0, 255, 0};
debug_point_ = {0, 0};
#endif
}
// Pinta el jugador en pantalla
void Player::render()
{
sprite_->getTexture()->setColor(color_.r, color_.g, color_.b);
sprite_->render();
#ifdef DEBUG
@@ -127,7 +59,7 @@ void Player::render()
SDL_RenderDrawPoint(renderer_, under_feet_[1].x, under_feet_[1].y);
// Pinta rectangulo del jugador
SDL_SetRenderDrawColor(renderer_, debugColor.r, debugColor.g, debugColor.b, 192);
SDL_SetRenderDrawColor(renderer_, debug_color_.r, debug_color_.g, debug_color_.b, 192);
SDL_Rect rect = getRect();
SDL_RenderFillRect(renderer_, &rect);
SDL_SetRenderDrawColor(renderer_, 0, 255, 255, 255);
@@ -137,16 +69,16 @@ void Player::render()
SDL_SetRenderDrawColor(renderer_, 255, 0, 0, 255);
if (vx_ != 0.0f)
{
SDL_RenderFillRect(renderer_, &rx);
SDL_RenderFillRect(renderer_, &debug_rect_x_);
}
if (vy_ != 0.0f)
{
SDL_RenderFillRect(renderer_, &ry);
SDL_RenderFillRect(renderer_, &debug_rect_y_);
}
// Pinta el punto de debug
SDL_SetRenderDrawColor(renderer_, rand() % 256, rand() % 256, rand() % 256, 255);
SDL_RenderDrawPoint(renderer_, debugPoint.x, debugPoint.y);
SDL_RenderDrawPoint(renderer_, debug_point_.x, debug_point_.y);
}
#endif
}
@@ -154,30 +86,28 @@ void Player::render()
// Actualiza las variables del objeto
void Player::update()
{
if (is_paused_)
{ // Si está en modo pausa no se actualiza nada
return;
if (!is_paused_)
{
checkInput(); // Comprueba las entradas y modifica variables
move(); // Recalcula la posición del jugador
animate(); // Establece la animación del jugador
checkBorders(); // Comprueba si está situado en alguno de los cuatro bordes de la habitación
checkJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio
checkKillingTiles(); // Comprueba que el jugador no toque ningun tile de los que matan}
}
checkInput(); // Comprueba las entradas y modifica variables
move(); // Recalcula la posición del jugador
animate(); // Establece la animación del jugador
checkBorders(); // Comprueba si está situado en alguno de los cuatro bordes de la habitación
checkJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio
checkKillingTiles(); // Comprueba que el jugador no toque ningun tile de los que matan
}
// Comprueba las entradas y modifica variables
void Player::checkInput()
{
// Solo comprueba las entradas de dirección cuando está sobre una superficie
if (state_ != s_standing)
if (state_ != PlayerState::STANDING)
{
return;
}
if (!auto_movement_)
{
{
// Comprueba las entradas de desplazamiento lateral solo en el caso de no estar enganchado a una superficie automatica
if (input_->checkInput(input_left))
{
@@ -223,7 +153,7 @@ void Player::checkInput()
if (isOnFloor() || isOnAutoSurface())
{
setState(s_jumping);
setState(PlayerState::JUMPING);
vy_ = -MAX_VY_;
jump_init_pos_ = y_;
jumping_counter_ = 0;
@@ -231,18 +161,6 @@ void Player::checkInput()
}
}
// Indica si el jugador esta en uno de los cuatro bordes de la pantalla
bool Player::getOnBorder()
{
return is_on_border_;
}
// Indica en cual de los cuatro bordes se encuentra
int Player::getBorder()
{
return border_;
}
// Comprueba si está situado en alguno de los cuatro bordes de la habitación
void Player::checkBorders()
{
@@ -252,7 +170,7 @@ void Player::checkBorders()
is_on_border_ = true;
}
else if (x_ + w_ > PLAY_AREA_RIGHT)
else if (x_ + WIDTH_ > PLAY_AREA_RIGHT)
{
border_ = BORDER_RIGHT;
is_on_border_ = true;
@@ -264,7 +182,7 @@ void Player::checkBorders()
is_on_border_ = true;
}
else if (y_ + h_ > PLAY_AREA_BOTTOM)
else if (y_ + HEIGHT_ > PLAY_AREA_BOTTOM)
{
border_ = BORDER_BOTTOM;
is_on_border_ = true;
@@ -280,7 +198,7 @@ void Player::checkBorders()
void Player::checkState()
{
// Actualiza las variables en función del estado
if (state_ == s_falling)
if (state_ == PlayerState::FALLING)
{
vx_ = 0.0f;
vy_ = MAX_VY_;
@@ -288,9 +206,9 @@ void Player::checkState()
playFallSound();
}
else if (state_ == s_standing)
else if (state_ == PlayerState::STANDING)
{
if (previous_state_ == s_falling && falling_counter_ > MAX_FALLING_HEIGHT_)
if (previous_state_ == PlayerState::FALLING && falling_counter_ > MAX_FALLING_HEIGHT_)
{ // Si cae de muy alto, el jugador muere
is_alive_ = false;
}
@@ -299,7 +217,7 @@ void Player::checkState()
falling_counter_ = 0;
if (!isOnFloor() && !isOnAutoSurface() && !isOnDownSlope())
{
setState(s_falling);
setState(PlayerState::FALLING);
vx_ = 0.0f;
vy_ = MAX_VY_;
falling_counter_++;
@@ -307,7 +225,7 @@ void Player::checkState()
}
}
else if (state_ == s_jumping)
else if (state_ == PlayerState::JUMPING)
{
falling_counter_ = 0;
jumping_counter_++;
@@ -320,13 +238,13 @@ void Player::switchBorders()
{
if (border_ == BORDER_TOP)
{
y_ = PLAY_AREA_BOTTOM - h_ - 0 - BLOCK;
setState(s_standing);
y_ = PLAY_AREA_BOTTOM - HEIGHT_ - 0 - BLOCK;
setState(PlayerState::STANDING);
}
else if (border_ == BORDER_BOTTOM)
{
y_ = PLAY_AREA_TOP + 0;
setState(s_standing);
setState(PlayerState::STANDING);
}
else if (border_ == BORDER_RIGHT)
{
@@ -334,7 +252,7 @@ void Player::switchBorders()
}
if (border_ == BORDER_LEFT)
{
x_ = PLAY_AREA_RIGHT - w_ - 0;
x_ = PLAY_AREA_RIGHT - WIDTH_ - 0;
}
is_on_border_ = false;
@@ -347,7 +265,7 @@ void Player::applyGravity()
// La gravedad solo se aplica cuando el jugador esta saltando
// Nunca mientras cae o esta de pie
if (state_ == s_jumping)
if (state_ == PlayerState::JUMPING)
{
vy_ += GF;
if (vy_ > MAX_VY_)
@@ -357,19 +275,6 @@ void Player::applyGravity()
}
}
// Obtiene el rectangulo que delimita al jugador
SDL_Rect Player::getRect()
{
return {static_cast<int>(x_), static_cast<int>(y_), w_, h_};
}
// Obtiene el rectangulo de colision del jugador
SDL_Rect &Player::getCollider()
{
collider_box_ = getRect();
return collider_box_;
}
// Recalcula la posición del jugador y su animación
void Player::move()
{
@@ -378,7 +283,7 @@ void Player::move()
checkState(); // Comprueba el estado del jugador
#ifdef DEBUG
debugColor = {0, 255, 0};
debug_color_ = {0, 255, 0};
#endif
// Se mueve hacia la izquierda
@@ -388,11 +293,11 @@ void Player::move()
SDL_Rect proj;
proj.x = static_cast<int>(x_ + vx_);
proj.y = static_cast<int>(y_);
proj.h = h_;
proj.h = HEIGHT_;
proj.w = ceil(abs(vx_)); // Para evitar que tenga un ancho de 0 pixels
#ifdef DEBUG
rx = proj;
debug_rect_x_ = proj;
#endif
// Comprueba la colisión con las superficies
@@ -411,18 +316,18 @@ void Player::move()
}
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende
if (state_ != s_jumping)
if (state_ != PlayerState::JUMPING)
{
v_line_t leftSide = {static_cast<int>(x_), static_cast<int>(y_) + h_ - 2, static_cast<int>(y_) + h_ - 1}; // Comprueba solo los dos pixels de abajo
v_line_t leftSide = {static_cast<int>(x_), static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo
const int ly = room_->checkLeftSlopes(&leftSide);
if (ly > -1)
{
y_ = ly - h_;
y_ = ly - HEIGHT_;
}
}
// Si está bajando la rampa, recoloca al jugador
if (isOnDownSlope() && state_ != s_jumping)
if (isOnDownSlope() && state_ != PlayerState::JUMPING)
{
y_ += 1;
}
@@ -433,13 +338,13 @@ void Player::move()
{
// Crea el rectangulo de proyección en el eje X para ver si colisiona
SDL_Rect proj;
proj.x = static_cast<int>(x_) + w_;
proj.x = static_cast<int>(x_) + WIDTH_;
proj.y = static_cast<int>(y_);
proj.h = h_;
proj.h = HEIGHT_;
proj.w = ceil(vx_); // Para evitar que tenga un ancho de 0 pixels
#ifdef DEBUG
rx = proj;
debug_rect_x_ = proj;
#endif
// Comprueba la colisión
@@ -454,38 +359,38 @@ void Player::move()
else
{
// Si hay colisión lo mueve hasta donde no colisiona
x_ = pos - w_;
x_ = pos - WIDTH_;
}
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende
if (state_ != s_jumping)
if (state_ != PlayerState::JUMPING)
{
v_line_t rightSide = {static_cast<int>(x_) + w_ - 1, static_cast<int>(y_) + h_ - 2, static_cast<int>(y_) + h_ - 1}; // Comprueba solo los dos pixels de abajo
v_line_t rightSide = {static_cast<int>(x_) + WIDTH_ - 1, static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo
const int ry = room_->checkRightSlopes(&rightSide);
if (ry > -1)
{
y_ = ry - h_;
y_ = ry - HEIGHT_;
}
}
// Si está bajando la rampa, recoloca al jugador
if (isOnDownSlope() && state_ != s_jumping)
if (isOnDownSlope() && state_ != PlayerState::JUMPING)
{
y_ += 1;
}
}
// Si ha salido del suelo, el jugador cae
if (state_ == s_standing && !isOnFloor())
if (state_ == PlayerState::STANDING && !isOnFloor())
{
setState(s_falling);
setState(PlayerState::FALLING);
// Deja de estar enganchado a la superficie automatica
auto_movement_ = false;
}
// Si ha salido de una superficie automatica, detiene el movimiento automatico
if (state_ == s_standing && isOnFloor() && !isOnAutoSurface())
if (state_ == PlayerState::STANDING && isOnFloor() && !isOnAutoSurface())
{
// Deja de estar enganchado a la superficie automatica
auto_movement_ = false;
@@ -499,10 +404,10 @@ void Player::move()
proj.x = static_cast<int>(x_);
proj.y = static_cast<int>(y_ + vy_);
proj.h = ceil(abs(vy_)); // Para evitar que tenga una altura de 0 pixels
proj.w = w_;
proj.w = WIDTH_;
#ifdef DEBUG
ry = proj;
debug_rect_y_ = proj;
#endif
// Comprueba la colisión
@@ -518,7 +423,7 @@ void Player::move()
{
// Si hay colisión lo mueve hasta donde no colisiona y entra en caída
y_ = pos + 1;
setState(s_falling);
setState(PlayerState::FALLING);
}
}
@@ -528,12 +433,12 @@ void Player::move()
// Crea el rectangulo de proyección en el eje Y para ver si colisiona
SDL_Rect proj;
proj.x = static_cast<int>(x_);
proj.y = static_cast<int>(y_) + h_;
proj.y = static_cast<int>(y_) + HEIGHT_;
proj.h = ceil(vy_); // Para evitar que tenga una altura de 0 pixels
proj.w = w_;
proj.w = WIDTH_;
#ifdef DEBUG
ry = proj;
debug_rect_y_ = proj;
#endif
// Comprueba la colisión con las superficies normales y las automáticas
@@ -541,8 +446,8 @@ void Player::move()
if (pos > -1)
{
// Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie
y_ = pos - h_;
setState(s_standing);
y_ = pos - HEIGHT_;
setState(PlayerState::STANDING);
// Deja de estar enganchado a la superficie automatica
auto_movement_ = false;
@@ -550,7 +455,7 @@ void Player::move()
else
{
// Si no hay colisión con los muros, comprueba la colisión con las rampas
if (state_ != s_jumping)
if (state_ != PlayerState::JUMPING)
{ // Las rampas no se miran si se está saltando
v_line_t leftSide = {proj.x, proj.y, proj.y + proj.h - 1};
v_line_t rightSide = {proj.x + proj.w - 1, proj.y, proj.y + proj.h - 1};
@@ -559,11 +464,11 @@ void Player::move()
{
// No está saltando y hay colisión con una rampa
// Calcula la nueva posición
y_ = p - h_;
setState(s_standing);
y_ = p - HEIGHT_;
setState(PlayerState::STANDING);
#ifdef DEBUG
debugColor = {255, 255, 0};
debugPoint = {(int)x_ + (w_ / 2), p};
debug_color_ = {255, 255, 0};
debug_point_ = {(int)x_ + (WIDTH_ / 2), p};
#endif
}
else
@@ -572,7 +477,7 @@ void Player::move()
// Calcula la nueva posición
y_ += vy_;
#ifdef DEBUG
debugColor = {255, 0, 0};
debug_color_ = {255, 0, 0};
#endif
}
}
@@ -585,13 +490,12 @@ void Player::move()
}
}
// Actualiza la posición del sprite
sprite_->setPosX(x_);
sprite_->setPosY(y_);
placeSprite(); // Coloca el sprite en la nueva posición
collider_box_ = getRect(); // Actualiza el rectangulo de colisión
#ifdef DEBUG
debug_->add("RECT_X: " + std::to_string(rx.x) + "," + std::to_string(rx.y) + "," + std::to_string(rx.w) + "," + std::to_string(rx.h));
debug_->add("RECT_Y: " + std::to_string(ry.x) + "," + std::to_string(ry.y) + "," + std::to_string(ry.w) + "," + std::to_string(ry.h));
debug_->add("RECT_X: " + std::to_string(debug_rect_x_.x) + "," + std::to_string(debug_rect_x_.y) + "," + std::to_string(debug_rect_x_.w) + "," + std::to_string(debug_rect_x_.h));
debug_->add("RECT_Y: " + std::to_string(debug_rect_y_.x) + "," + std::to_string(debug_rect_y_.y) + "," + std::to_string(debug_rect_y_.w) + "," + std::to_string(debug_rect_y_.h));
#endif
}
@@ -607,14 +511,14 @@ void Player::animate()
// Comprueba si ha finalizado el salto al alcanzar la altura de inicio
void Player::checkJumpEnd()
{
if (state_ == s_jumping)
if (state_ == PlayerState::JUMPING)
{
if (vy_ > 0)
{
if (y_ >= jump_init_pos_)
{
// Si alcanza la altura de salto inicial, pasa al estado de caída
setState(s_falling);
setState(PlayerState::FALLING);
vy_ = MAX_VY_;
jumping_counter_ = 0;
}
@@ -760,46 +664,23 @@ bool Player::checkKillingTiles()
return check;
}
// Obtiene algunos parametros del jugador
playerSpawn_t Player::getSpawnParams()
// Establece el color del jugador
void Player::setColor()
{
playerSpawn_t params;
params.x = x_;
params.y = y_;
params.vx = vx_;
params.vy = vy_;
params.jump_init_pos = jump_init_pos_;
params.state = state_;
params.flip = sprite_->getFlip();
return params;
}
// Recarga la textura
void Player::reLoadTexture()
{
sprite_->getTexture()->reLoad();
}
// Recarga la paleta
void Player::reLoadPalette()
{
color_ = stringToColor(options.video.palette, "white");
if (options.cheats.infinite_lives == Cheat::CheatState::ENABLED)
{
color_ = stringToColor(options.video.palette, "yellow");
}
if (options.cheats.invincible == Cheat::CheatState::ENABLED)
{
color_ = stringToColor(options.video.palette, "cyan");
}
}
else if (options.cheats.infinite_lives == Cheat::CheatState::ENABLED)
{
color_ = stringToColor(options.video.palette, "yellow");
}
else
{
color_ = stringToColor(options.video.palette, "white");
}
// Establece el valor de la variable
void Player::setRoom(std::shared_ptr<Room> room)
{
room_ = room;
sprite_->getTexture()->setColor(color_.r, color_.g, color_.b);
}
// Actualiza los puntos de colisión
@@ -821,15 +702,15 @@ void Player::updateFeet()
{
const SDL_Point p = {static_cast<int>(x_), static_cast<int>(y_)};
under_feet_[0] = {p.x, p.y + h_};
under_feet_[1] = {p.x + 7, p.y + h_};
under_feet_[0] = {p.x, p.y + HEIGHT_};
under_feet_[1] = {p.x + 7, p.y + HEIGHT_};
feet_[0] = {p.x, p.y + h_ - 1};
feet_[1] = {p.x + 7, p.y + h_ - 1};
feet_[0] = {p.x, p.y + HEIGHT_ - 1};
feet_[1] = {p.x + 7, p.y + HEIGHT_ - 1};
}
// Cambia el estado del jugador
void Player::setState(state_e value)
void Player::setState(PlayerState value)
{
previous_state_ = state_;
state_ = value;
@@ -837,20 +718,49 @@ void Player::setState(state_e value)
checkState();
}
// Comprueba si el jugador esta vivo
bool Player::isAlive()
// Inicializa los sonidos de salto y caida
void Player::initSounds()
{
return is_alive_;
jumping_sound_.clear();
falling_sound_.clear();
for (int i = 1; i <= 24; ++i)
{
std::string soundFile = "jump" + std::to_string(i) + ".wav";
jumping_sound_.push_back(Resource::get()->getSound(soundFile));
if (i >= 11)
{
falling_sound_.push_back(Resource::get()->getSound(soundFile));
}
}
}
// Pone el jugador en modo pausa
void Player::pause()
// Coloca el sprite en la posición del jugador
void Player::placeSprite()
{
is_paused_ = true;
sprite_->setPosX(x_);
sprite_->setPosY(y_);
}
// Quita el modo pausa del jugador
void Player::resume()
// Aplica los valores de spawn al jugador
void Player::applySpawnValues(const PlayerSpawn &spawn)
{
is_paused_ = false;
x_ = spawn.x;
y_ = spawn.y;
vx_ = spawn.vx;
vy_ = spawn.vy;
jump_init_pos_ = spawn.jump_init_pos;
state_ = spawn.state;
sprite_->setFlip(spawn.flip);
}
// Inicializa el sprite del jugador
void Player::initSprite(const std::string &png, const std::string &animation)
{
sprite_ = std::make_shared<AnimatedSprite>(png, animation);
sprite_->setWidth(WIDTH_);
sprite_->setHeight(HEIGHT_);
sprite_->setCurrentAnimation("walk");
// sprite_->update();
}