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) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "hit.h" // Para Hit
|
||||
#include "item.h" // Para Item, ItemType
|
||||
#include "manage_hiscore_table.h" // Para HiScoreEntry
|
||||
#include "options.h" // Para SettingsOptions, settings
|
||||
@@ -147,6 +148,7 @@ class Game {
|
||||
int menace_threshold_ = 0; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el número de globos
|
||||
GameState state_ = GameState::FADE_IN; // Estado
|
||||
std::vector<std::shared_ptr<Player>> players_to_reorder_;
|
||||
Hit hit_; // Para representar colisiones en pantalla
|
||||
|
||||
#ifdef _DEBUG
|
||||
bool auto_pop_balloons_ = false; // Si es true, incrementa automaticamente los globos explotados
|
||||
@@ -186,9 +188,9 @@ class Game {
|
||||
auto allPlayersAreNotPlaying() -> bool; // Verifica si ningún jugador está activo
|
||||
|
||||
// --- Colisiones de jugadores ---
|
||||
void handlePlayerCollision(std::shared_ptr<Player> &player); // Procesa colisión de jugador con globo
|
||||
auto checkPlayerBalloonCollision(std::shared_ptr<Player> &player) -> std::shared_ptr<Balloon>; // Detecta colisión jugador-globo
|
||||
void checkPlayerItemCollision(std::shared_ptr<Player> &player); // Detecta colisión jugador-ítem
|
||||
void handlePlayerCollision(std::shared_ptr<Player> &player, std::shared_ptr<Balloon> &balloon); // Procesa colisión de jugador con globo
|
||||
auto checkPlayerBalloonCollision(std::shared_ptr<Player> &player) -> std::shared_ptr<Balloon>; // Detecta colisión jugador-globo
|
||||
void checkPlayerItemCollision(std::shared_ptr<Player> &player); // Detecta colisión jugador-ítem
|
||||
|
||||
// --- Sistema de entrada (input) ---
|
||||
void checkInput(); // Gestiona toda la entrada durante el juego
|
||||
@@ -284,11 +286,16 @@ class Game {
|
||||
// --- Sistema de audio ---
|
||||
static void playMusic(); // Reproduce la música de fondo
|
||||
void stopMusic() const; // Detiene la reproducción de música
|
||||
void pauseMusic(); // Pausa la música
|
||||
void resumeMusic(); // Retoma la música que eestaba pausada
|
||||
void playSound(const std::string &name) const; // Reproduce un efecto de sonido específico
|
||||
|
||||
// --- Utilidades y servicios ---
|
||||
void checkServiceMenu(); // Verifica si el menú de servicio está activo
|
||||
|
||||
void renderHit(); // Dibuja el golpe que recibe el jugador al impactarle un globo
|
||||
void putHitOnScreen(SDL_FPoint position); // Coloca el Hit en pantalla obligando a hacer un renderizado
|
||||
|
||||
// SISTEMA DE GRABACIÓN (CONDICIONAL)
|
||||
#ifdef RECORDING
|
||||
void updateRecording(); // Actualiza variables durante modo de grabación
|
||||
|
||||
Reference in New Issue
Block a user