diff --git a/source/game.cpp b/source/game.cpp index c242ab5..7de9e07 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -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++; } } diff --git a/source/player.cpp b/source/player.cpp index 6e01811..88eb2d8 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -16,8 +16,8 @@ Player::Player(float x, int y, SDL_Renderer *renderer, std::vector 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; diff --git a/source/player.h b/source/player.h index aa54258..6dd576a 100644 --- a/source/player.h +++ b/source/player.h @@ -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