fix: nou metode per ordenar i dibuixar els jugadors ordenats en l'eix Z
codi: eliminat tot el codi mort de Hit
This commit is contained in:
@@ -2,14 +2,13 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64
|
||||
|
||||
#include <list> // Para list
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
#include <list> // Para list
|
||||
|
||||
#include "bullet.hpp" // for Bullet
|
||||
#include "demo.hpp" // for Demo
|
||||
#include "hit.hpp" // for Hit
|
||||
#include "item.hpp" // for Item (ptr only), ItemType
|
||||
#include "manage_hiscore_table.hpp" // for HiScoreEntry
|
||||
#include "options.hpp" // for Settings, settings
|
||||
@@ -65,6 +64,8 @@ class Game {
|
||||
void run(); // Ejecuta el bucle principal del juego
|
||||
|
||||
private:
|
||||
using Players = std::vector<std::shared_ptr<Player>>;
|
||||
|
||||
// --- Enums ---
|
||||
enum class State {
|
||||
FADE_IN, // Transición de entrada
|
||||
@@ -121,7 +122,8 @@ class Game {
|
||||
|
||||
SDL_Texture* canvas_; // Textura para dibujar la zona de juego
|
||||
|
||||
std::vector<std::shared_ptr<Player>> players_; // Vector con los jugadores
|
||||
Players players_; // Vector con los jugadores
|
||||
Players players_draw_list_; // Vector con los jugadores ordenados para ser renderizados
|
||||
std::list<std::unique_ptr<Item>> items_; // Vector con los items
|
||||
std::list<std::unique_ptr<SmartSprite>> smart_sprites_; // Vector con los smartsprites
|
||||
std::list<std::unique_ptr<PathSprite>> path_sprites_; // Vector con los pathsprites
|
||||
@@ -163,9 +165,6 @@ class Game {
|
||||
int menace_ = 0; // Nivel de amenaza actual
|
||||
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
|
||||
State state_ = State::FADE_IN; // Estado
|
||||
std::vector<std::shared_ptr<Player>> players_to_put_at_back_;
|
||||
std::vector<std::shared_ptr<Player>> players_to_put_at_front_;
|
||||
Hit hit_; // Para representar colisiones en pantalla
|
||||
|
||||
// Estructuras para gestionar flags de eventos basados en tiempo
|
||||
struct GameOverFlags {
|
||||
@@ -226,7 +225,6 @@ class Game {
|
||||
void initPlayers(Player::Id player_id); // Inicializa los datos de los jugadores
|
||||
void updatePlayers(float delta_time); // Actualiza las variables y estados de los jugadores
|
||||
void renderPlayers(); // Renderiza todos los jugadores en pantalla
|
||||
void sortPlayersByZOrder(); // Reorganiza el orden de dibujado de jugadores
|
||||
auto getPlayer(Player::Id id) -> std::shared_ptr<Player>; // Obtiene un jugador por su identificador
|
||||
static auto getController(Player::Id player_id) -> int; // Obtiene el controlador asignado a un jugador
|
||||
|
||||
@@ -260,9 +258,6 @@ class Game {
|
||||
void demoHandlePassInput(); // Permite saltar la demostración
|
||||
void demoHandlePlayerInput(const std::shared_ptr<Player>& player, int index); // Procesa entrada de jugador en demo
|
||||
|
||||
// --- Sistema de balas y proyectiles ---
|
||||
void checkBulletCollision(); // Verifica colisiones de todas las balas (delegado a BulletManager)
|
||||
|
||||
// --- Colisiones específicas de balas ---
|
||||
auto checkBulletTabeCollision(const std::shared_ptr<Bullet>& bullet) -> bool; // Detecta colisión bala-Tabe
|
||||
auto checkBulletBalloonCollision(const std::shared_ptr<Bullet>& bullet) -> bool; // Detecta colisión bala-globo
|
||||
@@ -338,8 +333,15 @@ class Game {
|
||||
static void resumeMusic(); // Retoma la música que eestaba pausada
|
||||
void playSound(const std::string& name) const; // Reproduce un efecto de sonido específico
|
||||
|
||||
void sendPlayerToTheBack(const std::shared_ptr<Player>& player); // Mueve el jugador para pintarlo al fondo de la lista de jugadores
|
||||
void sendPlayerToTheFront(const std::shared_ptr<Player>& player); // Mueve el jugador para pintarlo el primero de la lista de jugadores
|
||||
// --- Gestion y dibujado de jugadores en z-order ---
|
||||
void buildPlayerDrawList(const Players& elements, Players& drawList); // Construye el drawList a partir del vector principal
|
||||
void updatePlayerDrawList(const Players& elements, Players& drawList); // Actualiza drawList tras cambios en los z_order
|
||||
void renderPlayerDrawList(const Players& drawList); // Dibuja en el orden definido
|
||||
static auto findPlayerIndex(const Players& elems, const std::shared_ptr<Player>& who) -> size_t;
|
||||
void sendPlayerToBack(Players& elements, const std::shared_ptr<Player>& who, Players& drawList); // Envia al jugador al fondo de la pantalla
|
||||
void bringPlayerToFront(Players& elements, const std::shared_ptr<Player>& who, Players& drawList); // Envia al jugador al frente de la pantalla
|
||||
|
||||
// --- Varios ---
|
||||
void onPauseStateChanged(bool is_paused);
|
||||
|
||||
// SISTEMA DE GRABACIÓN (CONDICIONAL)
|
||||
|
||||
Reference in New Issue
Block a user