reestructuració

This commit is contained in:
2026-04-17 17:15:38 +02:00
parent 55caef3210
commit 5fec0110b3
66 changed files with 221 additions and 217 deletions

View File

@@ -4,67 +4,67 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview ## Project Overview
Coffee Crisis is a C++20 arcade game built with SDL2. The player controls a character defending the UPV (university) from bouncing coffee-ball enemies across 10 stages. Supports 1-2 players, keyboard and gamepad input, and multiple languages (Spanish, Basque, English). Coffee Crisis is a C++20 arcade game built with SDL3. The player controls a character defending the UPV (university) from bouncing coffee-ball enemies across 10 stages. Supports 1-2 players, keyboard and gamepad input, and multiple languages (Spanish, Basque, English).
## Build Commands ## Build Commands
Dependencies: `libsdl2-dev` and `g++` (Linux) or `clang++` (macOS). Dependencies: `libsdl3-dev` and `g++` (Linux) or `clang++` (macOS). Build system is CMake (driven by `Makefile` wrappers).
```bash ```bash
# Linux make # Release build
make linux # Release build → ./coffee_crisis make debug # Debug build (defines DEBUG and PAUSE)
make linux_debug # Debug build (defines DEBUG and PAUSE) → ./coffee_crisis_debug make release # Empaqueta .tar.gz / .dmg / .zip segons SO
make pack # Regenera resources.pack
# macOS make controllerdb # Descarga gamecontrollerdb.txt
make macos # Release build with clang++ make format # clang-format -i
make macos_debug # Debug build make tidy # clang-tidy
make cppcheck # cppcheck
# Windows (MinGW)
make windows # Release build → coffee_crisis.exe
make windows_debug # Debug build
# Release packaging
make linux_release # Builds and creates .tar.gz
make macos_release # Builds Intel + Apple Silicon .dmg files
make windows_release # Builds and creates .zip
``` ```
There is also a CMakeLists.txt available as an alternative build system.
There are no tests or linter configured.
## Architecture ## Architecture
All source code is in `source/`. The game uses a section-based architecture controlled by the **Director** class: Source layout (alineat amb la resta de projectes germans):
- **Director** (`director.h/cpp`): Top-level controller. Initializes SDL, manages the window/renderer, and runs sections in sequence: Logo → Intro → Title → Game → Quit. Owns all shared objects (Screen, Input, Lang, Asset). ```
- **Game** (`game.h/cpp`): Core gameplay logic. Manages players, balloons (enemies), bullets, items, stages, menace level, and collision detection. Contains its own update/render loop plus sub-loops for pause and game over screens. source/
- **Screen** (`screen.h/cpp`): Rendering abstraction. Manages a virtual canvas (256×192) that gets scaled to the actual window. Handles fullscreen/windowed modes, border rendering, and fade effects. ├── main.cpp
- **Input** (`input.h/cpp`): Abstracts keyboard and gamepad input. ├── core/
- **Asset** (`asset.h/cpp`): Resource file index. Files are registered with `add()` and retrieved by name with `get()`. All paths are relative to the executable. │ ├── audio/ jail_audio.hpp
- **Lang** (`lang.h/cpp`): i18n system loading text strings from files in `data/lang/`. │ ├── input/ input.*, mouse.*
│ ├── locale/ lang.*
│ ├── rendering/ screen, fade, text, writer, texture, sprite + animated/moving/smart
│ ├── resources/ asset, resource, resource_pack, resource_loader, resource_helper
│ └── system/ director
├── game/
│ ├── defaults.hpp (constants de gameplay: block size, canvas, áreas, colors)
│ ├── game.* (hub de gameplay)
│ ├── entities/ player, balloon, bullet, item
│ ├── scenes/ logo, intro, title, instructions
│ └── ui/ menu
├── utils/
│ ├── defines.hpp (macros de build)
│ └── utils.* (helpers, enum de dificultat, circle_t, ...)
└── external/ (stb_image, stb_vorbis — protegits amb dummies `.clang-*`)
```
### Sprite hierarchy Flux general controlat per la classe **Director** (`core/system/director.h`): inicialitza SDL, finestra/renderer i executa seccions en seqüència **Logo → Intro → Title → Game → Quit**. Les classes principals:
- **Sprite** → base class for drawing from a PNG spritesheet - **Game** (`game/game.h`): gameplay nuclear. Gestiona jugadors, balloons, bullets, items, stages, nivell d'amenaça i col·lisions. Té el seu bucle d'update/render i sub-bucles per pausa i game-over.
- **AnimatedSprite** → extends Sprite with frame-based animation (loaded from `.ani` files) - **Screen** (`core/rendering/screen.h`): abstracció de render. Canvas virtual 256×192 escalat a la finestra. Fullscreen/windowed, borders, fades.
- **MovingSprite** → sprite with movement - **Input** (`core/input/input.h`): abstracció de teclat i gamepad.
- **SmartSprite** → sprite with autonomous behavior (score popups, thrown items) - **Asset** (`core/resources/asset.h`): índex de fitxers de recurs (`add`/`get` per nom).
- **Lang** (`core/locale/lang.h`): i18n, carrega strings des de `data/lang/`.
### Game entities ### Sprite hierarchy (`core/rendering/`)
- **Player** (`player.h/cpp`): Player character state and rendering - **Sprite** → base per dibuixar des d'un spritesheet PNG
- **Balloon** (`balloon.h/cpp`): Enemy entities with multiple types and split-on-pop behavior - **AnimatedSprite** → afegeix animació per frames (arxius `.ani`)
- **Bullet** (`bullet.h/cpp`): Projectiles fired by the player (left/center/right) - **MovingSprite** → sprite amb posició/velocitat
- **Item** (`item.h/cpp`): Collectible items (points, clock, coffee, power-ups) - **SmartSprite** → sprite autònom (score popups, objectes llençats)
### Audio ### Audio
**jail_audio** (`jail_audio.h/cpp`): Custom audio library wrapping SDL2 audio. Uses stb_vorbis for OGG decoding. Provides `JA_*` functions for music and sound effects with channel-based mixing. **jail_audio** (`core/audio/jail_audio.hpp`): wrapper audio SDL3 first-party. Usa stb_vorbis per OGG. API `JA_*` per música i efectes amb mesclat per canals.
### Key constants
Defined in `const.h`: block size (8px), virtual canvas (256×192), play area bounds, section/subsection IDs, and color definitions.
## Data Directory ## Data Directory

View File

@@ -26,8 +26,9 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -ffunction-sections
# Define el directorio de los archivos fuente # Define el directorio de los archivos fuente
set(DIR_SOURCES "${CMAKE_SOURCE_DIR}/source") set(DIR_SOURCES "${CMAKE_SOURCE_DIR}/source")
# Cargar todos los archivos fuente en DIR_SOURCES # Cargar todos los archivos fuente en DIR_SOURCES (recursivo, sin external/)
file(GLOB SOURCES "${DIR_SOURCES}/*.cpp") file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "${DIR_SOURCES}/*.cpp")
list(FILTER SOURCES EXCLUDE REGEX "${DIR_SOURCES}/external/.*")
# Verificar si se encontraron archivos fuente # Verificar si se encontraron archivos fuente
if(NOT SOURCES) if(NOT SOURCES)
@@ -57,6 +58,9 @@ endif()
# Añadir ejecutable principal # Añadir ejecutable principal
add_executable(${PROJECT_NAME} ${SOURCES}) add_executable(${PROJECT_NAME} ${SOURCES})
# Includes relatius a source/ (p.e. `#include "core/rendering/texture.h"`)
target_include_directories(${PROJECT_NAME} PRIVATE ${DIR_SOURCES})
# Configuración de salida: el ejecutable principal va a la raíz del proyecto. # Configuración de salida: el ejecutable principal va a la raíz del proyecto.
# Per-target (no global) perquè `pack_resources` acabe a `build/` com la resta # Per-target (no global) perquè `pack_resources` acabe a `build/` com la resta
# de projectes. # de projectes.
@@ -204,7 +208,7 @@ endif()
if(NOT EMSCRIPTEN) if(NOT EMSCRIPTEN)
add_executable(pack_resources EXCLUDE_FROM_ALL add_executable(pack_resources EXCLUDE_FROM_ALL
tools/pack_resources/pack_resources.cpp tools/pack_resources/pack_resources.cpp
source/resource_pack.cpp source/core/resources/resource_pack.cpp
) )
target_include_directories(pack_resources PRIVATE "${CMAKE_SOURCE_DIR}/source") target_include_directories(pack_resources PRIVATE "${CMAKE_SOURCE_DIR}/source")
target_compile_options(pack_resources PRIVATE -Wall) target_compile_options(pack_resources PRIVATE -Wall)

View File

@@ -19,9 +19,9 @@ RESOURCE_FILE := release/windows/coffee.res
# VERSION (extracted from defines.hpp) # VERSION (extracted from defines.hpp)
# ============================================================================== # ==============================================================================
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
VERSION := $(shell powershell -Command "(Select-String -Path 'source/defines.hpp' -Pattern 'constexpr const char\* VERSION = \"(.+?)\"').Matches.Groups[1].Value") VERSION := $(shell powershell -Command "(Select-String -Path 'source/utils/defines.hpp' -Pattern 'constexpr const char\* VERSION = \"(.+?)\"').Matches.Groups[1].Value")
else else
VERSION := $(shell grep 'constexpr const char\* VERSION' source/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/') VERSION := $(shell grep 'constexpr const char\* VERSION' source/utils/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/')
endif endif
# ============================================================================== # ==============================================================================

View File

@@ -1,4 +1,4 @@
#include "input.h" #include "core/input/input.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>

View File

@@ -1,4 +1,4 @@
#include "mouse.hpp" #include "core/input/mouse.hpp"
namespace Mouse { namespace Mouse {
Uint32 cursorHideTime = 3000; // Tiempo en milisegundos para ocultar el cursor por inactividad Uint32 cursorHideTime = 3000; // Tiempo en milisegundos para ocultar el cursor por inactividad

View File

@@ -1,10 +1,10 @@
#include "lang.h" #include "core/locale/lang.h"
#include <fstream> // for basic_ifstream, basic_istream, ifstream #include <fstream> // for basic_ifstream, basic_istream, ifstream
#include <sstream> #include <sstream>
#include "asset.h" // for Asset #include "core/resources/asset.h" // for Asset
#include "resource_helper.h" #include "core/resources/resource_helper.h"
// Constructor // Constructor
Lang::Lang(Asset *mAsset) { Lang::Lang(Asset *mAsset) {

View File

@@ -1,10 +1,10 @@
#include "animatedsprite.h" #include "core/rendering/animatedsprite.h"
#include <fstream> // for basic_ostream, operator<<, basic_istream, basic... #include <fstream> // for basic_ostream, operator<<, basic_istream, basic...
#include <iostream> // for cout #include <iostream> // for cout
#include <sstream> // for basic_stringstream #include <sstream> // for basic_stringstream
#include "texture.h" // for Texture #include "core/rendering/texture.h" // for Texture
// Parser compartido: lee un istream con el formato .ani // Parser compartido: lee un istream con el formato .ani
static animatedSprite_t parseAnimationStream(std::istream &file, Texture *texture, const std::string &filename, bool verbose) { static animatedSprite_t parseAnimationStream(std::istream &file, Texture *texture, const std::string &filename, bool verbose) {

View File

@@ -6,7 +6,7 @@
#include <string> // for string, basic_string #include <string> // for string, basic_string
#include <vector> // for vector #include <vector> // for vector
#include "movingsprite.h" // for MovingSprite #include "core/rendering/movingsprite.h" // for MovingSprite
class Texture; class Texture;
struct animation_t { struct animation_t {

View File

@@ -1,11 +1,11 @@
#include "fade.h" #include "core/rendering/fade.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <stdlib.h> // for rand #include <stdlib.h> // for rand
#include <iostream> // for char_traits, basic_ostream, operator<< #include <iostream> // for char_traits, basic_ostream, operator<<
#include "const.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH #include "game/defaults.hpp" // for GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH
// Constructor // Constructor
Fade::Fade(SDL_Renderer *renderer) { Fade::Fade(SDL_Renderer *renderer) {

View File

@@ -1,6 +1,6 @@
#include "movingsprite.h" #include "core/rendering/movingsprite.h"
#include "texture.h" // for Texture #include "core/rendering/texture.h" // for Texture
// Constructor // Constructor
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, Texture *texture, SDL_Renderer *renderer) { MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, Texture *texture, SDL_Renderer *renderer) {

View File

@@ -2,7 +2,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include "sprite.h" // for Sprite #include "core/rendering/sprite.h" // for Sprite
class Texture; class Texture;
// Clase MovingSprite. Añade posicion y velocidad en punto flotante // Clase MovingSprite. Añade posicion y velocidad en punto flotante

View File

@@ -1,4 +1,4 @@
#include "screen.h" #include "core/rendering/screen.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -6,10 +6,10 @@
#include <iostream> // for basic_ostream, operator<<, cout, endl #include <iostream> // for basic_ostream, operator<<, cout, endl
#include <string> // for basic_string, char_traits, string #include <string> // for basic_string, char_traits, string
#include "asset.h" // for Asset #include "core/input/mouse.hpp" // for Mouse::cursorVisible, Mouse::lastMouseMoveTime
#include "mouse.hpp" // for Mouse::cursorVisible, Mouse::lastMouseMoveTime #include "core/rendering/text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_STROKE
#include "resource.h" #include "core/resources/asset.h" // for Asset
#include "text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_STROKE #include "core/resources/resource.h"
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#include <emscripten.h> #include <emscripten.h>

View File

@@ -4,7 +4,7 @@
#include <string> // for string #include <string> // for string
#include "utils.h" // for color_t #include "utils/utils.h" // for color_t
class Asset; class Asset;
class Text; class Text;

View File

@@ -1,6 +1,6 @@
#include "smartsprite.h" #include "core/rendering/smartsprite.h"
#include "movingsprite.h" // for MovingSprite #include "core/rendering/movingsprite.h" // for MovingSprite
class Texture; class Texture;
// Constructor // Constructor

View File

@@ -2,7 +2,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include "animatedsprite.h" // for AnimatedSprite #include "core/rendering/animatedsprite.h" // for AnimatedSprite
class Texture; class Texture;
// Clase SmartSprite // Clase SmartSprite

View File

@@ -1,6 +1,6 @@
#include "sprite.h" #include "core/rendering/sprite.h"
#include "texture.h" // for Texture #include "core/rendering/texture.h" // for Texture
// Constructor // Constructor
Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *renderer) { Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *renderer) {

View File

@@ -1,13 +1,13 @@
#include "text.h" #include "core/rendering/text.h"
#include <fstream> // for char_traits, basic_ostream, basic_ifstream, ope... #include <fstream> // for char_traits, basic_ostream, basic_ifstream, ope...
#include <iostream> // for cout #include <iostream> // for cout
#include <sstream> #include <sstream>
#include "sprite.h" // for Sprite #include "core/rendering/sprite.h" // for Sprite
#include "texture.h" // for Texture #include "core/rendering/texture.h" // for Texture
#include "utils.h" // for color_t #include "utils/utils.h" // for color_t
// Parser compartido: rellena un textFile_t desde cualquier istream // Parser compartido: rellena un textFile_t desde cualquier istream
static void parseTextFileStream(std::istream &rfile, textFile_t &tf) { static void parseTextFileStream(std::istream &rfile, textFile_t &tf) {

View File

@@ -7,7 +7,7 @@
#include <vector> #include <vector>
class Sprite; class Sprite;
class Texture; class Texture;
#include "utils.h" #include "utils/utils.h"
// Opciones de texto // Opciones de texto
constexpr int TXT_COLOR = 1; constexpr int TXT_COLOR = 1;

View File

@@ -1,5 +1,5 @@
#include "texture.h" #include "core/rendering/texture.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <stdlib.h> // for exit #include <stdlib.h> // for exit

View File

@@ -1,6 +1,6 @@
#include "writer.h" #include "core/rendering/writer.h"
#include "text.h" // for Text #include "core/rendering/text.h" // for Text
// Constructor // Constructor
Writer::Writer(Text *text) { Writer::Writer(Text *text) {

View File

@@ -1,11 +1,11 @@
#include "asset.h" #include "core/resources/asset.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <stddef.h> // for size_t #include <stddef.h> // for size_t
#include <iostream> // for basic_ostream, operator<<, cout, endl #include <iostream> // for basic_ostream, operator<<, cout, endl
#include "resource_helper.h" #include "core/resources/resource_helper.h"
// Constructor // Constructor
Asset::Asset(std::string executablePath) { Asset::Asset(std::string executablePath) {

View File

@@ -1,16 +1,16 @@
#include "resource.h" #include "core/resources/resource.h"
#include <algorithm> #include <algorithm>
#include <filesystem> #include <filesystem>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "asset.h" #include "core/audio/jail_audio.hpp"
#include "jail_audio.hpp" #include "core/rendering/text.h"
#include "menu.h" #include "core/rendering/texture.h"
#include "resource_helper.h" #include "core/resources/asset.h"
#include "text.h" #include "core/resources/resource_helper.h"
#include "texture.h" #include "game/ui/menu.h"
Resource *Resource::instance_ = nullptr; Resource *Resource::instance_ = nullptr;

View File

@@ -1,11 +1,11 @@
#include "resource_helper.h" #include "core/resources/resource_helper.h"
#include <algorithm> #include <algorithm>
#include <cstddef> #include <cstddef>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "resource_loader.h" #include "core/resources/resource_loader.h"
namespace ResourceHelper { namespace ResourceHelper {
static bool resource_system_initialized = false; static bool resource_system_initialized = false;

View File

@@ -1,11 +1,11 @@
#include "resource_loader.h" #include "core/resources/resource_loader.h"
#include <algorithm> #include <algorithm>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "resource_pack.h" #include "core/resources/resource_pack.h"
std::unique_ptr<ResourceLoader> ResourceLoader::instance = nullptr; std::unique_ptr<ResourceLoader> ResourceLoader::instance = nullptr;

View File

@@ -1,4 +1,4 @@
#include "resource_pack.h" #include "core/resources/resource_pack.h"
#include <algorithm> #include <algorithm>
#include <array> #include <array>

View File

@@ -1,4 +1,4 @@
#include "director.h" #include "core/system/director.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <errno.h> // for errno, EEXIST, EACCES, ENAMETOO... #include <errno.h> // for errno, EEXIST, EACCES, ENAMETOO...
@@ -17,21 +17,21 @@
#include <string> // for basic_string, operator+, char_t... #include <string> // for basic_string, operator+, char_t...
#include <vector> // for vector #include <vector> // for vector
#include "asset.h" // for Asset, assetType #include "core/audio/jail_audio.hpp" // for JA_Init
#include "const.h" // for SECTION_PROG_LOGO, GAMECANVAS_H... #include "core/input/input.h" // for Input, inputs_e, INPUT_USE_GAME...
#include "game.h" // for Game #include "core/input/mouse.hpp" // for Mouse::handleEvent, Mouse::upda...
#include "input.h" // for Input, inputs_e, INPUT_USE_GAME... #include "core/locale/lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK
#include "intro.h" // for Intro #include "core/rendering/screen.h" // for FILTER_NEAREST, Screen, FILTER_...
#include "jail_audio.hpp" // for JA_Init #include "core/rendering/texture.h" // for Texture
#include "lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK #include "core/resources/asset.h" // for Asset, assetType
#include "logo.h" // for Logo #include "core/resources/resource.h"
#include "mouse.hpp" // for Mouse::handleEvent, Mouse::upda... #include "core/resources/resource_helper.h"
#include "resource.h" #include "game/defaults.hpp" // for SECTION_PROG_LOGO, GAMECANVAS_H...
#include "resource_helper.h" #include "game/game.h" // for Game
#include "screen.h" // for FILTER_NEAREST, Screen, FILTER_... #include "game/scenes/intro.h" // for Intro
#include "texture.h" // for Texture #include "game/scenes/logo.h" // for Logo
#include "title.h" // for Title #include "game/scenes/title.h" // for Title
#include "utils.h" // for options_t, input_t, boolToString #include "utils/utils.h" // for options_t, input_t, boolToString
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) #if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
#include <pwd.h> #include <pwd.h>

View File

@@ -2,8 +2,8 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include "lang.h" #include "core/locale/lang.h"
#include "utils.h" #include "utils/utils.h"
// Tamaño de bloque // Tamaño de bloque
constexpr int BLOCK = 8; constexpr int BLOCK = 8;

View File

@@ -1,12 +1,12 @@
#include "balloon.h" #include "game/entities/balloon.h"
#include <math.h> // for abs #include <math.h> // for abs
#include "animatedsprite.h" // for AnimatedSprite #include "core/rendering/animatedsprite.h" // for AnimatedSprite
#include "const.h" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_AR... #include "core/rendering/movingsprite.h" // for MovingSprite
#include "movingsprite.h" // for MovingSprite #include "core/rendering/sprite.h" // for Sprite
#include "sprite.h" // for Sprite #include "core/rendering/texture.h" // for Texture
#include "texture.h" // for Texture #include "game/defaults.hpp" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_AR...
// Constructor // Constructor
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer) { Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer) {

View File

@@ -5,7 +5,7 @@
#include <string> // for string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "utils.h" // for circle_t #include "utils/utils.h" // for circle_t
class AnimatedSprite; class AnimatedSprite;
class Texture; class Texture;

View File

@@ -1,7 +1,7 @@
#include "bullet.h" #include "game/entities/bullet.h"
#include "const.h" // for NO_KIND, PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_A... #include "core/rendering/sprite.h" // for Sprite
#include "sprite.h" // for Sprite #include "game/defaults.hpp" // for NO_KIND, PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_A...
class Texture; class Texture;
// Constructor // Constructor

View File

@@ -2,7 +2,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include "utils.h" // for circle_t #include "utils/utils.h" // for circle_t
class Sprite; class Sprite;
class Texture; class Texture;

View File

@@ -1,9 +1,9 @@
#include "item.h" #include "game/entities/item.h"
#include <stdlib.h> // for rand #include <stdlib.h> // for rand
#include "animatedsprite.h" // for AnimatedSprite #include "core/rendering/animatedsprite.h" // for AnimatedSprite
#include "const.h" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_AR... #include "game/defaults.hpp" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_AR...
class Texture; class Texture;
// Constructor // Constructor

View File

@@ -5,7 +5,7 @@
#include <string> // for string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "utils.h" // for circle_t #include "utils/utils.h" // for circle_t
class AnimatedSprite; class AnimatedSprite;
class Texture; class Texture;

View File

@@ -1,11 +1,11 @@
#include "player.h" #include "game/entities/player.h"
#include <stdlib.h> // for rand #include <stdlib.h> // for rand
#include "animatedsprite.h" // for AnimatedSprite #include "core/input/input.h" // for inputs_e
#include "const.h" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT #include "core/rendering/animatedsprite.h" // for AnimatedSprite
#include "input.h" // for inputs_e #include "core/rendering/texture.h" // for Texture
#include "texture.h" // for Texture #include "game/defaults.hpp" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT
// Constructor // Constructor
Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations) { Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations) {

View File

@@ -5,7 +5,7 @@
#include <string> // for string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "utils.h" // for circle_t #include "utils/utils.h" // for circle_t
class AnimatedSprite; class AnimatedSprite;
class Texture; class Texture;

View File

@@ -1,4 +1,4 @@
#include "game.h" #include "game/game.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <stdlib.h> // for rand #include <stdlib.h> // for rand
@@ -7,24 +7,24 @@
#include <fstream> // for basic_ifstream #include <fstream> // for basic_ifstream
#include <iostream> // for basic_ostream, char_traits, operator<< #include <iostream> // for basic_ostream, char_traits, operator<<
#include "asset.h" // for Asset #include "core/audio/jail_audio.hpp" // for JA_PlaySound, JA_DeleteSound, JA_LoadSound
#include "balloon.h" // for Balloon, BALLOON_VELX_NEGATIVE, BALLOON_... #include "core/input/input.h" // for inputs_e, Input, REPEAT_TRUE, REPEAT_FALSE
#include "bullet.h" // for Bullet, BULLET_LEFT, BULLET_RIGHT, BULLE... #include "core/locale/lang.h" // for Lang
#include "const.h" // for PLAY_AREA_CENTER_X, BLOCK, PLAY_AREA_CEN... #include "core/rendering/fade.h" // for Fade, FADE_CENTER
#include "fade.h" // for Fade, FADE_CENTER #include "core/rendering/movingsprite.h" // for MovingSprite
#include "input.h" // for inputs_e, Input, REPEAT_TRUE, REPEAT_FALSE #include "core/rendering/screen.h" // for Screen
#include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK #include "core/rendering/smartsprite.h" // for SmartSprite
#include "jail_audio.hpp" // for JA_PlaySound, JA_DeleteSound, JA_LoadSound #include "core/rendering/sprite.h" // for Sprite
#include "lang.h" // for Lang #include "core/rendering/text.h" // for Text, TXT_CENTER
#include "menu.h" // for Menu #include "core/rendering/texture.h" // for Texture
#include "movingsprite.h" // for MovingSprite #include "core/resources/asset.h" // for Asset
#include "player.h" // for Player, DEATH_COUNTER #include "core/resources/resource.h"
#include "resource.h" #include "game/defaults.hpp" // for PLAY_AREA_CENTER_X, BLOCK, PLAY_AREA_CEN...
#include "screen.h" // for Screen #include "game/entities/balloon.h" // for Balloon, BALLOON_VELX_NEGATIVE, BALLOON_...
#include "smartsprite.h" // for SmartSprite #include "game/entities/bullet.h" // for Bullet, BULLET_LEFT, BULLET_RIGHT, BULLE...
#include "sprite.h" // for Sprite #include "game/entities/item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK
#include "text.h" // for Text, TXT_CENTER #include "game/entities/player.h" // for Player, DEATH_COUNTER
#include "texture.h" // for Texture #include "game/ui/menu.h" // for Menu
struct JA_Sound_t; struct JA_Sound_t;
// Constructor // Constructor

View File

@@ -5,7 +5,7 @@
#include <string> // for string, basic_string #include <string> // for string, basic_string
#include <vector> // for vector #include <vector> // for vector
#include "utils.h" // for demoKeys_t, color_t #include "utils/utils.h" // for demoKeys_t, color_t
class Asset; class Asset;
class Balloon; class Balloon;
class Bullet; class Bullet;

View File

@@ -1,4 +1,4 @@
#include "instructions.h" #include "game/scenes/instructions.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -6,17 +6,17 @@
#include <iostream> // for char_traits, basic_ostream, operator<< #include <iostream> // for char_traits, basic_ostream, operator<<
#include <string> // for basic_string #include <string> // for basic_string
#include "asset.h" // for Asset #include "core/audio/jail_audio.hpp" // for JA_StopMusic
#include "const.h" // for shdwTxtColor, GAMECANVAS_CENTER_X, GAME... #include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "core/locale/lang.h" // for Lang
#include "jail_audio.hpp" // for JA_StopMusic #include "core/rendering/screen.h" // for Screen
#include "lang.h" // for Lang #include "core/rendering/sprite.h" // for Sprite
#include "resource.h" #include "core/rendering/text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_SHADOW
#include "screen.h" // for Screen #include "core/rendering/texture.h" // for Texture
#include "sprite.h" // for Sprite #include "core/resources/asset.h" // for Asset
#include "text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_SHADOW #include "core/resources/resource.h"
#include "texture.h" // for Texture #include "game/defaults.hpp" // for shdwTxtColor, GAMECANVAS_CENTER_X, GAME...
#include "utils.h" // for color_t, section_t #include "utils/utils.h" // for color_t, section_t
// Constructor // Constructor
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) { Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) {

View File

@@ -1,21 +1,21 @@
#include "intro.h" #include "game/scenes/intro.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <string> // for basic_string #include <string> // for basic_string
#include "asset.h" // for Asset #include "core/audio/jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic
#include "const.h" // for GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QU... #include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "core/locale/lang.h" // for Lang
#include "jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic #include "core/rendering/screen.h" // for Screen
#include "lang.h" // for Lang #include "core/rendering/smartsprite.h" // for SmartSprite
#include "resource.h" #include "core/rendering/text.h" // for Text
#include "screen.h" // for Screen #include "core/rendering/texture.h" // for Texture
#include "smartsprite.h" // for SmartSprite #include "core/rendering/writer.h" // for Writer
#include "text.h" // for Text #include "core/resources/asset.h" // for Asset
#include "texture.h" // for Texture #include "core/resources/resource.h"
#include "utils.h" // for section_t, color_t #include "game/defaults.hpp" // for GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QU...
#include "writer.h" // for Writer #include "utils/utils.h" // for section_t, color_t
// Constructor // Constructor
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) { Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) {

View File

@@ -1,19 +1,19 @@
#include "logo.h" #include "game/scenes/logo.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <algorithm> // for min #include <algorithm> // for min
#include <string> // for basic_string #include <string> // for basic_string
#include "asset.h" // for Asset #include "core/audio/jail_audio.hpp" // for JA_StopMusic
#include "const.h" // for bgColor, SECTION_PROG_LOGO, SECTION_PROG... #include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "core/rendering/screen.h" // for Screen
#include "jail_audio.hpp" // for JA_StopMusic #include "core/rendering/sprite.h" // for Sprite
#include "resource.h" #include "core/rendering/texture.h" // for Texture
#include "screen.h" // for Screen #include "core/resources/asset.h" // for Asset
#include "sprite.h" // for Sprite #include "core/resources/resource.h"
#include "texture.h" // for Texture #include "game/defaults.hpp" // for bgColor, SECTION_PROG_LOGO, SECTION_PROG...
#include "utils.h" // for section_t, color_t #include "utils/utils.h" // for section_t, color_t
// Valores de inicialización y fin // Valores de inicialización y fin
constexpr int INIT_FADE = 100; constexpr int INIT_FADE = 100;

View File

@@ -1,4 +1,4 @@
#include "title.h" #include "game/scenes/title.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <stdlib.h> // for rand #include <stdlib.h> // for rand
@@ -6,21 +6,21 @@
#include <iostream> // for basic_ostream, operator<<, basic_ostrea... #include <iostream> // for basic_ostream, operator<<, basic_ostrea...
#include <string> // for basic_string, operator+, char_traits #include <string> // for basic_string, operator+, char_traits
#include "animatedsprite.h" // for AnimatedSprite #include "core/audio/jail_audio.hpp" // for JA_StopMusic, JA_GetMusicState, JA_Play...
#include "asset.h" // for Asset #include "core/input/input.h" // for Input, INPUT_USE_GAMECONTROLLER, INPUT_...
#include "const.h" // for GAMECANVAS_CENTER_X, SECTION_PROG_QUIT #include "core/locale/lang.h" // for Lang, ba_BA, en_UK, es_ES
#include "fade.h" // for Fade #include "core/rendering/animatedsprite.h" // for AnimatedSprite
#include "game.h" // for Game #include "core/rendering/fade.h" // for Fade
#include "input.h" // for Input, INPUT_USE_GAMECONTROLLER, INPUT_... #include "core/rendering/screen.h" // for Screen, FILTER_LINEAL, FILTER_NEAREST
#include "jail_audio.hpp" // for JA_StopMusic, JA_GetMusicState, JA_Play... #include "core/rendering/smartsprite.h" // for SmartSprite
#include "lang.h" // for Lang, ba_BA, en_UK, es_ES #include "core/rendering/sprite.h" // for Sprite
#include "menu.h" // for Menu #include "core/rendering/text.h" // for Text, TXT_CENTER, TXT_SHADOW
#include "resource.h" #include "core/rendering/texture.h" // for Texture
#include "screen.h" // for Screen, FILTER_LINEAL, FILTER_NEAREST #include "core/resources/asset.h" // for Asset
#include "smartsprite.h" // for SmartSprite #include "core/resources/resource.h"
#include "sprite.h" // for Sprite #include "game/defaults.hpp" // for GAMECANVAS_CENTER_X, SECTION_PROG_QUIT
#include "text.h" // for Text, TXT_CENTER, TXT_SHADOW #include "game/game.h" // for Game
#include "texture.h" // for Texture #include "game/ui/menu.h" // for Menu
// Constructor // Constructor
Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t *section) { Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t *section) {

View File

@@ -4,8 +4,8 @@
#include <vector> // for vector #include <vector> // for vector
#include "instructions.h" // for mode_e #include "game/scenes/instructions.h" // for mode_e
#include "utils.h" // for input_t, options_t, section_t #include "utils/utils.h" // for input_t, options_t, section_t
class AnimatedSprite; class AnimatedSprite;
class Asset; class Asset;
class Fade; class Fade;

View File

@@ -1,14 +1,14 @@
#include "menu.h" #include "game/ui/menu.h"
#include <algorithm> // for max, min #include <algorithm> // for max, min
#include <fstream> // for char_traits, basic_ifstream, basic_istream #include <fstream> // for char_traits, basic_ifstream, basic_istream
#include <sstream> // for basic_stringstream #include <sstream> // for basic_stringstream
#include "asset.h" // for Asset #include "core/audio/jail_audio.hpp" // for JA_LoadSound, JA_PlaySound, JA_DeleteSound
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "jail_audio.hpp" // for JA_LoadSound, JA_PlaySound, JA_DeleteSound #include "core/rendering/text.h" // for Text
#include "resource_helper.h" #include "core/resources/asset.h" // for Asset
#include "text.h" // for Text #include "core/resources/resource_helper.h"
// Constructor // Constructor
Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file) { Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file) {

View File

@@ -6,7 +6,7 @@
#include <string> // for string, basic_string #include <string> // for string, basic_string
#include <vector> // for vector #include <vector> // for vector
#include "utils.h" // for color_t #include "utils/utils.h" // for color_t
class Asset; class Asset;
class Input; class Input;
class Text; class Text;

View File

@@ -42,7 +42,7 @@ Reescribiendo el código el 27/09/2022
#define SDL_MAIN_USE_CALLBACKS 1 #define SDL_MAIN_USE_CALLBACKS 1
#include <SDL3/SDL_main.h> #include <SDL3/SDL_main.h>
#include "director.h" #include "core/system/director.h"
#include "external/stb_vorbis.c" #include "external/stb_vorbis.c"
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) { SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) {

View File

@@ -1,4 +1,4 @@
#include "utils.h" #include "utils/utils.h"
#include <stdlib.h> // for abs, free, malloc #include <stdlib.h> // for abs, free, malloc

View File

@@ -1,7 +1,7 @@
#include <filesystem> #include <filesystem>
#include <iostream> #include <iostream>
#include "resource_pack.h" #include "core/resources/resource_pack.h"
static constexpr const char* APP_NAME = "Coffee Crisis"; static constexpr const char* APP_NAME = "Coffee Crisis";