afegit efecte de "colp" quan el jugador es "alcanssat" per un globo
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <functional> // Para function
|
||||
#include <iostream> // Para std::cout, std::endl
|
||||
#include <iterator> // Para distance, size
|
||||
#include <memory> // Para std::make_unique
|
||||
|
||||
#include "asset.h" // Para Asset
|
||||
#include "audio.h" // Para Audio
|
||||
@@ -20,6 +21,7 @@
|
||||
#include "fade.h" // Para Fade, FadeType, FadeMode
|
||||
#include "global_events.h" // Para check
|
||||
#include "global_inputs.h" // Para check
|
||||
#include "hit.h" // Para Hit
|
||||
#include "input.h" // Para InputAction, Input, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_ALLOW_REPEAT, InputDevice
|
||||
#include "item.h" // Para Item, ItemType
|
||||
#include "lang.h" // Para getText
|
||||
@@ -49,7 +51,8 @@ Game::Game(int player_id, int current_stage, bool demo)
|
||||
fade_in_(std::make_unique<Fade>()),
|
||||
fade_out_(std::make_unique<Fade>()),
|
||||
balloon_manager_(std::make_unique<BalloonManager>()),
|
||||
tabe_(std::make_unique<Tabe>()) {
|
||||
tabe_(std::make_unique<Tabe>()),
|
||||
hit_(Hit(Resource::get()->getTexture("hit.png"))) {
|
||||
// Pasa variables
|
||||
demo_.enabled = demo;
|
||||
|
||||
@@ -213,7 +216,7 @@ void Game::updatePlayers() {
|
||||
}
|
||||
// En caso contrario, el jugador ha sido golpeado por un globo activo
|
||||
else {
|
||||
handlePlayerCollision(player);
|
||||
handlePlayerCollision(player, balloon);
|
||||
|
||||
if (demo_.enabled && allPlayersAreNotPlaying()) {
|
||||
fade_out_->setType(FadeType::RANDOM_SQUARE);
|
||||
@@ -830,7 +833,7 @@ void Game::renderPathSprites() {
|
||||
}
|
||||
|
||||
// Acciones a realizar cuando el jugador colisiona con un globo
|
||||
void Game::handlePlayerCollision(std::shared_ptr<Player> &player) {
|
||||
void Game::handlePlayerCollision(std::shared_ptr<Player> &player, std::shared_ptr<Balloon> &balloon) {
|
||||
if (!player->isPlaying() || player->isInvulnerable()) {
|
||||
// Si no está jugando o tiene inmunidad, no hace nada
|
||||
return;
|
||||
@@ -847,15 +850,19 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &player) {
|
||||
// Si no tiene cafes, muere
|
||||
playSound("player_collision.wav");
|
||||
if (param.game.hit_stop) {
|
||||
pauseMusic();
|
||||
auto position = getCollisionPoint(player->getCollider(), balloon->getCollider());
|
||||
putHitOnScreen(position);
|
||||
SDL_Delay(param.game.hit_stop_ms);
|
||||
hit_.disable();
|
||||
resumeMusic();
|
||||
}
|
||||
screen_->shake();
|
||||
playSound("voice_no.wav");
|
||||
player->setPlayingState(PlayerState::ROLLING);
|
||||
players_to_reorder_.push_back(player);
|
||||
if (allPlayersAreNotPlaying()) {
|
||||
// No se puede subir poder de fase si no hay nadie jugando
|
||||
Stage::power_can_be_added = false;
|
||||
Stage::power_can_be_added = false; // No se puede subir poder de fase si no hay nadie jugando
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -979,6 +986,7 @@ void Game::fillCanvas() {
|
||||
// Dibuja los objetos
|
||||
background_->render();
|
||||
renderPlayers();
|
||||
renderHit();
|
||||
renderSmartSprites();
|
||||
renderItems();
|
||||
balloon_manager_->render();
|
||||
@@ -1598,6 +1606,16 @@ void Game::playMusic() {
|
||||
Audio::get()->playMusic("playing.ogg");
|
||||
}
|
||||
|
||||
// Pausa la música
|
||||
void Game::pauseMusic() {
|
||||
Audio::get()->pauseMusic();
|
||||
}
|
||||
|
||||
// Retoma la música que eestaba pausada
|
||||
void Game::resumeMusic() {
|
||||
Audio::get()->resumeMusic();
|
||||
}
|
||||
|
||||
// Detiene la música
|
||||
void Game::stopMusic() const {
|
||||
if (!demo_.enabled) {
|
||||
@@ -1823,6 +1841,19 @@ void Game::checkServiceMenu() {
|
||||
service_menu_was_active_ = service_menu_is_active;
|
||||
}
|
||||
|
||||
// Dibuja el golpe que recibe el jugador al impactarle un globo
|
||||
void Game::renderHit() {
|
||||
hit_.render();
|
||||
}
|
||||
|
||||
// Coloca el Hit en pantalla obligando a hacer un renderizado
|
||||
void Game::putHitOnScreen(SDL_FPoint position) {
|
||||
hit_.create(position);
|
||||
fillCanvas();
|
||||
render();
|
||||
hit_.disable();
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Comprueba los eventos en el modo DEBUG
|
||||
void Game::checkDebugEvents(const SDL_Event &event) {
|
||||
|
||||
Reference in New Issue
Block a user