Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 78a0200856 | |||
| 61c6b9087c | |||
| 254ef3d11c | |||
| df54930e14 | |||
| 4ed9fd07a2 | |||
| ddc3a0b9b0 | |||
| 87eebe730d |
@@ -1,7 +1,7 @@
|
|||||||
# CMakeLists.txt
|
# CMakeLists.txt
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(pollo VERSION 0.1.0)
|
project(pollo VERSION 0.1.1)
|
||||||
|
|
||||||
# Info del proyecto para version.h
|
# Info del proyecto para version.h
|
||||||
set(PROJECT_LONG_NAME "Los pollos hermanos")
|
set(PROJECT_LONG_NAME "Los pollos hermanos")
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -451,7 +451,6 @@ rpi_release:
|
|||||||
CROSS_CXX := x86_64-w64-mingw32-g++
|
CROSS_CXX := x86_64-w64-mingw32-g++
|
||||||
CROSS_STRIP := x86_64-w64-mingw32-strip
|
CROSS_STRIP := x86_64-w64-mingw32-strip
|
||||||
CROSS_WINDRES := x86_64-w64-mingw32-windres
|
CROSS_WINDRES := x86_64-w64-mingw32-windres
|
||||||
CROSS_ZIP_FILE := $(TARGET_NAME)-$(VERSION)-win32-x64.zip
|
|
||||||
|
|
||||||
CROSS_CXXFLAGS := -std=$(CPP_STANDARD) -Wall -Os -ffunction-sections -fdata-sections \
|
CROSS_CXXFLAGS := -std=$(CPP_STANDARD) -Wall -Os -ffunction-sections -fdata-sections \
|
||||||
-Wl,--gc-sections -static-libstdc++ -static-libgcc \
|
-Wl,--gc-sections -static-libstdc++ -static-libgcc \
|
||||||
@@ -504,10 +503,10 @@ windows_cross:
|
|||||||
$(CROSS_STRIP) -s "$(RELEASE_FOLDER)/$(APP_NAME).exe"
|
$(CROSS_STRIP) -s "$(RELEASE_FOLDER)/$(APP_NAME).exe"
|
||||||
|
|
||||||
# 6. Empaquetar
|
# 6. Empaquetar
|
||||||
@echo "Empaquetando en $(CROSS_ZIP_FILE)..."
|
@echo "Empaquetando en $(WINDOWS_RELEASE)..."
|
||||||
cd $(RELEASE_FOLDER) && zip -r ../$(CROSS_ZIP_FILE) .
|
cd $(RELEASE_FOLDER) && zip -r ../$(WINDOWS_RELEASE) .
|
||||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
@echo "✓ Release de Windows (Cross) completado: $(CROSS_ZIP_FILE)"
|
@echo "✓ Release de Windows (Cross) completado: $(WINDOWS_RELEASE)"
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# SETUP
|
# SETUP
|
||||||
|
|||||||
@@ -66,17 +66,9 @@ assets:
|
|||||||
# PLAYER
|
# PLAYER
|
||||||
player:
|
player:
|
||||||
- type: BITMAP
|
- type: BITMAP
|
||||||
path: ${PREFIX}/data/player/player.gif
|
path: ${PREFIX}/data/player/player_spritesheet.gif
|
||||||
- type: ANIMATION
|
- type: ANIMATION
|
||||||
path: ${PREFIX}/data/player/player.yaml
|
path: ${PREFIX}/data/player/player_animations.yaml
|
||||||
- type: BITMAP
|
|
||||||
path: ${PREFIX}/data/player/player2.gif
|
|
||||||
- type: ANIMATION
|
|
||||||
path: ${PREFIX}/data/player/player2.yaml
|
|
||||||
- type: BITMAP
|
|
||||||
path: ${PREFIX}/data/player/player_game_over.gif
|
|
||||||
- type: ANIMATION
|
|
||||||
path: ${PREFIX}/data/player/player_game_over.yaml
|
|
||||||
|
|
||||||
# MUSIC
|
# MUSIC
|
||||||
music:
|
music:
|
||||||
@@ -84,16 +76,6 @@ assets:
|
|||||||
path: ${PREFIX}/data/music/574070_KUVO_Farewell_to_school.ogg
|
path: ${PREFIX}/data/music/574070_KUVO_Farewell_to_school.ogg
|
||||||
- type: MUSIC
|
- type: MUSIC
|
||||||
path: ${PREFIX}/data/music/574071_EA_DTV.ogg
|
path: ${PREFIX}/data/music/574071_EA_DTV.ogg
|
||||||
- type: MUSIC
|
|
||||||
path: ${PREFIX}/data/music/574072_Scalesmann_Kaleidoscope.ogg
|
|
||||||
- type: MUSIC
|
|
||||||
path: ${PREFIX}/data/music/574073_KUVO_We_are_us.ogg
|
|
||||||
- type: MUSIC
|
|
||||||
path: ${PREFIX}/data/music/574219_nq_core_vet.ogg
|
|
||||||
- type: MUSIC
|
|
||||||
path: ${PREFIX}/data/music/575111_nq_Zak_McDrucken.ogg
|
|
||||||
- type: MUSIC
|
|
||||||
path: ${PREFIX}/data/music/576109_Pator_Parallel_Visions.ogg
|
|
||||||
|
|
||||||
# SOUNDS
|
# SOUNDS
|
||||||
sounds:
|
sounds:
|
||||||
@@ -128,6 +110,6 @@ assets:
|
|||||||
# ENEMIES
|
# ENEMIES
|
||||||
enemies:
|
enemies:
|
||||||
- type: BITMAP
|
- type: BITMAP
|
||||||
path: ${PREFIX}/data/enemies/code.gif
|
path: ${PREFIX}/data/enemies/code_spritesheet.gif
|
||||||
- type: ANIMATION
|
- type: ANIMATION
|
||||||
path: ${PREFIX}/data/enemies/code.yaml
|
path: ${PREFIX}/data/enemies/code_animations.yaml
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# code animation
|
# code animation
|
||||||
tileSetFile: code.gif
|
tileSetFile: code_spritesheet.gif
|
||||||
frameWidth: 16
|
frameWidth: 16
|
||||||
frameHeight: 16
|
frameHeight: 16
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 223 B |
@@ -1,20 +0,0 @@
|
|||||||
# player2 animation
|
|
||||||
tileSetFile: player2.gif
|
|
||||||
frameWidth: 8
|
|
||||||
frameHeight: 16
|
|
||||||
|
|
||||||
animations:
|
|
||||||
- name: stand
|
|
||||||
speed: 0.1333
|
|
||||||
loop: 0
|
|
||||||
frames: [0]
|
|
||||||
|
|
||||||
- name: walk
|
|
||||||
speed: 0.1333
|
|
||||||
loop: 0
|
|
||||||
frames: [0, 1, 2, 3, 4, 5, 6, 7]
|
|
||||||
|
|
||||||
- name: walk_menu
|
|
||||||
speed: 0.0
|
|
||||||
loop: 0
|
|
||||||
frames: [0, 1, 2, 3, 4, 5, 6, 7]
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# player animation
|
# player animation
|
||||||
tileSetFile: player.gif
|
tileSetFile: player_spritesheet.gif
|
||||||
frameWidth: 8
|
frameWidth: 8
|
||||||
frameHeight: 16
|
frameHeight: 16
|
||||||
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 225 B |
@@ -1,10 +0,0 @@
|
|||||||
# player_game_over animation
|
|
||||||
tileSetFile: player_game_over.gif
|
|
||||||
frameWidth: 19
|
|
||||||
frameHeight: 18
|
|
||||||
|
|
||||||
animations:
|
|
||||||
- name: default
|
|
||||||
speed: 0.1
|
|
||||||
loop: 0
|
|
||||||
frames: [0, 1, 2, 3]
|
|
||||||
15
data/player/player_physics.yaml
Normal file
15
data/player/player_physics.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Player Physics Configuration
|
||||||
|
# All velocities in pixels/second
|
||||||
|
# All accelerations in pixels/second²
|
||||||
|
# All times in seconds
|
||||||
|
|
||||||
|
# Horizontal movement
|
||||||
|
walk_velocity: 50.0 # Velocidad al caminar (inmediata)
|
||||||
|
run_velocity: 80.0 # Velocidad al correr
|
||||||
|
time_to_run: 0.8 # Segundos caminando antes de empezar a correr
|
||||||
|
run_acceleration: 150.0 # Aceleración de caminar a correr
|
||||||
|
horizontal_deceleration: 250.0 # Desaceleración al soltar (momentum)
|
||||||
|
|
||||||
|
# Vertical movement (jump and gravity)
|
||||||
|
jump_velocity: -160.0 # Impulso de salto (negativo = hacia arriba)
|
||||||
|
gravity_force: 280.0 # Gravedad aplicada
|
||||||
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 291 B |
@@ -1,6 +1,5 @@
|
|||||||
# VOID MAIN
|
# 03
|
||||||
room:
|
room:
|
||||||
name: "VOID MAIN"
|
|
||||||
bgColor: blue
|
bgColor: blue
|
||||||
border: mauve
|
border: mauve
|
||||||
tileSetFile: standard.gif
|
tileSetFile: standard.gif
|
||||||
@@ -77,7 +76,7 @@ collisionmap:
|
|||||||
|
|
||||||
# Enemigos en esta habitación
|
# Enemigos en esta habitación
|
||||||
enemies:
|
enemies:
|
||||||
- animation: code.yaml
|
- animation: code_animations.yaml
|
||||||
position: {x: 1, y: 17}
|
position: {x: 1, y: 17}
|
||||||
velocity: {x: 24.0, y: 0}
|
velocity: {x: 24.0, y: 0}
|
||||||
boundaries:
|
boundaries:
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
# Imagen para compilar pollo en múltiples plataformas
|
|
||||||
# Incluye herramientas para: Linux x64, Windows x64 (cross), Raspberry Pi ARM64 (cross)
|
|
||||||
# SDL3 se compila en cada job del workflow
|
|
||||||
|
|
||||||
FROM ubuntu:24.04
|
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
# Herramientas básicas de build
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
build-essential \
|
|
||||||
cmake \
|
|
||||||
git \
|
|
||||||
pkg-config \
|
|
||||||
wget \
|
|
||||||
tar \
|
|
||||||
gzip \
|
|
||||||
zip \
|
|
||||||
# Node.js (requerido para GitHub/Gitea Actions)
|
|
||||||
nodejs \
|
|
||||||
npm \
|
|
||||||
# Cross-compilación Windows
|
|
||||||
mingw-w64 \
|
|
||||||
# Cross-compilación Raspberry Pi ARM64
|
|
||||||
gcc-aarch64-linux-gnu \
|
|
||||||
g++-aarch64-linux-gnu \
|
|
||||||
# Dependencias para compilar SDL3 (Linux nativo)
|
|
||||||
libgl1-mesa-dev \
|
|
||||||
libglu1-mesa-dev \
|
|
||||||
libx11-dev \
|
|
||||||
libxext-dev \
|
|
||||||
libxrandr-dev \
|
|
||||||
libxcursor-dev \
|
|
||||||
libxi-dev \
|
|
||||||
libxinerama-dev \
|
|
||||||
libxxf86vm-dev \
|
|
||||||
libxss-dev \
|
|
||||||
libasound2-dev \
|
|
||||||
libpulse-dev \
|
|
||||||
libudev-dev \
|
|
||||||
libdbus-1-dev \
|
|
||||||
libwayland-dev \
|
|
||||||
libxkbcommon-dev \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /workspace
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# Docker Compose para act_runner de Gitea Actions
|
|
||||||
#
|
|
||||||
# USO:
|
|
||||||
# 1. Obtener token de registro en Gitea > Settings > Actions > Runners
|
|
||||||
# 2. Actualizar GITEA_RUNNER_REGISTRATION_TOKEN abajo
|
|
||||||
# 3. Iniciar: docker compose -f docker-compose.runner.yml up -d runner
|
|
||||||
# 4. Ver logs: docker compose -f docker-compose.runner.yml logs -f runner
|
|
||||||
|
|
||||||
services:
|
|
||||||
runner:
|
|
||||||
image: gitea/act_runner:latest
|
|
||||||
container_name: gitea-runner-pollo
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
- ./runner-data:/data
|
|
||||||
environment:
|
|
||||||
- GITEA_INSTANCE_URL=http://gitea:3000
|
|
||||||
- GITEA_RUNNER_REGISTRATION_TOKEN=${RUNNER_TOKEN}
|
|
||||||
- GITEA_RUNNER_NAME=pollo-runner
|
|
||||||
- GITEA_RUNNER_LABELS=ubuntu-latest:docker://ubuntu:24.04,linux:docker://ubuntu:24.04
|
|
||||||
- CONFIG_FILE=/data/config.yaml
|
|
||||||
networks:
|
|
||||||
- web
|
|
||||||
|
|
||||||
networks:
|
|
||||||
web:
|
|
||||||
external: true
|
|
||||||
@@ -182,10 +182,6 @@ auto Director::checkProgramArguments(std::vector<std::string> const& args) -> st
|
|||||||
Options::cheats.infinite_lives = Options::Cheat::State::ENABLED;
|
Options::cheats.infinite_lives = Options::Cheat::State::ENABLED;
|
||||||
} else if (argument == "--invincible") {
|
} else if (argument == "--invincible") {
|
||||||
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
||||||
} else if (argument == "--jailEnabled") {
|
|
||||||
Options::cheats.jail_is_open = Options::Cheat::State::ENABLED;
|
|
||||||
} else if (argument == "--altSkin") {
|
|
||||||
Options::cheats.alternate_skin = Options::Cheat::State::ENABLED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ constexpr const char* NOTIFY = "notify.wav"; // Sonido de notificación
|
|||||||
namespace Cheat {
|
namespace Cheat {
|
||||||
constexpr bool INFINITE_LIVES = false; // Vidas infinitas desactivadas por defecto
|
constexpr bool INFINITE_LIVES = false; // Vidas infinitas desactivadas por defecto
|
||||||
constexpr bool INVINCIBLE = false; // Invencibilidad desactivada por defecto
|
constexpr bool INVINCIBLE = false; // Invencibilidad desactivada por defecto
|
||||||
constexpr bool JAIL_IS_OPEN = false; // Jail abierta desactivada por defecto
|
|
||||||
constexpr bool ALTERNATE_SKIN = false; // Skin alternativa desactivada por defecto
|
|
||||||
} // namespace Cheat
|
} // namespace Cheat
|
||||||
|
|
||||||
// --- CONTROLS ---
|
// --- CONTROLS ---
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "core/input/input.hpp" // Para Input, InputAction
|
#include "core/input/input.hpp" // Para Input, InputAction
|
||||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||||
|
#include "core/resources/resource_helper.hpp" // Para Resource::Helper
|
||||||
|
#include "external/fkyaml_node.hpp" // Para fkyaml::node
|
||||||
#include "game/defaults.hpp" // Para Defaults::Sound
|
#include "game/defaults.hpp" // Para Defaults::Sound
|
||||||
#include "game/gameplay/room.hpp" // Para Room, TileType
|
#include "game/gameplay/room.hpp" // Para Room, TileType
|
||||||
#include "game/options.hpp" // Para Cheat, Options, options
|
#include "game/options.hpp" // Para Cheat, Options, options
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(const Data& player)
|
Player::Player(const Data& player)
|
||||||
: room_(player.room) {
|
: room_(player.room) {
|
||||||
|
loadPhysicsConfig("player_physics.yaml");
|
||||||
initSprite(player.animations_path);
|
initSprite(player.animations_path);
|
||||||
setColor();
|
setColor();
|
||||||
applySpawnValues(player.spawn_data);
|
applySpawnValues(player.spawn_data);
|
||||||
@@ -122,7 +125,7 @@ void Player::transitionToState(State state) {
|
|||||||
break;
|
break;
|
||||||
case State::ON_AIR:
|
case State::ON_AIR:
|
||||||
if (previous_state_ == State::ON_GROUND) {
|
if (previous_state_ == State::ON_GROUND) {
|
||||||
vy_ = JUMP_VELOCITY; // Impulso de salto
|
vy_ = physics_.jump_velocity; // Impulso de salto
|
||||||
last_grounded_position_ = y_;
|
last_grounded_position_ = y_;
|
||||||
Audio::get()->playSound(Defaults::Sound::JUMP, Audio::Group::GAME);
|
Audio::get()->playSound(Defaults::Sound::JUMP, Audio::Group::GAME);
|
||||||
}
|
}
|
||||||
@@ -257,7 +260,7 @@ void Player::switchBorders() {
|
|||||||
void Player::applyGravity(float delta_time) {
|
void Player::applyGravity(float delta_time) {
|
||||||
// La gravedad se aplica siempre que el jugador está en el aire
|
// La gravedad se aplica siempre que el jugador está en el aire
|
||||||
if (state_ == State::ON_AIR) {
|
if (state_ == State::ON_AIR) {
|
||||||
vy_ += GRAVITY_FORCE * delta_time;
|
vy_ += physics_.gravity_force * delta_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,16 +342,49 @@ void Player::setColor(Uint8 color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los puntos de colisión
|
// Actualiza los puntos de colisión
|
||||||
|
// Sistema dinámico que adapta el número de puntos al tamaño del sprite
|
||||||
|
// Para sprites más grandes que los tiles (8px), genera puntos adicionales
|
||||||
|
// evitando que se atraviesen tiles al haber huecos entre colliders
|
||||||
void Player::updateColliderPoints() {
|
void Player::updateColliderPoints() {
|
||||||
const SDL_FRect RECT = getRect();
|
const SDL_FRect RECT = getRect();
|
||||||
collider_points_[0] = {.x = RECT.x, .y = RECT.y};
|
|
||||||
collider_points_[1] = {.x = RECT.x + 7, .y = RECT.y};
|
// Calcular cuántos puntos necesitamos por cada dimensión
|
||||||
collider_points_[2] = {.x = RECT.x + 7, .y = RECT.y + 7};
|
// Regla: un punto cada ~7px (menos que Tile::SIZE=8px) para garantizar detección
|
||||||
collider_points_[3] = {.x = RECT.x, .y = RECT.y + 7};
|
// Como mínimo 2 puntos por borde (esquinas)
|
||||||
collider_points_[4] = {.x = RECT.x, .y = RECT.y + 8};
|
constexpr int MAX_SPACING = 7; // Máxima distancia entre puntos (menor que tile size de 8px)
|
||||||
collider_points_[5] = {.x = RECT.x + 7, .y = RECT.y + 8};
|
|
||||||
collider_points_[6] = {.x = RECT.x + 7, .y = RECT.y + 15};
|
const int points_per_width = std::max(2, (WIDTH / MAX_SPACING) + 1);
|
||||||
collider_points_[7] = {.x = RECT.x, .y = RECT.y + 15};
|
const int points_per_height = std::max(2, (HEIGHT / MAX_SPACING) + 1);
|
||||||
|
|
||||||
|
// Limpiar y reservar espacio para los nuevos puntos
|
||||||
|
collider_points_.clear();
|
||||||
|
collider_points_.reserve(2 * points_per_width + 2 * points_per_height - 4); // Perímetro sin duplicar esquinas
|
||||||
|
|
||||||
|
// Generar puntos distribuidos uniformemente por el perímetro del rectángulo
|
||||||
|
|
||||||
|
// Borde superior (izquierda a derecha)
|
||||||
|
for (int i = 0; i < points_per_width; ++i) {
|
||||||
|
const float offset = (WIDTH - 1) * static_cast<float>(i) / static_cast<float>(points_per_width - 1);
|
||||||
|
collider_points_.push_back({.x = RECT.x + offset, .y = RECT.y});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Borde derecho (arriba a abajo, sin repetir esquina superior derecha)
|
||||||
|
for (int i = 1; i < points_per_height; ++i) {
|
||||||
|
const float offset = (HEIGHT - 1) * static_cast<float>(i) / static_cast<float>(points_per_height - 1);
|
||||||
|
collider_points_.push_back({.x = RECT.x + WIDTH - 1, .y = RECT.y + offset});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Borde inferior (derecha a izquierda, sin repetir esquina inferior derecha)
|
||||||
|
for (int i = 1; i < points_per_width; ++i) {
|
||||||
|
const float offset = (WIDTH - 1) * static_cast<float>(points_per_width - 1 - i) / static_cast<float>(points_per_width - 1);
|
||||||
|
collider_points_.push_back({.x = RECT.x + offset, .y = RECT.y + HEIGHT - 1});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Borde izquierdo (abajo a arriba, sin repetir esquinas)
|
||||||
|
for (int i = 1; i < points_per_height - 1; ++i) {
|
||||||
|
const float offset = (HEIGHT - 1) * static_cast<float>(points_per_height - 1 - i) / static_cast<float>(points_per_height - 1);
|
||||||
|
collider_points_.push_back({.x = RECT.x, .y = RECT.y + offset});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los puntos de los pies
|
// Actualiza los puntos de los pies
|
||||||
@@ -382,6 +418,54 @@ void Player::initSprite(const std::string& animations_path) {
|
|||||||
sprite_->setCurrentAnimation("walk");
|
sprite_->setCurrentAnimation("walk");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Carga la configuración de física desde YAML
|
||||||
|
void Player::loadPhysicsConfig(const std::string& path) {
|
||||||
|
try {
|
||||||
|
auto file_data = Resource::Helper::loadFile(path);
|
||||||
|
std::string yaml_content(file_data.begin(), file_data.end());
|
||||||
|
auto yaml = fkyaml::node::deserialize(yaml_content);
|
||||||
|
|
||||||
|
// Cargar valores del YAML (con fallback a valores por defecto si falta alguna clave)
|
||||||
|
if (yaml.contains("walk_velocity")) {
|
||||||
|
physics_.walk_velocity = yaml["walk_velocity"].get_value<float>();
|
||||||
|
}
|
||||||
|
if (yaml.contains("run_velocity")) {
|
||||||
|
physics_.run_velocity = yaml["run_velocity"].get_value<float>();
|
||||||
|
}
|
||||||
|
if (yaml.contains("time_to_run")) {
|
||||||
|
physics_.time_to_run = yaml["time_to_run"].get_value<float>();
|
||||||
|
}
|
||||||
|
if (yaml.contains("run_acceleration")) {
|
||||||
|
physics_.run_acceleration = yaml["run_acceleration"].get_value<float>();
|
||||||
|
}
|
||||||
|
if (yaml.contains("horizontal_deceleration")) {
|
||||||
|
physics_.horizontal_deceleration = yaml["horizontal_deceleration"].get_value<float>();
|
||||||
|
}
|
||||||
|
if (yaml.contains("jump_velocity")) {
|
||||||
|
physics_.jump_velocity = yaml["jump_velocity"].get_value<float>();
|
||||||
|
}
|
||||||
|
if (yaml.contains("gravity_force")) {
|
||||||
|
physics_.gravity_force = yaml["gravity_force"].get_value<float>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
std::cout << "[Player] Physics config loaded: walk=" << physics_.walk_velocity
|
||||||
|
<< " run=" << physics_.run_velocity
|
||||||
|
<< " jump=" << physics_.jump_velocity
|
||||||
|
<< " gravity=" << physics_.gravity_force << std::endl;
|
||||||
|
#endif
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "[Player] Error loading physics config from '" << path << "': " << e.what() << std::endl;
|
||||||
|
std::cerr << "[Player] Using default physics values" << std::endl;
|
||||||
|
// Los valores por defecto ya están establecidos en PhysicsConfig
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recarga la configuración de física desde el archivo YAML
|
||||||
|
void Player::reloadPhysics() {
|
||||||
|
loadPhysicsConfig("player_physics.yaml");
|
||||||
|
}
|
||||||
|
|
||||||
// Actualiza la posición del sprite y las colisiones
|
// Actualiza la posición del sprite y las colisiones
|
||||||
void Player::syncSpriteAndCollider() {
|
void Player::syncSpriteAndCollider() {
|
||||||
placeSprite(); // Coloca el sprite en la posición del jugador
|
placeSprite(); // Coloca el sprite en la posición del jugador
|
||||||
@@ -401,7 +485,7 @@ void Player::placeSprite() {
|
|||||||
void Player::updateVelocity(float delta_time) {
|
void Player::updateVelocity(float delta_time) {
|
||||||
if (auto_movement_) {
|
if (auto_movement_) {
|
||||||
// La cinta transportadora tiene el control (velocidad fija)
|
// La cinta transportadora tiene el control (velocidad fija)
|
||||||
vx_ = RUN_VELOCITY * room_->getConveyorBeltDirection();
|
vx_ = physics_.run_velocity * room_->getConveyorBeltDirection();
|
||||||
sprite_->setFlip(vx_ < 0.0F ? Flip::LEFT : Flip::RIGHT);
|
sprite_->setFlip(vx_ < 0.0F ? Flip::LEFT : Flip::RIGHT);
|
||||||
movement_time_ = 0.0F;
|
movement_time_ = 0.0F;
|
||||||
} else {
|
} else {
|
||||||
@@ -409,25 +493,25 @@ void Player::updateVelocity(float delta_time) {
|
|||||||
switch (wanna_go_) {
|
switch (wanna_go_) {
|
||||||
case Direction::LEFT:
|
case Direction::LEFT:
|
||||||
movement_time_ += delta_time;
|
movement_time_ += delta_time;
|
||||||
if (movement_time_ < TIME_TO_RUN) {
|
if (movement_time_ < physics_.time_to_run) {
|
||||||
// Caminando: velocidad fija inmediata
|
// Caminando: velocidad fija inmediata
|
||||||
vx_ = -WALK_VELOCITY;
|
vx_ = -physics_.walk_velocity;
|
||||||
} else {
|
} else {
|
||||||
// Corriendo: acelerar hacia RUN_VELOCITY
|
// Corriendo: acelerar hacia RUN_VELOCITY
|
||||||
vx_ -= RUN_ACCELERATION * delta_time;
|
vx_ -= physics_.run_acceleration * delta_time;
|
||||||
vx_ = std::max(vx_, -RUN_VELOCITY);
|
vx_ = std::max(vx_, -physics_.run_velocity);
|
||||||
}
|
}
|
||||||
sprite_->setFlip(Flip::LEFT);
|
sprite_->setFlip(Flip::LEFT);
|
||||||
break;
|
break;
|
||||||
case Direction::RIGHT:
|
case Direction::RIGHT:
|
||||||
movement_time_ += delta_time;
|
movement_time_ += delta_time;
|
||||||
if (movement_time_ < TIME_TO_RUN) {
|
if (movement_time_ < physics_.time_to_run) {
|
||||||
// Caminando: velocidad fija inmediata
|
// Caminando: velocidad fija inmediata
|
||||||
vx_ = WALK_VELOCITY;
|
vx_ = physics_.walk_velocity;
|
||||||
} else {
|
} else {
|
||||||
// Corriendo: acelerar hacia RUN_VELOCITY
|
// Corriendo: acelerar hacia RUN_VELOCITY
|
||||||
vx_ += RUN_ACCELERATION * delta_time;
|
vx_ += physics_.run_acceleration * delta_time;
|
||||||
vx_ = std::min(vx_, RUN_VELOCITY);
|
vx_ = std::min(vx_, physics_.run_velocity);
|
||||||
}
|
}
|
||||||
sprite_->setFlip(Flip::RIGHT);
|
sprite_->setFlip(Flip::RIGHT);
|
||||||
break;
|
break;
|
||||||
@@ -435,10 +519,10 @@ void Player::updateVelocity(float delta_time) {
|
|||||||
movement_time_ = 0.0F;
|
movement_time_ = 0.0F;
|
||||||
// Desacelerar gradualmente (momentum)
|
// Desacelerar gradualmente (momentum)
|
||||||
if (vx_ > 0.0F) {
|
if (vx_ > 0.0F) {
|
||||||
vx_ -= HORIZONTAL_DECELERATION * delta_time;
|
vx_ -= physics_.horizontal_deceleration * delta_time;
|
||||||
vx_ = std::max(vx_, 0.0F);
|
vx_ = std::max(vx_, 0.0F);
|
||||||
} else if (vx_ < 0.0F) {
|
} else if (vx_ < 0.0F) {
|
||||||
vx_ += HORIZONTAL_DECELERATION * delta_time;
|
vx_ += physics_.horizontal_deceleration * delta_time;
|
||||||
vx_ = std::min(vx_, 0.0F);
|
vx_ = std::min(vx_, 0.0F);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <memory> // Para shared_ptr, __shared_ptr_access
|
#include <memory> // Para shared_ptr, __shared_ptr_access
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <vector> // Para vector
|
||||||
|
|
||||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||||
#include "game/gameplay/room.hpp"
|
#include "game/gameplay/room.hpp"
|
||||||
@@ -16,6 +17,10 @@
|
|||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
public:
|
public:
|
||||||
|
// --- Constantes de tamaño ---
|
||||||
|
static constexpr int WIDTH = 8; // Ancho del jugador en pixels
|
||||||
|
static constexpr int HEIGHT = 16; // Alto del jugador en pixels
|
||||||
|
|
||||||
// --- Enums y Structs ---
|
// --- Enums y Structs ---
|
||||||
enum class State {
|
enum class State {
|
||||||
ON_GROUND, // En suelo plano o conveyor belt
|
ON_GROUND, // En suelo plano o conveyor belt
|
||||||
@@ -64,6 +69,8 @@ class Player {
|
|||||||
//[[nodiscard]] auto isAlive() const -> bool { return is_alive_ || (Options::cheats.invincible == Options::Cheat::State::ENABLED); } // Comprueba si el jugador esta vivo
|
//[[nodiscard]] auto isAlive() const -> bool { return is_alive_ || (Options::cheats.invincible == Options::Cheat::State::ENABLED); } // Comprueba si el jugador esta vivo
|
||||||
[[nodiscard]] auto isAlive() const -> bool { return is_alive_; } // Comprueba si el jugador esta vivo
|
[[nodiscard]] auto isAlive() const -> bool { return is_alive_; } // Comprueba si el jugador esta vivo
|
||||||
void setPaused(bool value) { is_paused_ = value; } // Pone el jugador en modo pausa
|
void setPaused(bool value) { is_paused_ = value; } // Pone el jugador en modo pausa
|
||||||
|
auto handleKillingTiles() -> bool; // Comprueba que el jugador no toque ningun tile de los que matan
|
||||||
|
void reloadPhysics(); // Recarga la configuración de física desde el archivo YAML
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// --- Funciones de debug ---
|
// --- Funciones de debug ---
|
||||||
@@ -72,20 +79,18 @@ class Player {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Constantes de tamaño ---
|
// --- Configuración de física ---
|
||||||
static constexpr int WIDTH = 8; // Ancho del jugador en pixels
|
struct PhysicsConfig {
|
||||||
static constexpr int HEIGHT = 16; // Alto del jugador en pixels
|
float walk_velocity = 50.0F; // Velocidad al caminar (inmediata) en pixels/segundo
|
||||||
|
float run_velocity = 80.0F; // Velocidad al correr en pixels/segundo
|
||||||
|
float time_to_run = 0.8F; // Segundos caminando antes de empezar a correr
|
||||||
|
float run_acceleration = 150.0F; // Aceleración de caminar a correr en pixels/segundo²
|
||||||
|
float horizontal_deceleration = 250.0F; // Desaceleración al soltar (momentum) en pixels/segundo²
|
||||||
|
float jump_velocity = -160.0F; // Impulso de salto en pixels/segundo (más fuerte, menos floaty)
|
||||||
|
float gravity_force = 280.0F; // Gravedad en pixels/segundo² (más alta, menos floaty)
|
||||||
|
};
|
||||||
|
|
||||||
// --- Constantes de movimiento horizontal ---
|
PhysicsConfig physics_; // Configuración de física cargada desde YAML
|
||||||
static constexpr float WALK_VELOCITY = 50.0F; // Velocidad al caminar (inmediata) en pixels/segundo
|
|
||||||
static constexpr float RUN_VELOCITY = 80.0F; // Velocidad al correr en pixels/segundo
|
|
||||||
static constexpr float TIME_TO_RUN = 0.8F; // Segundos caminando antes de empezar a correr
|
|
||||||
static constexpr float RUN_ACCELERATION = 150.0F; // Aceleración de caminar a correr en pixels/segundo²
|
|
||||||
static constexpr float HORIZONTAL_DECELERATION = 250.0F; // Desaceleración al soltar (momentum) en pixels/segundo²
|
|
||||||
|
|
||||||
// --- Constantes de salto ---
|
|
||||||
static constexpr float JUMP_VELOCITY = -160.0F; // Impulso de salto en pixels/segundo (más fuerte, menos floaty)
|
|
||||||
static constexpr float GRAVITY_FORCE = 280.0F; // Gravedad en pixels/segundo² (más alta, menos floaty)
|
|
||||||
|
|
||||||
// --- Objetos y punteros ---
|
// --- Objetos y punteros ---
|
||||||
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
||||||
@@ -108,7 +113,7 @@ class Player {
|
|||||||
|
|
||||||
// --- Variables de colisión ---
|
// --- Variables de colisión ---
|
||||||
SDL_FRect collider_box_{}; // Caja de colisión con los enemigos u objetos
|
SDL_FRect collider_box_{}; // Caja de colisión con los enemigos u objetos
|
||||||
std::array<SDL_FPoint, 8> collider_points_{}; // Puntos de colisión con el mapa
|
std::vector<SDL_FPoint> collider_points_{}; // Puntos de colisión con el mapa (dinámico, se adapta al tamaño del sprite)
|
||||||
SDL_FPoint under_left_foot_ = {0.0F, 0.0F}; // El punto bajo la esquina inferior izquierda del jugador
|
SDL_FPoint under_left_foot_ = {0.0F, 0.0F}; // El punto bajo la esquina inferior izquierda del jugador
|
||||||
SDL_FPoint under_right_foot_ = {0.0F, 0.0F}; // El punto bajo la esquina inferior derecha del jugador
|
SDL_FPoint under_right_foot_ = {0.0F, 0.0F}; // El punto bajo la esquina inferior derecha del jugador
|
||||||
|
|
||||||
@@ -137,6 +142,7 @@ class Player {
|
|||||||
// --- Funciones de inicialización ---
|
// --- Funciones de inicialización ---
|
||||||
void initSprite(const std::string& animations_path); // Inicializa el sprite del jugador
|
void initSprite(const std::string& animations_path); // Inicializa el sprite del jugador
|
||||||
void applySpawnValues(const SpawnData& spawn); // Aplica los valores de spawn al jugador
|
void applySpawnValues(const SpawnData& spawn); // Aplica los valores de spawn al jugador
|
||||||
|
void loadPhysicsConfig(const std::string& path); // Carga la configuración de física desde YAML
|
||||||
|
|
||||||
// --- Funciones de procesamiento de entrada ---
|
// --- Funciones de procesamiento de entrada ---
|
||||||
void handleInput(); // Comprueba las entradas y modifica variables
|
void handleInput(); // Comprueba las entradas y modifica variables
|
||||||
@@ -167,7 +173,6 @@ class Player {
|
|||||||
// --- Funciones de finalización ---
|
// --- Funciones de finalización ---
|
||||||
void animate(float delta_time); // Establece la animación del jugador
|
void animate(float delta_time); // Establece la animación del jugador
|
||||||
auto handleBorders() -> Room::Border; // Comprueba si se halla en alguno de los cuatro bordes
|
auto handleBorders() -> Room::Border; // Comprueba si se halla en alguno de los cuatro bordes
|
||||||
auto handleKillingTiles() -> bool; // Comprueba que el jugador no toque ningun tile de los que matan
|
|
||||||
void updateVelocity(float delta_time); // Calcula la velocidad en x con aceleración
|
void updateVelocity(float delta_time); // Calcula la velocidad en x con aceleración
|
||||||
void markAsDead(); // Marca al jugador como muerto
|
void markAsDead(); // Marca al jugador como muerto
|
||||||
};
|
};
|
||||||
@@ -22,10 +22,9 @@ Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
|
|||||||
|
|
||||||
// Crea los managers de enemigos e items
|
// Crea los managers de enemigos e items
|
||||||
enemy_manager_ = std::make_unique<EnemyManager>();
|
enemy_manager_ = std::make_unique<EnemyManager>();
|
||||||
item_manager_ = std::make_unique<ItemManager>(room->name, data_);
|
item_manager_ = std::make_unique<ItemManager>(room->number, data_);
|
||||||
|
|
||||||
initializeRoom(*room);
|
initializeRoom(*room);
|
||||||
openTheJail(); // Abre la Jail si se da el caso
|
|
||||||
|
|
||||||
// Crea el mapa de colisiones (necesita collision_data_, conveyor_belt_direction_)
|
// Crea el mapa de colisiones (necesita collision_data_, conveyor_belt_direction_)
|
||||||
collision_map_ = std::make_unique<CollisionMap>(collision_data_, conveyor_belt_direction_);
|
collision_map_ = std::make_unique<CollisionMap>(collision_data_, conveyor_belt_direction_);
|
||||||
@@ -43,7 +42,6 @@ Room::~Room() = default;
|
|||||||
void Room::initializeRoom(const Data& room) {
|
void Room::initializeRoom(const Data& room) {
|
||||||
// Asignar valores a las variables miembro
|
// Asignar valores a las variables miembro
|
||||||
number_ = room.number;
|
number_ = room.number;
|
||||||
name_ = room.name;
|
|
||||||
bg_color_ = room.bg_color;
|
bg_color_ = room.bg_color;
|
||||||
border_color_ = room.border_color;
|
border_color_ = room.border_color;
|
||||||
item_color1_ = room.item_color1.empty() ? "yellow" : room.item_color1;
|
item_color1_ = room.item_color1.empty() ? "yellow" : room.item_color1;
|
||||||
@@ -69,7 +67,7 @@ void Room::initializeRoom(const Data& room) {
|
|||||||
for (const auto& item : room.items) {
|
for (const auto& item : room.items) {
|
||||||
const SDL_FPoint ITEM_POS = {item.x, item.y};
|
const SDL_FPoint ITEM_POS = {item.x, item.y};
|
||||||
|
|
||||||
if (!ItemTracker::get()->hasBeenPicked(room.name, ITEM_POS)) {
|
if (!ItemTracker::get()->hasBeenPicked(room.number, ITEM_POS)) {
|
||||||
// Crear una copia local de los datos del item
|
// Crear una copia local de los datos del item
|
||||||
Item::Data item_copy = item;
|
Item::Data item_copy = item;
|
||||||
item_copy.color1 = stringToColor(item_color1_);
|
item_copy.color1 = stringToColor(item_color1_);
|
||||||
@@ -81,28 +79,6 @@ void Room::initializeRoom(const Data& room) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abre la jail para poder entrar
|
|
||||||
void Room::openTheJail() {
|
|
||||||
if (data_->jail_is_open && name_ == "THE JAIL") {
|
|
||||||
// Elimina el último enemigo (Bry debe ser el último enemigo definido en el fichero)
|
|
||||||
if (!enemy_manager_->isEmpty()) {
|
|
||||||
enemy_manager_->removeLastEnemy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Abre las puertas (tanto en tilemap para renderizado como en collisionmap para colisiones)
|
|
||||||
constexpr int TILE_A = 16 + (13 * MAP_WIDTH);
|
|
||||||
constexpr int TILE_B = 16 + (14 * MAP_WIDTH);
|
|
||||||
if (TILE_A < tile_map_.size()) {
|
|
||||||
tile_map_[TILE_A] = -1; // Renderizado: vacío
|
|
||||||
collision_data_[TILE_A] = -1; // Colisiones: vacío
|
|
||||||
}
|
|
||||||
if (TILE_B < tile_map_.size()) {
|
|
||||||
tile_map_[TILE_B] = -1; // Renderizado: vacío
|
|
||||||
collision_data_[TILE_B] = -1; // Colisiones: vacío
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dibuja el mapa en pantalla
|
// Dibuja el mapa en pantalla
|
||||||
void Room::renderMap() {
|
void Room::renderMap() {
|
||||||
tilemap_renderer_->render();
|
tilemap_renderer_->render();
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class Room {
|
|||||||
|
|
||||||
struct Data {
|
struct Data {
|
||||||
std::string number; // Numero de la habitación
|
std::string number; // Numero de la habitación
|
||||||
std::string name; // Nombre de la habitación
|
|
||||||
std::string bg_color; // Color de fondo de la habitación
|
std::string bg_color; // Color de fondo de la habitación
|
||||||
std::string border_color; // Color del borde de la pantalla
|
std::string border_color; // Color del borde de la pantalla
|
||||||
std::string item_color1; // Color 1 para los items de la habitación
|
std::string item_color1; // Color 1 para los items de la habitación
|
||||||
@@ -61,7 +60,6 @@ class Room {
|
|||||||
~Room(); // Definido en .cpp para poder usar unique_ptr con forward declarations
|
~Room(); // Definido en .cpp para poder usar unique_ptr con forward declarations
|
||||||
|
|
||||||
// --- Funciones ---
|
// --- Funciones ---
|
||||||
[[nodiscard]] auto getName() const -> const std::string& { return name_; } // Devuelve el nombre de la habitación
|
|
||||||
[[nodiscard]] auto getBGColor() const -> Uint8 { return stringToColor(bg_color_); } // Devuelve el color de la habitación
|
[[nodiscard]] auto getBGColor() const -> Uint8 { return stringToColor(bg_color_); } // Devuelve el color de la habitación
|
||||||
[[nodiscard]] auto getBorderColor() const -> Uint8 { return stringToColor(border_color_); } // Devuelve el color del borde
|
[[nodiscard]] auto getBorderColor() const -> Uint8 { return stringToColor(border_color_); } // Devuelve el color del borde
|
||||||
void renderMap(); // Dibuja el mapa en pantalla
|
void renderMap(); // Dibuja el mapa en pantalla
|
||||||
@@ -106,7 +104,6 @@ class Room {
|
|||||||
|
|
||||||
// --- Variables ---
|
// --- Variables ---
|
||||||
std::string number_; // Numero de la habitación
|
std::string number_; // Numero de la habitación
|
||||||
std::string name_; // Nombre de la habitación
|
|
||||||
std::string bg_color_; // Color de fondo de la habitación
|
std::string bg_color_; // Color de fondo de la habitación
|
||||||
std::string border_color_; // Color del borde de la pantalla
|
std::string border_color_; // Color del borde de la pantalla
|
||||||
std::string item_color1_; // Color 1 para los items de la habitación
|
std::string item_color1_; // Color 1 para los items de la habitación
|
||||||
@@ -124,5 +121,4 @@ class Room {
|
|||||||
|
|
||||||
// --- Funciones ---
|
// --- Funciones ---
|
||||||
void initializeRoom(const Data& room); // Inicializa los valores
|
void initializeRoom(const Data& room); // Inicializa los valores
|
||||||
void openTheJail(); // Abre la jail para poder entrar
|
|
||||||
};
|
};
|
||||||
@@ -63,9 +63,6 @@ void RoomLoader::parseRoomConfig(const fkyaml::node& yaml, Room::Data& room, con
|
|||||||
room.number = file_name.substr(0, file_name.find_last_of('.'));
|
room.number = file_name.substr(0, file_name.find_last_of('.'));
|
||||||
|
|
||||||
// Basic properties
|
// Basic properties
|
||||||
if (room_node.contains("name")) {
|
|
||||||
room.name = room_node["name"].get_value<std::string>();
|
|
||||||
}
|
|
||||||
if (room_node.contains("bgColor")) {
|
if (room_node.contains("bgColor")) {
|
||||||
room.bg_color = room_node["bgColor"].get_value<std::string>();
|
room.bg_color = room_node["bgColor"].get_value<std::string>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ Scoreboard::Scoreboard(std::shared_ptr<Data> data)
|
|||||||
constexpr float SURFACE_HEIGHT = ScoreboardArea::HEIGHT;
|
constexpr float SURFACE_HEIGHT = ScoreboardArea::HEIGHT;
|
||||||
|
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
const auto& player_animation_data = Resource::Cache::get()->getAnimationData(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.yaml" : "player.yaml");
|
player_sprite_ = std::make_shared<SurfaceAnimatedSprite>(Resource::Cache::get()->getAnimationData("player_animations.yaml"));
|
||||||
player_sprite_ = std::make_shared<SurfaceAnimatedSprite>(player_animation_data);
|
|
||||||
player_sprite_->setCurrentAnimation("walk_menu");
|
player_sprite_->setCurrentAnimation("walk_menu");
|
||||||
|
|
||||||
surface_ = std::make_shared<Surface>(SURFACE_WIDTH, SURFACE_HEIGHT);
|
surface_ = std::make_shared<Surface>(SURFACE_WIDTH, SURFACE_HEIGHT);
|
||||||
@@ -96,23 +95,8 @@ void Scoreboard::setPaused(bool value) {
|
|||||||
|
|
||||||
// Actualiza el color de la cantidad de items recogidos
|
// Actualiza el color de la cantidad de items recogidos
|
||||||
void Scoreboard::updateItemsColor(float delta_time) {
|
void Scoreboard::updateItemsColor(float delta_time) {
|
||||||
if (!data_->jail_is_open) {
|
// No hay animación de color de items en este juego
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
items_color_timer_ += delta_time;
|
|
||||||
|
|
||||||
// Resetear timer cada 2 ciclos (0.666s total)
|
|
||||||
if (items_color_timer_ >= ITEMS_COLOR_BLINK_DURATION * 2.0F) {
|
|
||||||
items_color_timer_ = 0.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alternar color cada ITEMS_COLOR_BLINK_DURATION
|
|
||||||
if (items_color_timer_ < ITEMS_COLOR_BLINK_DURATION) {
|
|
||||||
items_color_ = stringToColor("white");
|
items_color_ = stringToColor("white");
|
||||||
} else {
|
|
||||||
items_color_ = stringToColor("magenta");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la cantidad de minutos de juego transcurridos
|
// Devuelve la cantidad de minutos de juego transcurridos
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class Scoreboard {
|
|||||||
bool music{true}; // Indica si ha de sonar la música durante el juego
|
bool music{true}; // Indica si ha de sonar la música durante el juego
|
||||||
Uint8 color{0}; // Color para escribir el texto del marcador
|
Uint8 color{0}; // Color para escribir el texto del marcador
|
||||||
Uint32 ini_clock{0}; // Tiempo inicial para calcular el tiempo transcurrido
|
Uint32 ini_clock{0}; // Tiempo inicial para calcular el tiempo transcurrido
|
||||||
bool jail_is_open{false}; // Indica si se puede entrar a la Jail
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Métodos públicos
|
// Métodos públicos
|
||||||
|
|||||||
@@ -38,12 +38,10 @@ struct Cheat {
|
|||||||
|
|
||||||
State infinite_lives{Defaults::Cheat::INFINITE_LIVES ? State::ENABLED : State::DISABLED}; // Indica si el jugador dispone de vidas infinitas
|
State infinite_lives{Defaults::Cheat::INFINITE_LIVES ? State::ENABLED : State::DISABLED}; // Indica si el jugador dispone de vidas infinitas
|
||||||
State invincible{Defaults::Cheat::INVINCIBLE ? State::ENABLED : State::DISABLED}; // Indica si el jugador puede morir
|
State invincible{Defaults::Cheat::INVINCIBLE ? State::ENABLED : State::DISABLED}; // Indica si el jugador puede morir
|
||||||
State jail_is_open{Defaults::Cheat::JAIL_IS_OPEN ? State::ENABLED : State::DISABLED}; // Indica si la Jail está abierta
|
|
||||||
State alternate_skin{Defaults::Cheat::ALTERNATE_SKIN ? State::ENABLED : State::DISABLED}; // Indica si se usa una skin diferente para el jugador
|
|
||||||
|
|
||||||
// Método para comprobar si alguno de los tres primeros trucos está activo
|
// Método para comprobar si alguno de los trucos está activo
|
||||||
[[nodiscard]] auto enabled() const -> bool {
|
[[nodiscard]] auto enabled() const -> bool {
|
||||||
return infinite_lives == State::ENABLED || invincible == State::ENABLED || jail_is_open == State::ENABLED;
|
return infinite_lives == State::ENABLED || invincible == State::ENABLED;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,16 +33,16 @@
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(Mode mode)
|
Game::Game(Mode mode)
|
||||||
: scoreboard_data_(std::make_shared<Scoreboard::Data>(0, 9, 0, true, 0, SDL_GetTicks(), Options::cheats.jail_is_open == Options::Cheat::State::ENABLED)),
|
: scoreboard_data_(std::make_shared<Scoreboard::Data>(0, 9, 0, true, 0, SDL_GetTicks())),
|
||||||
scoreboard_(std::make_shared<Scoreboard>(scoreboard_data_)),
|
scoreboard_(std::make_shared<Scoreboard>(scoreboard_data_)),
|
||||||
room_tracker_(std::make_shared<RoomTracker>()),
|
room_tracker_(std::make_shared<RoomTracker>()),
|
||||||
mode_(mode),
|
mode_(mode),
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
current_room_("03.yaml"),
|
current_room_("03.yaml"),
|
||||||
spawn_data_(Player::SpawnData(25 * Tile::SIZE, 21 * Tile::SIZE, 0, 0, 0, Player::State::ON_GROUND, Flip::LEFT))
|
spawn_data_(Player::SpawnData(25 * Tile::SIZE, PlayArea::BOTTOM - Player::HEIGHT - Tile::SIZE, 0, 0, 0, Player::State::ON_GROUND, Flip::LEFT))
|
||||||
#else
|
#else
|
||||||
current_room_("03.yaml"),
|
current_room_("03.yaml"),
|
||||||
spawn_data_(Player::SpawnData(25 * Tile::SIZE, 13 * Tile::SIZE, 0, 0, 0, Player::State::ON_GROUND, Flip::LEFT))
|
spawn_data_(Player::SpawnData(25 * Tile::SIZE, PlayArea::BOTTOM - Player::HEIGHT - Tile::SIZE, 0, 0, 0, Player::State::ON_GROUND, Flip::LEFT))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Crea objetos e inicializa variables
|
// Crea objetos e inicializa variables
|
||||||
@@ -52,7 +52,6 @@ Game::Game(Mode mode)
|
|||||||
initPlayer(spawn_data_, room_);
|
initPlayer(spawn_data_, room_);
|
||||||
total_items_ = getTotalItems();
|
total_items_ = getTotalItems();
|
||||||
|
|
||||||
createRoomNameTexture();
|
|
||||||
game_backbuffer_surface_ = std::make_shared<Surface>(Options::game.width, Options::game.height);
|
game_backbuffer_surface_ = std::make_shared<Surface>(Options::game.width, Options::game.height);
|
||||||
changeRoom(current_room_);
|
changeRoom(current_room_);
|
||||||
|
|
||||||
@@ -173,12 +172,11 @@ void Game::updatePlaying(float delta_time) {
|
|||||||
#else
|
#else
|
||||||
player_->update(delta_time);
|
player_->update(delta_time);
|
||||||
#endif
|
#endif
|
||||||
checkPlayerIsOnBorder();
|
handlePlayerIsOnBorder();
|
||||||
checkPlayerAndItems();
|
handlePlayerAndItemsCollisions();
|
||||||
checkPlayerAndEnemies();
|
handlePlayerAndEnemiesCollisions();
|
||||||
checkIfPlayerIsAlive();
|
player_->handleKillingTiles();
|
||||||
checkEndGame();
|
handleIfPlayerIsAlive();
|
||||||
checkRestoringJail(delta_time);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Mode::DEMO:
|
case Mode::DEMO:
|
||||||
@@ -303,7 +301,6 @@ void Game::renderPlaying() {
|
|||||||
if (mode_ == Mode::GAME) {
|
if (mode_ == Mode::GAME) {
|
||||||
player_->render();
|
player_->render();
|
||||||
}
|
}
|
||||||
renderRoomName();
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (!Debug::get()->isEnabled()) {
|
if (!Debug::get()->isEnabled()) {
|
||||||
scoreboard_->render();
|
scoreboard_->render();
|
||||||
@@ -348,7 +345,6 @@ void Game::renderFadeToEnding() {
|
|||||||
room_->renderEnemies();
|
room_->renderEnemies();
|
||||||
room_->renderItems();
|
room_->renderItems();
|
||||||
player_->render(); // Player congelado pero visible
|
player_->render(); // Player congelado pero visible
|
||||||
renderRoomName();
|
|
||||||
scoreboard_->render();
|
scoreboard_->render();
|
||||||
|
|
||||||
// 4. Restaurar renderer original
|
// 4. Restaurar renderer original
|
||||||
@@ -422,6 +418,11 @@ void Game::handleDebugEvents(const SDL_Event& event) {
|
|||||||
Resource::Cache::get()->reload();
|
Resource::Cache::get()->reload();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SDLK_P:
|
||||||
|
player_->reloadPhysics();
|
||||||
|
Notifier::get()->show({"PHYSICS RELOADED"});
|
||||||
|
break;
|
||||||
|
|
||||||
case SDLK_W:
|
case SDLK_W:
|
||||||
changeRoom(room_->getRoom(Room::Border::TOP));
|
changeRoom(room_->getRoom(Room::Border::TOP));
|
||||||
break;
|
break;
|
||||||
@@ -450,11 +451,6 @@ void Game::handleDebugEvents(const SDL_Event& event) {
|
|||||||
player_->setColor();
|
player_->setColor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_3:
|
|
||||||
Options::cheats.jail_is_open = Options::cheats.jail_is_open == Options::Cheat::State::ENABLED ? Options::Cheat::State::DISABLED : Options::Cheat::State::ENABLED;
|
|
||||||
Notifier::get()->show({std::string("JAIL IS OPEN ") + (Options::cheats.jail_is_open == Options::Cheat::State::ENABLED ? "ENABLED" : "DISABLED")}, Notifier::Style::DEFAULT, -1, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_0:
|
case SDLK_0:
|
||||||
Screen::get()->toggleDebugInfo();
|
Screen::get()->toggleDebugInfo();
|
||||||
break;
|
break;
|
||||||
@@ -539,12 +535,6 @@ void Game::handleDebugMouseDrag(float delta_time) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Escribe el nombre de la pantalla
|
|
||||||
void Game::renderRoomName() {
|
|
||||||
// Dibuja la textura con el nombre de la habitación
|
|
||||||
room_name_surface_->render(nullptr, &room_name_rect_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
auto Game::changeRoom(const std::string& room_path) -> bool {
|
auto Game::changeRoom(const std::string& room_path) -> bool {
|
||||||
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
|
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
|
||||||
@@ -557,9 +547,6 @@ auto Game::changeRoom(const std::string& room_path) -> bool {
|
|||||||
// Crea un objeto habitación nuevo a partir del fichero
|
// Crea un objeto habitación nuevo a partir del fichero
|
||||||
room_ = std::make_shared<Room>(room_path, scoreboard_data_);
|
room_ = std::make_shared<Room>(room_path, scoreboard_data_);
|
||||||
|
|
||||||
// Pone el nombre de la habitación en la textura
|
|
||||||
fillRoomNameTexture();
|
|
||||||
|
|
||||||
// Pone el color del marcador en función del color del borde de la habitación
|
// Pone el color del marcador en función del color del borde de la habitación
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
|
|
||||||
@@ -581,7 +568,7 @@ auto Game::changeRoom(const std::string& room_path) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si el jugador esta en el borde de la pantalla
|
// Comprueba si el jugador esta en el borde de la pantalla
|
||||||
void Game::checkPlayerIsOnBorder() {
|
void Game::handlePlayerIsOnBorder() {
|
||||||
if (player_->isOnBorder()) {
|
if (player_->isOnBorder()) {
|
||||||
const auto BORDER = player_->getBorder();
|
const auto BORDER = player_->getBorder();
|
||||||
const auto ROOM_NAME = room_->getRoom(BORDER);
|
const auto ROOM_NAME = room_->getRoom(BORDER);
|
||||||
@@ -602,7 +589,7 @@ void Game::checkPlayerIsOnBorder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las colisiones del jugador con los enemigos
|
// Comprueba las colisiones del jugador con los enemigos
|
||||||
auto Game::checkPlayerAndEnemies() -> bool {
|
auto Game::handlePlayerAndEnemiesCollisions() -> bool {
|
||||||
const bool DEATH = room_->enemyCollision(player_->getCollider());
|
const bool DEATH = room_->enemyCollision(player_->getCollider());
|
||||||
if (DEATH) {
|
if (DEATH) {
|
||||||
killPlayer();
|
killPlayer();
|
||||||
@@ -611,12 +598,12 @@ auto Game::checkPlayerAndEnemies() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las colisiones del jugador con los objetos
|
// Comprueba las colisiones del jugador con los objetos
|
||||||
void Game::checkPlayerAndItems() {
|
void Game::handlePlayerAndItemsCollisions() {
|
||||||
room_->itemCollision(player_->getCollider());
|
room_->itemCollision(player_->getCollider());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si el jugador esta vivo
|
// Comprueba si el jugador esta vivo
|
||||||
void Game::checkIfPlayerIsAlive() {
|
void Game::handleIfPlayerIsAlive() {
|
||||||
if (!player_->isAlive()) {
|
if (!player_->isAlive()) {
|
||||||
killPlayer();
|
killPlayer();
|
||||||
}
|
}
|
||||||
@@ -651,24 +638,6 @@ void Game::setScoreBoardColor() {
|
|||||||
scoreboard_data_->color = IS_BLACK ? Color::index(Color::Cpc::WHITE) : BORDER_COLOR;
|
scoreboard_data_->color = IS_BLACK ? Color::index(Color::Cpc::WHITE) : BORDER_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si ha finalizado el juego
|
|
||||||
auto Game::checkEndGame() -> bool {
|
|
||||||
const bool IS_ON_THE_ROOM = room_->getName() == "THE JAIL"; // Estar en la habitación que toca
|
|
||||||
const bool HAVE_THE_ITEMS = scoreboard_data_->items >= int(total_items_ * 0.9F) || Options::cheats.jail_is_open == Options::Cheat::State::ENABLED; // Con mas del 90% de los items recogidos
|
|
||||||
const bool IS_ON_THE_DOOR = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
|
||||||
|
|
||||||
scoreboard_data_->jail_is_open = HAVE_THE_ITEMS;
|
|
||||||
|
|
||||||
if (HAVE_THE_ITEMS && IS_ON_THE_ROOM && IS_ON_THE_DOOR) {
|
|
||||||
// Iniciar transición de fade en vez de cambio inmediato de escena
|
|
||||||
transitionToState(State::FADE_TO_ENDING);
|
|
||||||
Audio::get()->fadeOutMusic(Defaults::Music::FADE_DURATION_MS); // Fade out de música
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene la cantidad total de items que hay en el mapeado del juego
|
// Obtiene la cantidad total de items que hay en el mapeado del juego
|
||||||
auto Game::getTotalItems() -> int {
|
auto Game::getTotalItems() -> int {
|
||||||
int items = 0;
|
int items = 0;
|
||||||
@@ -690,58 +659,12 @@ void Game::togglePause() {
|
|||||||
scoreboard_->setPaused(paused_);
|
scoreboard_->setPaused(paused_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Da vidas al jugador cuando está en la Jail
|
|
||||||
void Game::checkRestoringJail(float delta_time) {
|
|
||||||
if (room_->getName() != "THE JAIL" || scoreboard_data_->lives == 9) {
|
|
||||||
jail_restore_time_ = 0.0F; // Reset timer cuando no está en la Jail
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!paused_) {
|
|
||||||
jail_restore_time_ += delta_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Incrementa el numero de vidas
|
|
||||||
if (jail_restore_time_ >= JAIL_RESTORE_INTERVAL) {
|
|
||||||
jail_restore_time_ -= JAIL_RESTORE_INTERVAL; // Mantiene el excedente para precisión
|
|
||||||
scoreboard_data_->lives++;
|
|
||||||
Audio::get()->playSound(Defaults::Sound::HIT, Audio::Group::GAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Crea la textura con el nombre de la habitación
|
|
||||||
void Game::fillRoomNameTexture() {
|
|
||||||
// Pone la textura como destino de renderizado
|
|
||||||
auto previuos_renderer = Screen::get()->getRendererSurface();
|
|
||||||
Screen::get()->setRendererSurface(room_name_surface_);
|
|
||||||
|
|
||||||
// Rellena la textura de color
|
|
||||||
room_name_surface_->clear(stringToColor("white"));
|
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
|
||||||
auto text = Resource::Cache::get()->getText("smb2");
|
|
||||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, text->getCharacterSize() / 2, room_->getName(), 1, room_->getBGColor());
|
|
||||||
|
|
||||||
// Deja el renderizador por defecto
|
|
||||||
Screen::get()->setRendererSurface(previuos_renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializa al jugador
|
// Inicializa al jugador
|
||||||
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) {
|
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) {
|
||||||
std::string player_animations = Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.yaml" : "player.yaml";
|
const Player::Data PLAYER{.spawn_data = spawn_point, .animations_path = "player_animations.yaml", .room = std::move(room)};
|
||||||
const Player::Data PLAYER{.spawn_data = spawn_point, .animations_path = player_animations, .room = std::move(room)};
|
|
||||||
player_ = std::make_shared<Player>(PLAYER);
|
player_ = std::make_shared<Player>(PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea la textura para poner el nombre de la habitación
|
|
||||||
void Game::createRoomNameTexture() {
|
|
||||||
auto text = Resource::Cache::get()->getText("smb2");
|
|
||||||
room_name_surface_ = std::make_shared<Surface>(Options::game.width, text->getCharacterSize() * 2);
|
|
||||||
|
|
||||||
// Establece el destino de la textura
|
|
||||||
room_name_rect_ = {.x = 0.0F, .y = PlayArea::HEIGHT, .w = Options::game.width, .h = text->getCharacterSize() * 2.0F};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hace sonar la música
|
// Hace sonar la música
|
||||||
void Game::keepMusicPlaying() {
|
void Game::keepMusicPlaying() {
|
||||||
const std::string MUSIC_PATH = mode_ == Mode::GAME ? Defaults::Music::GAME_TRACK : Defaults::Music::TITLE_TRACK;
|
const std::string MUSIC_PATH = mode_ == Mode::GAME ? Defaults::Music::GAME_TRACK : Defaults::Music::TITLE_TRACK;
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class Game {
|
|||||||
static constexpr float BLACK_SCREEN_DURATION = 0.30F; // Duración de la pantalla negra en segundos (20 frames a 66.67fps)
|
static constexpr float BLACK_SCREEN_DURATION = 0.30F; // Duración de la pantalla negra en segundos (20 frames a 66.67fps)
|
||||||
static constexpr float GAME_OVER_THRESHOLD = 0.255F; // Tiempo antes del game over en segundos (17 frames a 66.67fps)
|
static constexpr float GAME_OVER_THRESHOLD = 0.255F; // Tiempo antes del game over en segundos (17 frames a 66.67fps)
|
||||||
static constexpr float DEMO_ROOM_DURATION = 6.0F; // Duración de cada habitación en modo demo en segundos (400 frames)
|
static constexpr float DEMO_ROOM_DURATION = 6.0F; // Duración de cada habitación en modo demo en segundos (400 frames)
|
||||||
static constexpr float JAIL_RESTORE_INTERVAL = 1.5F; // Intervalo de restauración de vidas en la Jail en segundos (100 frames)
|
|
||||||
static constexpr float FADE_STEP_INTERVAL = 0.05F; // Intervalo entre pasos de fade en segundos
|
static constexpr float FADE_STEP_INTERVAL = 0.05F; // Intervalo entre pasos de fade en segundos
|
||||||
static constexpr float POST_FADE_DELAY = 2.0F; // Duración de la pantalla negra después del fade
|
static constexpr float POST_FADE_DELAY = 2.0F; // Duración de la pantalla negra después del fade
|
||||||
|
|
||||||
@@ -57,7 +56,6 @@ class Game {
|
|||||||
void update(); // Actualiza el juego, las variables, comprueba la entrada, etc.
|
void update(); // Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void render(); // Pinta los objetos en pantalla
|
void render(); // Pinta los objetos en pantalla
|
||||||
void handleEvents(); // Comprueba los eventos de la cola
|
void handleEvents(); // Comprueba los eventos de la cola
|
||||||
void renderRoomName(); // Escribe el nombre de la pantalla
|
|
||||||
void transitionToState(State new_state); // Cambia al estado especificado y resetea los timers
|
void transitionToState(State new_state); // Cambia al estado especificado y resetea los timers
|
||||||
void updatePlaying(float delta_time); // Actualiza el juego en estado PLAYING
|
void updatePlaying(float delta_time); // Actualiza el juego en estado PLAYING
|
||||||
void updateBlackScreen(float delta_time); // Actualiza el juego en estado BLACK_SCREEN
|
void updateBlackScreen(float delta_time); // Actualiza el juego en estado BLACK_SCREEN
|
||||||
@@ -71,21 +69,17 @@ class Game {
|
|||||||
void renderPostFadeEnding(); // Renderiza el juego en estado POST_FADE_ENDING (pantalla negra)
|
void renderPostFadeEnding(); // Renderiza el juego en estado POST_FADE_ENDING (pantalla negra)
|
||||||
auto changeRoom(const std::string& room_path) -> bool; // Cambia de habitación
|
auto changeRoom(const std::string& room_path) -> bool; // Cambia de habitación
|
||||||
void handleInput(); // Comprueba el teclado
|
void handleInput(); // Comprueba el teclado
|
||||||
void checkPlayerIsOnBorder(); // Comprueba si el jugador esta en el borde de la pantalla y actua
|
void handlePlayerIsOnBorder(); // Comprueba si el jugador esta en el borde de la pantalla y actua
|
||||||
auto checkPlayerAndEnemies() -> bool; // Comprueba las colisiones del jugador con los enemigos
|
auto handlePlayerAndEnemiesCollisions() -> bool; // Comprueba las colisiones del jugador con los enemigos
|
||||||
void checkPlayerAndItems(); // Comprueba las colisiones del jugador con los objetos
|
void handlePlayerAndItemsCollisions(); // Comprueba las colisiones del jugador con los objetos
|
||||||
void checkIfPlayerIsAlive(); // Comprueba si el jugador esta vivo
|
void handleIfPlayerIsAlive(); // Comprueba si el jugador esta vivo
|
||||||
void killPlayer(); // Mata al jugador
|
void killPlayer(); // Mata al jugador
|
||||||
void setScoreBoardColor(); // Pone el color del marcador en función del color del borde de la habitación
|
void setScoreBoardColor(); // Pone el color del marcador en función del color del borde de la habitación
|
||||||
auto checkEndGame() -> bool; // Comprueba si ha finalizado el juego
|
|
||||||
static auto getTotalItems() -> int; // Obtiene la cantidad total de items que hay en el mapeado del juego
|
static auto getTotalItems() -> int; // Obtiene la cantidad total de items que hay en el mapeado del juego
|
||||||
void togglePause(); // Pone el juego en pausa
|
void togglePause(); // Pone el juego en pausa
|
||||||
void checkRestoringJail(float delta_time); // Da vidas al jugador cuando está en la Jail
|
|
||||||
void fillRoomNameTexture(); // Pone el nombre de la habitación en la textura
|
|
||||||
void checkSomeCheevos(); // Comprueba algunos logros
|
void checkSomeCheevos(); // Comprueba algunos logros
|
||||||
void checkEndGameCheevos(); // Comprueba los logros de completar el juego
|
void checkEndGameCheevos(); // Comprueba los logros de completar el juego
|
||||||
void initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room); // Inicializa al jugador
|
void initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room); // Inicializa al jugador
|
||||||
void createRoomNameTexture(); // Crea la textura para poner el nombre de la habitación
|
|
||||||
void keepMusicPlaying(); // Hace sonar la música
|
void keepMusicPlaying(); // Hace sonar la música
|
||||||
void demoInit(); // DEMO MODE: Inicializa las variables para el modo demo
|
void demoInit(); // DEMO MODE: Inicializa las variables para el modo demo
|
||||||
void demoCheckRoomChange(float delta_time); // DEMO MODE: Comprueba si se ha de cambiar de habitación
|
void demoCheckRoomChange(float delta_time); // DEMO MODE: Comprueba si se ha de cambiar de habitación
|
||||||
@@ -103,7 +97,6 @@ class Game {
|
|||||||
std::shared_ptr<RoomTracker> room_tracker_; // Lleva el control de las habitaciones visitadas
|
std::shared_ptr<RoomTracker> room_tracker_; // Lleva el control de las habitaciones visitadas
|
||||||
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
||||||
std::shared_ptr<Player> player_; // Objeto con el jugador
|
std::shared_ptr<Player> player_; // Objeto con el jugador
|
||||||
std::shared_ptr<Surface> room_name_surface_; // Textura para escribir el nombre de la habitación
|
|
||||||
std::shared_ptr<Surface> game_backbuffer_surface_; // Backbuffer para efectos de fade
|
std::shared_ptr<Surface> game_backbuffer_surface_; // Backbuffer para efectos de fade
|
||||||
|
|
||||||
// Variables de estado del juego
|
// Variables de estado del juego
|
||||||
@@ -120,10 +113,6 @@ class Game {
|
|||||||
// Variables de demo mode
|
// Variables de demo mode
|
||||||
DemoData demo_; // Variables para el modo demo
|
DemoData demo_; // Variables para el modo demo
|
||||||
|
|
||||||
// Variables de efectos visuales
|
|
||||||
SDL_FRect room_name_rect_; // Rectangulo donde pintar la textura con el nombre de la habitación
|
|
||||||
float jail_restore_time_{0.0F}; // Tiempo acumulado para restauración de vidas en la Jail
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Variables de debug para arrastre con ratón
|
// Variables de debug para arrastre con ratón
|
||||||
bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el ratón
|
bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el ratón
|
||||||
|
|||||||
Reference in New Issue
Block a user