Compare commits
5 Commits
8a6ce8e66d
...
b92e5df98b
| Author | SHA1 | Date | |
|---|---|---|---|
| b92e5df98b | |||
| 83871273ec | |||
| 0459b39366 | |||
| 5bb0ff19bc | |||
| a867b3cf4d |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -17,4 +17,5 @@ coffee_crisis*
|
||||
debug.txt
|
||||
cppcheck-result*
|
||||
desktop.ini
|
||||
ccae_release/
|
||||
ccae_release/
|
||||
resources.pack
|
||||
41
Makefile
41
Makefile
@@ -3,6 +3,7 @@ DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
||||
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source)
|
||||
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
||||
DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build)
|
||||
DIR_TOOLS := $(addsuffix /, $(DIR_ROOT)tools)
|
||||
|
||||
# Variables
|
||||
TARGET_NAME := coffee_crisis_arcade_edition
|
||||
@@ -12,6 +13,17 @@ RELEASE_FOLDER := ccae_release
|
||||
RELEASE_FILE := $(RELEASE_FOLDER)/$(TARGET_NAME)
|
||||
RESOURCE_FILE := release/coffee.res
|
||||
|
||||
# Variables para herramienta de empaquetado
|
||||
ifeq ($(OS),Windows_NT)
|
||||
PACK_TOOL := $(DIR_TOOLS)pack_resources.exe
|
||||
PACK_CXX := $(CXX)
|
||||
else
|
||||
PACK_TOOL := $(DIR_TOOLS)pack_resources
|
||||
PACK_CXX := $(CXX)
|
||||
endif
|
||||
PACK_SOURCES := $(DIR_TOOLS)pack_resources.cpp $(DIR_SOURCES)resource_pack.cpp
|
||||
PACK_INCLUDES := -I$(DIR_ROOT)
|
||||
|
||||
# Versión automática basada en la fecha actual (específica por SO)
|
||||
ifeq ($(OS),Windows_NT)
|
||||
VERSION := $(shell powershell -Command "Get-Date -Format 'yyyy-MM-dd'")
|
||||
@@ -135,6 +147,19 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
# Reglas para herramienta de empaquetado y resources.pack
|
||||
$(PACK_TOOL): $(PACK_SOURCES)
|
||||
@echo "Compilando herramienta de empaquetado..."
|
||||
$(PACK_CXX) -std=c++17 -Wall -Os $(PACK_INCLUDES) $(PACK_SOURCES) -o $(PACK_TOOL)
|
||||
@echo "✓ Herramienta de empaquetado lista: $(PACK_TOOL)"
|
||||
|
||||
pack_tool: $(PACK_TOOL)
|
||||
|
||||
resources.pack: $(PACK_TOOL)
|
||||
@echo "Generando resources.pack desde directorio data/..."
|
||||
$(PACK_TOOL) data resources.pack
|
||||
@echo "✓ resources.pack generado exitosamente"
|
||||
|
||||
# Reglas para compilación
|
||||
windows:
|
||||
@echo off
|
||||
@@ -153,7 +178,7 @@ windows_debug:
|
||||
@echo Compilando version debug para Windows: "$(APP_NAME)_debug.exe"
|
||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(WIN_TARGET_FILE)_debug.exe"
|
||||
|
||||
windows_release:
|
||||
windows_release: resources.pack
|
||||
@echo off
|
||||
@echo Creando release para Windows - Version: $(VERSION)
|
||||
|
||||
@@ -191,7 +216,7 @@ macos_debug:
|
||||
@echo "Compilando version debug para macOS: $(TARGET_NAME)_debug"
|
||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||
|
||||
macos_release:
|
||||
macos_release: resources.pack
|
||||
@echo "Creando release para macOS - Version: $(VERSION)"
|
||||
# Elimina datos de compilaciones anteriores
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
@@ -258,7 +283,7 @@ linux_debug:
|
||||
@echo "Compilando version debug para Linux: $(TARGET_NAME)_debug"
|
||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||
|
||||
linux_release:
|
||||
linux_release: resources.pack
|
||||
@echo "Creando release para Linux - Version: $(VERSION)"
|
||||
# Elimina carpetas previas
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
@@ -284,7 +309,7 @@ linux_release:
|
||||
# Elimina la carpeta temporal
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
|
||||
linux_release_desktop:
|
||||
linux_release_desktop: resources.pack
|
||||
@echo "Creando release con integracion desktop para Linux - Version: $(VERSION)"
|
||||
# Elimina carpetas previas
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
@@ -389,7 +414,7 @@ raspi_debug:
|
||||
@echo "Compilando version debug para Raspberry Pi: $(TARGET_NAME)_debug"
|
||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DVERBOSE -DDEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||
|
||||
raspi_release:
|
||||
raspi_release: resources.pack
|
||||
@echo "Creando release para Raspberry Pi - Version: $(VERSION)"
|
||||
# Elimina carpetas previas
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
@@ -415,7 +440,7 @@ raspi_release:
|
||||
# Elimina la carpeta temporal
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||
|
||||
anbernic:
|
||||
anbernic: resources.pack
|
||||
@echo "Compilando para Anbernic: $(TARGET_NAME)"
|
||||
# Elimina carpetas previas
|
||||
$(RMDIR) "$(RELEASE_FOLDER)"_anbernic
|
||||
@@ -457,7 +482,9 @@ help:
|
||||
@echo " raspi_release - Crear release completo para Raspberry Pi"
|
||||
@echo " anbernic - Compilar para Anbernic"
|
||||
@echo " no_audio - Compilar sin sistema de audio"
|
||||
@echo " pack_tool - Compilar herramienta de empaquetado"
|
||||
@echo " resources.pack - Generar pack de recursos desde data/"
|
||||
@echo " show_version - Mostrar version actual ($(VERSION))"
|
||||
@echo " help - Mostrar esta ayuda"
|
||||
|
||||
.PHONY: windows windows_rec windows_debug windows_release macos macos_debug macos_release linux linux_debug linux_release linux_release_desktop raspi raspi_debug raspi_release anbernic no_audio show_version help
|
||||
.PHONY: windows windows_rec windows_debug windows_release macos macos_debug macos_release linux linux_debug linux_release linux_release_desktop raspi raspi_debug raspi_release anbernic no_audio show_version help pack_tool
|
||||
@@ -37,7 +37,8 @@ SOUND|${PREFIX}/data/sound/balloon_pop0.wav
|
||||
SOUND|${PREFIX}/data/sound/balloon_pop1.wav
|
||||
SOUND|${PREFIX}/data/sound/balloon_pop2.wav
|
||||
SOUND|${PREFIX}/data/sound/balloon_pop3.wav
|
||||
SOUND|${PREFIX}/data/sound/bullet.wav
|
||||
SOUND|${PREFIX}/data/sound/bullet1p.wav
|
||||
SOUND|${PREFIX}/data/sound/bullet2p.wav
|
||||
SOUND|${PREFIX}/data/sound/clock.wav
|
||||
SOUND|${PREFIX}/data/sound/coffee_out.wav
|
||||
SOUND|${PREFIX}/data/sound/continue_clock.wav
|
||||
|
||||
@@ -2,43 +2,85 @@ frame_width=12
|
||||
frame_height=12
|
||||
|
||||
[animation]
|
||||
name=normal_up
|
||||
speed=0.0833
|
||||
loop=0
|
||||
frames=0,1,2
|
||||
name=yellow_up
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=0
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=normal_left
|
||||
speed=0.0833
|
||||
loop=0
|
||||
frames=3,4,5,5,4,3
|
||||
name=yellow_left
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=1
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=normal_right
|
||||
speed=0.0833
|
||||
loop=0
|
||||
frames=6,7,8,8,7,6
|
||||
name=yellow_right
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=2
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=powered_up
|
||||
speed=0.0833
|
||||
loop=0
|
||||
frames=9,10,11,11,10,9
|
||||
name=green_up
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=3
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=powered_left
|
||||
speed=0.0833
|
||||
loop=0
|
||||
frames=12,13,14,14,13,12
|
||||
name=green_left
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=4
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=powered_right
|
||||
speed=0.0833
|
||||
loop=0
|
||||
frames=15,16,17,17,26,15
|
||||
name=green_right
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=5
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=red_up
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=6
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=red_left
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=7
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=red_right
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=8
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=purple_up
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=9
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=purple_left
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=10
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=purple_right
|
||||
speed=20
|
||||
loop=-1
|
||||
frames=11
|
||||
[/animation]
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
data/sound/bullet2p.wav
Normal file
BIN
data/sound/bullet2p.wav
Normal file
Binary file not shown.
@@ -2,11 +2,12 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
|
||||
|
||||
#include <cstddef> // Para size_t
|
||||
#include <exception> // Para exception
|
||||
#include <fstream> // Para basic_istream, basic_ifstream, ifstream, istringstream
|
||||
#include <sstream> // Para basic_istringstream
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <cstddef> // Para size_t
|
||||
#include <exception> // Para exception
|
||||
#include <filesystem> // Para std::filesystem
|
||||
#include <fstream> // Para basic_istream, basic_ifstream, ifstream, istringstream
|
||||
#include <sstream> // Para basic_istringstream
|
||||
#include <stdexcept> // Para runtime_error
|
||||
|
||||
#include "resource_helper.h" // Para ResourceHelper
|
||||
#include "utils.h" // Para getFileName
|
||||
@@ -205,25 +206,28 @@ auto Asset::check() const -> bool {
|
||||
}
|
||||
|
||||
// Comprueba que existe un fichero
|
||||
auto Asset::checkFile(const std::string &path) -> bool {
|
||||
// Intentar primero con ResourceHelper
|
||||
auto data = ResourceHelper::loadFile(path);
|
||||
bool success = !data.empty();
|
||||
auto Asset::checkFile(const std::string &path) const -> bool {
|
||||
// Construir ruta del pack usando executable_path_
|
||||
std::string pack_path = executable_path_ + "resources.pack";
|
||||
bool pack_exists = std::filesystem::exists(pack_path);
|
||||
|
||||
// Si no se encuentra en el pack, intentar con filesystem directo
|
||||
if (!success) {
|
||||
if (pack_exists) {
|
||||
// MODO PACK: Usar ResourceHelper (igual que la carga real)
|
||||
auto data = ResourceHelper::loadFile(path);
|
||||
return !data.empty();
|
||||
} else {
|
||||
// MODO FILESYSTEM: Verificación directa (modo desarrollo)
|
||||
std::ifstream file(path);
|
||||
success = file.good();
|
||||
bool success = file.good();
|
||||
file.close();
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Checking file: %s [ ERROR ]",
|
||||
getFileName(path).c_str());
|
||||
}
|
||||
if (!success) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Error: Could not open file: %s", path.c_str());
|
||||
}
|
||||
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
// Parsea string a Type
|
||||
|
||||
@@ -57,7 +57,7 @@ class Asset {
|
||||
std::string executable_path_; // Ruta del ejecutable
|
||||
|
||||
// --- Métodos internos ---
|
||||
[[nodiscard]] static auto checkFile(const std::string &path) -> bool; // Verifica si un archivo existe
|
||||
[[nodiscard]] auto checkFile(const std::string &path) const -> bool; // Verifica si un archivo existe
|
||||
[[nodiscard]] static auto getTypeName(Type type) -> std::string; // Obtiene el nombre del tipo
|
||||
[[nodiscard]] static auto parseAssetType(const std::string &type_str) -> Type; // Convierte string a tipo
|
||||
void addToMap(const std::string &file_path, Type type, bool required, bool absolute); // Añade archivo al mapa
|
||||
|
||||
@@ -33,10 +33,27 @@ auto Bullet::calculateVelocity(Type type) -> float {
|
||||
}
|
||||
}
|
||||
|
||||
// Construye el string de animación basado en el tipo de bala y si está potenciada
|
||||
// Construye el string de animación basado en el tipo de bala y color específico
|
||||
auto Bullet::buildAnimationString(Type type, Color color) -> std::string {
|
||||
std::string animation_string = color == Color::GREEN ? "powered_" : "normal_";
|
||||
std::string animation_string;
|
||||
|
||||
// Mapear color a string específico
|
||||
switch (color) {
|
||||
case Color::YELLOW:
|
||||
animation_string = "yellow_";
|
||||
break;
|
||||
case Color::GREEN:
|
||||
animation_string = "green_";
|
||||
break;
|
||||
case Color::RED:
|
||||
animation_string = "red_";
|
||||
break;
|
||||
case Color::PURPLE:
|
||||
animation_string = "purple_";
|
||||
break;
|
||||
}
|
||||
|
||||
// Añadir dirección
|
||||
switch (type) {
|
||||
case Type::UP:
|
||||
animation_string += "up";
|
||||
|
||||
@@ -30,7 +30,9 @@ class Bullet {
|
||||
|
||||
enum class Color : Uint8 {
|
||||
YELLOW,
|
||||
GREEN
|
||||
GREEN,
|
||||
RED,
|
||||
PURPLE
|
||||
};
|
||||
|
||||
// --- Constructor y destructor ---
|
||||
|
||||
@@ -80,9 +80,9 @@ void Director::init() {
|
||||
Asset::init(executable_path_); // Inicializa el sistema de gestión de archivos
|
||||
|
||||
#ifdef MACOS_BUNDLE
|
||||
ResourceHelper::initializeResourceSystem(executable_path_ + "/../Resources/resources.pack");
|
||||
ResourceHelper::initializeResourceSystem(executable_path_ + "../Resources/resources.pack");
|
||||
#else
|
||||
ResourceHelper::initializeResourceSystem("resources.pack");
|
||||
ResourceHelper::initializeResourceSystem(executable_path_ + "resources.pack");
|
||||
#endif
|
||||
loadAssets(); // Crea el índice de archivos
|
||||
Input::init(Asset::get()->get("gamecontrollerdb.txt"), Asset::get()->get("controllers.json")); // Carga configuración de controles
|
||||
@@ -174,8 +174,14 @@ void Director::loadAssets() {
|
||||
|
||||
// Comprueba los parametros del programa
|
||||
void Director::checkProgramArguments(int argc, std::span<char *> argv) {
|
||||
// Establece la ruta del programa
|
||||
executable_path_ = getPath(argv[0]);
|
||||
// Obtener la ruta absoluta del ejecutable
|
||||
std::filesystem::path exe_path = std::filesystem::absolute(argv[0]);
|
||||
executable_path_ = exe_path.parent_path().string();
|
||||
|
||||
// Asegurar que termine con separador de directorio
|
||||
if (!executable_path_.empty() && executable_path_.back() != '/' && executable_path_.back() != '\\') {
|
||||
executable_path_ += "/";
|
||||
}
|
||||
|
||||
// Comprueba el resto de parámetros
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
|
||||
@@ -774,7 +774,7 @@ void Player::updatePowerUp(float deltaTime) {
|
||||
power_sprite_visible_ = false;
|
||||
in_power_up_ending_phase_ = false;
|
||||
bullet_color_toggle_ = false;
|
||||
bullet_color_ = Bullet::Color::YELLOW;
|
||||
// Los colores ahora se manejan dinámicamente en getNextBulletColor()
|
||||
} else {
|
||||
// Calcular visibilidad del power sprite
|
||||
const float TOTAL_POWERUP_TIME_S = static_cast<float>(POWERUP_COUNTER) / 60.0f;
|
||||
@@ -784,7 +784,6 @@ void Player::updatePowerUp(float deltaTime) {
|
||||
// En los primeros 75% del tiempo, siempre visible
|
||||
power_sprite_visible_ = true;
|
||||
in_power_up_ending_phase_ = false;
|
||||
bullet_color_ = Bullet::Color::GREEN;
|
||||
} else {
|
||||
// En el último 25%, parpadea cada 20 frames (≈0.333s)
|
||||
constexpr float BLINK_PERIOD_S = 20.0f / 60.0f;
|
||||
@@ -793,14 +792,12 @@ void Player::updatePowerUp(float deltaTime) {
|
||||
float cycle_position = fmod(power_up_time_accumulator_, BLINK_PERIOD_S) / BLINK_PERIOD_S;
|
||||
power_sprite_visible_ = cycle_position >= VISIBLE_PROPORTION;
|
||||
in_power_up_ending_phase_ = true; // Activar modo alternancia de colores de balas
|
||||
bullet_color_ = power_sprite_visible_ ? Bullet::Color::GREEN : Bullet::Color::YELLOW;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
power_sprite_visible_ = false;
|
||||
in_power_up_ending_phase_ = false;
|
||||
bullet_color_toggle_ = false;
|
||||
bullet_color_ = Bullet::Color::YELLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -935,15 +932,31 @@ auto Player::isRenderable() const -> bool {
|
||||
return !isTitleHidden();
|
||||
};
|
||||
|
||||
// Devuelve el color actual de bala según el estado
|
||||
auto Player::getBulletColor() const -> Bullet::Color {
|
||||
return power_up_ ? bullet_colors_.powered_color : bullet_colors_.normal_color;
|
||||
}
|
||||
|
||||
// Devuelve el color para la próxima bala (alterna si está en modo toggle)
|
||||
auto Player::getNextBulletColor() -> Bullet::Color {
|
||||
if (in_power_up_ending_phase_) {
|
||||
// En fase final: alternar entre verde y amarillo
|
||||
// En fase final: alternar entre colores powered y normal
|
||||
bullet_color_toggle_ = !bullet_color_toggle_;
|
||||
return bullet_color_toggle_ ? Bullet::Color::GREEN : Bullet::Color::YELLOW;
|
||||
return bullet_color_toggle_ ? bullet_colors_.powered_color : bullet_colors_.normal_color;
|
||||
}
|
||||
// Modo normal: sin power-up = amarillo, con power-up = verde
|
||||
return bullet_color_;
|
||||
// Modo normal: sin power-up = normal_color, con power-up = powered_color
|
||||
return power_up_ ? bullet_colors_.powered_color : bullet_colors_.normal_color;
|
||||
}
|
||||
|
||||
// Establece los colores de bala para este jugador
|
||||
void Player::setBulletColors(Bullet::Color normal, Bullet::Color powered) {
|
||||
bullet_colors_.normal_color = normal;
|
||||
bullet_colors_.powered_color = powered;
|
||||
}
|
||||
|
||||
// Establece el archivo de sonido de bala para este jugador
|
||||
void Player::setBulletSoundFile(const std::string& filename) {
|
||||
bullet_sound_file_ = filename;
|
||||
}
|
||||
|
||||
// Añade una puntuación a la tabla de records
|
||||
|
||||
@@ -39,6 +39,12 @@ class Player {
|
||||
static constexpr int WIDTH = 32; // Anchura
|
||||
static constexpr int HEIGHT = 32; // Altura
|
||||
|
||||
// --- Estructuras ---
|
||||
struct BulletColorPair {
|
||||
Bullet::Color normal_color; // Color de bala sin power-up
|
||||
Bullet::Color powered_color; // Color de bala con power-up
|
||||
};
|
||||
|
||||
// --- Enums ---
|
||||
enum class Id : int {
|
||||
NO_PLAYER = -1, // Sin jugador
|
||||
@@ -134,7 +140,7 @@ class Player {
|
||||
void setPlayingState(State state); // Cambia el estado de juego
|
||||
void setInvulnerable(bool value); // Establece el valor del estado de invulnerabilidad
|
||||
void setPowerUp(); // Activa el modo PowerUp
|
||||
void updatePowerUp(float deltaTime); // Actualiza el valor de PowerUp (time-based)
|
||||
void updatePowerUp(float deltaTime); // Actualiza el valor de PowerUp
|
||||
void giveExtraHit(); // Concede un toque extra al jugador
|
||||
void removeExtraHit(); // Quita el toque extra al jugador
|
||||
void decContinueCounter(); // Decrementa el contador de continuar
|
||||
@@ -190,8 +196,11 @@ class Player {
|
||||
[[nodiscard]] auto getCoffees() const -> int { return coffees_; }
|
||||
[[nodiscard]] auto getPowerUpCounter() const -> int { return power_up_counter_; }
|
||||
[[nodiscard]] auto getInvulnerableCounter() const -> int { return invulnerable_counter_; }
|
||||
[[nodiscard]] auto getBulletColor() const -> Bullet::Color { return bullet_color_; }
|
||||
[[nodiscard]] auto getBulletColor() const -> Bullet::Color; // Devuelve el color actual de bala según el estado
|
||||
auto getNextBulletColor() -> Bullet::Color; // Devuelve el color para la próxima bala (alterna si está en modo toggle)
|
||||
void setBulletColors(Bullet::Color normal, Bullet::Color powered); // Establece los colores de bala para este jugador
|
||||
[[nodiscard]] auto getBulletSoundFile() const -> std::string { return bullet_sound_file_; } // Devuelve el archivo de sonido de bala
|
||||
void setBulletSoundFile(const std::string& filename); // Establece el archivo de sonido de bala para este jugador
|
||||
|
||||
// Contadores y timers
|
||||
[[nodiscard]] auto getContinueCounter() const -> int { return continue_counter_; }
|
||||
@@ -249,7 +258,8 @@ class Player {
|
||||
State walking_state_ = State::WALKING_STOP; // Estado del jugador al moverse
|
||||
State firing_state_ = State::FIRING_NONE; // Estado del jugador al disparar
|
||||
State playing_state_ = State::WAITING; // Estado del jugador en el juego
|
||||
Bullet::Color bullet_color_ = Bullet::Color::YELLOW; // Color de la bala del jugador
|
||||
BulletColorPair bullet_colors_ = {Bullet::Color::YELLOW, Bullet::Color::GREEN}; // Par de colores de balas para este jugador
|
||||
std::string bullet_sound_file_ = "bullet1p.wav"; // Archivo de sonido de bala para este jugador
|
||||
|
||||
float pos_x_ = 0.0F; // Posición en el eje X
|
||||
float default_pos_x_; // Posición inicial para el jugador
|
||||
|
||||
@@ -809,6 +809,23 @@ void Resource::renderProgress() {
|
||||
Lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_,
|
||||
param.resource.color);
|
||||
|
||||
// Muestra información del monitor alineada con la barra de carga
|
||||
loading_text_->writeColored(
|
||||
X_PADDING,
|
||||
Y_PADDING,
|
||||
screen->getDisplayMonitorName(),
|
||||
param.resource.color);
|
||||
loading_text_->writeColored(
|
||||
X_PADDING,
|
||||
Y_PADDING + 9,
|
||||
std::to_string(screen->getDisplayMonitorWidth()) + "x" + std::to_string(screen->getDisplayMonitorHeight()),
|
||||
param.resource.color);
|
||||
loading_text_->writeColored(
|
||||
X_PADDING,
|
||||
Y_PADDING + 18,
|
||||
std::to_string(screen->getDisplayMonitorRefreshRate()) + "Hz",
|
||||
param.resource.color);
|
||||
|
||||
// Renderiza el frame en pantalla
|
||||
screen->coreRender();
|
||||
}
|
||||
@@ -844,9 +861,6 @@ void Resource::loadDemoDataQuiet() {
|
||||
|
||||
// Inicializa los rectangulos que definen la barra de progreso
|
||||
void Resource::initProgressBar() {
|
||||
constexpr float X_PADDING = 20.0F;
|
||||
constexpr float Y_PADDING = 20.0F;
|
||||
constexpr float BAR_HEIGHT = 10.0F;
|
||||
const float BAR_Y_POSITION = param.game.height - BAR_HEIGHT - Y_PADDING;
|
||||
|
||||
const float WIRED_BAR_WIDTH = param.game.width - (X_PADDING * 2);
|
||||
|
||||
@@ -120,6 +120,11 @@ class Resource {
|
||||
}
|
||||
};
|
||||
|
||||
// --- Constantes para la barra de progreso ---
|
||||
static constexpr float X_PADDING = 20.0F;
|
||||
static constexpr float Y_PADDING = 20.0F;
|
||||
static constexpr float BAR_HEIGHT = 10.0F;
|
||||
|
||||
// --- Modo de carga ---
|
||||
LoadingMode loading_mode_;
|
||||
|
||||
|
||||
@@ -86,10 +86,10 @@ void Screen::render() {
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla exceptuando ciertas partes
|
||||
void Screen::coreRender() {
|
||||
fps_.increment();
|
||||
/*fps_.increment();
|
||||
#ifdef _DEBUG
|
||||
renderInfo();
|
||||
#endif
|
||||
#endif*/
|
||||
renderPresent(); // Renderiza el contenido del game_canvas_
|
||||
}
|
||||
|
||||
@@ -358,6 +358,13 @@ void Screen::getDisplayInfo() {
|
||||
|
||||
const auto *dm = SDL_GetCurrentDisplayMode(displays[0]);
|
||||
|
||||
// Guarda información del monitor en display_monitor_
|
||||
const char *first_display_name = SDL_GetDisplayName(displays[0]);
|
||||
display_monitor_.name = (first_display_name != nullptr) ? first_display_name : "Unknown";
|
||||
display_monitor_.width = static_cast<int>(dm->w);
|
||||
display_monitor_.height = static_cast<int>(dm->h);
|
||||
display_monitor_.refresh_rate = static_cast<int>(dm->refresh_rate);
|
||||
|
||||
// Calcula el máximo factor de zoom que se puede aplicar a la pantalla
|
||||
Options::window.max_zoom = std::min(dm->w / param.game.width, dm->h / param.game.height);
|
||||
Options::window.zoom = std::min(Options::window.zoom, Options::window.max_zoom);
|
||||
|
||||
@@ -54,6 +54,12 @@ class Screen {
|
||||
[[nodiscard]] static auto getVSync() -> bool { return Options::video.vsync; } // Obtiene el valor de V-Sync
|
||||
[[nodiscard]] auto getText() const -> std::shared_ptr<Text> { return text_; } // Obtiene el puntero al texto de Screen
|
||||
|
||||
// --- Display Monitor getters ---
|
||||
[[nodiscard]] auto getDisplayMonitorName() const -> std::string { return display_monitor_.name; }
|
||||
[[nodiscard]] auto getDisplayMonitorWidth() const -> int { return display_monitor_.width; }
|
||||
[[nodiscard]] auto getDisplayMonitorHeight() const -> int { return display_monitor_.height; }
|
||||
[[nodiscard]] auto getDisplayMonitorRefreshRate() const -> int { return display_monitor_.refresh_rate; }
|
||||
|
||||
#ifdef _DEBUG
|
||||
// --- Debug ---
|
||||
void toggleDebugInfo() { debug_info_.show = !debug_info_.show; }
|
||||
@@ -65,6 +71,12 @@ class Screen {
|
||||
static constexpr int WINDOWS_DECORATIONS = 35; // Decoraciones de la ventana
|
||||
|
||||
// --- Estructuras privadas ---
|
||||
struct DisplayMonitor {
|
||||
std::string name;
|
||||
int width;
|
||||
int height;
|
||||
int refresh_rate;
|
||||
};
|
||||
struct FPS {
|
||||
Uint32 ticks{0}; // Tiempo en milisegundos desde que se comenzó a contar.
|
||||
int frame_count{0}; // Número acumulado de frames en el intervalo.
|
||||
@@ -206,6 +218,7 @@ class Screen {
|
||||
FlashEffect flash_effect_; // Efecto de flash en pantalla
|
||||
ShakeEffect shake_effect_; // Efecto de agitar la pantalla
|
||||
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
|
||||
DisplayMonitor display_monitor_; // Información del monitor actual
|
||||
#ifdef _DEBUG
|
||||
Debug debug_info_; // Información de debug
|
||||
#endif
|
||||
@@ -218,7 +231,7 @@ class Screen {
|
||||
void renderPresent(); // Selecciona y ejecuta el método de renderizado adecuado
|
||||
void loadShaders(); // Carga el contenido del archivo GLSL
|
||||
void adjustWindowSize(); // Calcula el tamaño de la ventana
|
||||
static void getDisplayInfo(); // Obtiene información sobre la pantalla
|
||||
void getDisplayInfo(); // Obtiene información sobre la pantalla
|
||||
void renderOverlays(); // Renderiza todos los overlays y efectos
|
||||
void renderAttenuate(); // Atenúa la pantalla
|
||||
void createText(); // Crea el objeto de texto
|
||||
|
||||
@@ -1349,7 +1349,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, Bullet::Type t
|
||||
break;
|
||||
}
|
||||
createBullet(bullet.x, bullet.y, type, player->getNextBulletColor(), static_cast<int>(player->getId()));
|
||||
playSound("bullet.wav");
|
||||
playSound(player->getBulletSoundFile());
|
||||
|
||||
// Establece un tiempo de espera para el próximo disparo.
|
||||
constexpr int POWERUP_COOLDOWN = 5;
|
||||
@@ -1635,6 +1635,8 @@ void Game::initPlayers(Player::Id player_id) {
|
||||
.stage_info = stage_manager_.get()};
|
||||
|
||||
auto player1 = std::make_unique<Player>(config_player1);
|
||||
player1->setBulletColors(Bullet::Color::YELLOW, Bullet::Color::GREEN);
|
||||
player1->setBulletSoundFile("bullet1p.wav");
|
||||
player1->setScoreBoardPanel(Scoreboard::Id::LEFT);
|
||||
player1->setName(Lang::getText("[SCOREBOARD] 1"));
|
||||
player1->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).instance);
|
||||
@@ -1655,6 +1657,8 @@ void Game::initPlayers(Player::Id player_id) {
|
||||
.stage_info = stage_manager_.get()};
|
||||
|
||||
auto player2 = std::make_unique<Player>(config_player2);
|
||||
player2->setBulletColors(Bullet::Color::RED, Bullet::Color::PURPLE);
|
||||
player2->setBulletSoundFile("bullet2p.wav");
|
||||
player2->setScoreBoardPanel(Scoreboard::Id::RIGHT);
|
||||
player2->setName(Lang::getText("[SCOREBOARD] 2"));
|
||||
player2->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).instance);
|
||||
|
||||
@@ -43,7 +43,8 @@ int main(int argc, char* argv[]) {
|
||||
std::string dataDir = "data";
|
||||
std::string outputFile = "resources.pack";
|
||||
bool listMode = false;
|
||||
|
||||
bool dataDirSet = false;
|
||||
|
||||
// Parse arguments
|
||||
for (int i = 1; i < argc; i++) {
|
||||
std::string arg = argv[i];
|
||||
@@ -56,8 +57,9 @@ int main(int argc, char* argv[]) {
|
||||
outputFile = argv[++i]; // Next argument is pack file to list
|
||||
}
|
||||
} else if (!arg.empty() && arg[0] != '-') {
|
||||
if (dataDir == "data") {
|
||||
if (!dataDirSet) {
|
||||
dataDir = arg;
|
||||
dataDirSet = true;
|
||||
} else {
|
||||
outputFile = arg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user