El jugador ya reaparece en su posición original

This commit is contained in:
2024-06-30 18:05:11 +02:00
parent 8817899b12
commit 61c4884dfe
3 changed files with 13 additions and 4 deletions

View File

@@ -2931,6 +2931,10 @@ void Game::checkGameInput()
}
else
{
if (input->checkInput(input_accept, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id))
{
player->init();
}
i++;
}
}

View File

@@ -16,8 +16,8 @@ Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> te
fireSprite->getTexture()->setAlpha(224);
// Establece la posición inicial del jugador
posX = x;
posY = y;
defaultPosX = posX = x;
defaultPosY = posY = y;
init();
}
@@ -36,11 +36,13 @@ Player::~Player()
void Player::init()
{
// Inicializa variables de estado
posX = defaultPosX;
posY = defaultPosY;
alive = true;
deathCounter = DEATH_COUNTER;
statusWalking = PLAYER_STATUS_WALKING_STOP;
statusFiring = PLAYER_STATUS_FIRING_NO;
invulnerable = false;
invulnerable = true;
invulnerableCounter = PLAYER_INVULNERABLE_COUNTER;
powerUp = false;
powerUpCounter = PLAYER_POWERUP_COUNTER;

View File

@@ -37,12 +37,15 @@ private:
AnimatedSprite *bodySprite; // Sprite para dibujar el cuerpo
AnimatedSprite *legsSprite; // Sprite para dibujar las piernas
AnimatedSprite *deathSprite; // Sprite para dibujar el jugador derrotado
AnimatedSprite *fireSprite; // Sprite para dibujar el aura del jugador con el poder a tope
AnimatedSprite *fireSprite; // Sprite para dibujar el aura del jugador con el poder a tope
// Variables
float posX; // Posicion en el eje X
int posY; // Posicion en el eje Y
float defaultPosX; // Posición inicial para el jugador
int defaultPosY; // Posición inicial para el jugador
Uint8 width; // Anchura
Uint8 height; // Altura