treballant en el overlay, el text i les notificacions

This commit is contained in:
2026-04-04 18:11:04 +02:00
parent abb23071b5
commit fe8e5d661e
38 changed files with 738 additions and 105 deletions

View File

@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview
**Aventures En Egipte (AEE)** — a retro-style 2D game written in C++ using SDL3. The game uses a software-rendered 8-bit paletted graphics engine (320x200, 256 colors) with an OpenGL CRT shader pass, custom audio (JailAudio replacing SDL_Mixer), and GIF-based assets. The codebase and commit messages are in Valencian/Catalan.
**Aventures En Egipte (AEE)** — a retro-style 2D game written in C++ using SDL3. The game uses a software-rendered 8-bit paletted graphics engine (320x200, 256 colors), custom audio (JailAudio), and GIF-based assets. The codebase and commit messages are in Valencian/Catalan.
## Build
@@ -18,38 +18,61 @@ cmake -B build -G "MinGW Makefiles"
cmake --build build
```
Dependencies: SDL3, OpenGL. Uses CMake (minimum 3.10) with C++20.
Dependencies: SDL3. Uses CMake (minimum 3.10) with C++20.
The executable is output to the project root. The `data/` folder contains runtime assets (GIF images, OGG music, GLSL shader) and must be in the working directory at runtime.
The executable is output to the project root. The `data/` folder must be in the working directory at runtime.
## Architecture
### Custom "Jail" Engine Libraries (prefix: J)
### Boundary: Original vs New Code
All engine modules are flat C-style APIs (no classes), prefixed by subsystem:
The codebase has a clear separation between the original game and the new modernization layer:
- **JG** (`source/core/jgame`) — Game loop timing: init/finalize, fixed-timestep update via `JG_ShouldUpdate()`
- **JD8** (`source/core/jdraw8`) — 8-bit paletted software renderer. 320x200 screen buffer (`JD8_Surface` = `Uint8*`), palette-indexed blitting with color-key transparency, fade effects. `JD8_Flip()` converts the indexed buffer to ARGB, uploads to SDL texture, and renders through the CRT shader
- **JA** (`source/core/jail_audio`) — Custom audio mixing using SDL3 audio streams directly (OGG via stb_vorbis, WAV). Manages music and sound channels independently
- **JI** (`source/core/jinput`) — Input: keyboard state polling, key debouncing, cheat code detection
- **JF** (`source/core/jfile`) — File I/O: supports loading from filesystem folder or a packed resource file (`.jrf`). Currently uses folder mode (`data/`)
- **shader** (`source/core/jshader`) — OpenGL post-processing shader (CRT effect) applied to the back buffer
| Path | Owner | Rule |
|------|-------|------|
| `source/core/jail/` | Original engine | **Do not modify** gameplay behavior |
| `source/game/*.cpp/hpp` (except options/defines/defaults) | Original game | **Do not modify** |
| `source/core/rendering/` | New presentation layer | Free to modify |
| `source/core/input/` | New input layer | Free to modify |
| `source/game/options.hpp/cpp` | New config system | Free to modify |
| `source/game/defines.hpp` | New constants | Free to modify |
| `source/game/defaults.hpp` | New defaults | Free to modify |
| `data/*.gif, *.ogg` | Original assets | **Do not modify** |
| `data/fonts/, data/ui/` | New assets | Free to modify |
### Original "Jail" Engine (`source/core/jail/`)
Flat C-style APIs (no classes), prefixed by subsystem. **Do not touch gameplay logic.**
- **JG** (`jgame`) — Game loop timing: init/finalize, fixed-timestep update via `JG_ShouldUpdate()`
- **JD8** (`jdraw8`) — 8-bit paletted software renderer. 320x200 screen buffer (`JD8_Surface` = `Uint8*`), palette-indexed blitting with color-key transparency, fade effects. `JD8_Flip()` converts palette→ARGB and delegates to `Screen::present()`
- **JA** (`jail_audio`) — Custom audio mixing using SDL3 audio streams (OGG via stb_vorbis, WAV)
- **JI** (`jinput`) — Input: keyboard state polling, key debouncing, cheat code detection. Calls `GlobalInputs::handle()` at end of each update
- **JF** (`jfile`) — File I/O: filesystem folder mode (`data/`) or packed resource file (`.jrf`)
### Presentation Layer (`source/core/rendering/`)
- **Screen** — Singleton managing SDL_Window, SDL_Renderer, SDL_Texture. Receives ARGB pixel buffer from JD8 and presents it. Handles fullscreen toggle, zoom. Prepared for future SDL3GPU backend
### Input Layer (`source/core/input/`)
- **GlobalInputs** — Maps configurable function keys to window management actions (F1 zoom-, F2 zoom+, F3 fullscreen). Reads key bindings from `Options::keys_gui`
### Configuration System (`source/game/`)
Follows the pattern from `jaildoctors_dilemma`:
- **defines.hpp** <EFBFBD><EFBFBD> Game-wide constants (window title, version, screen dimensions)
- **defaults.hpp** — Default values for all persistent options (audio, game)
- **defines.hpp** Game-wide constants (window title, version, screen dimensions)
- **defaults.hpp** — Default values for all persistent options, including key bindings (`Defaults::KeysGUI`, `Defaults::KeysGame`)
- **options.hpp/cpp** — `Options` namespace with structs, inline globals, and YAML load/save API. Config persists to `~/.config/jailgames/aee/config.yaml` (Linux), `%APPDATA%/jailgames/aee/` (Windows)
### Game Modules (`source/game/`)
### Game Modules (`source/game/`) — Original, Do Not Touch
- **ModuleSequence** — Non-gameplay screens: intro, menu, slides, banners, credits, death screen. State machine entry point (state=1)
- **ModuleGame** — Core gameplay loop. Owns and orchestrates all game objects. State=0
- **ModuleSequence** — Non-gameplay screens: intro, menu, slides, banners, credits, death screen (state=1)
- **ModuleGame** — Core gameplay loop, orchestrates all game objects (state=0)
- **Sprite** — Base class for animated entities (frame/animation data via `Entitat`)
- **Prota** — Player character ("Sam"), extends Sprite
- **Mapa** — Level map with tomb grid (16 tombs), items (treasure, keys, pharaoh, mummy, scroll, diamond), door logic
- **Mapa** — Level map with tomb grid (16 tombs), items, door logic
- **Momia** — Enemy: mummies
- **Bola** — Enemy: projectile ball
- **Marcador** — HUD/scoreboard
@@ -61,19 +84,21 @@ Follows the pattern from `jaildoctors_dilemma`:
- `stb_vorbis.h` — stb single-header OGG decoder
- `fkyaml_node.hpp` — Header-only YAML parser (fkYAML v0.4.2)
### Data Assets (`data/`)
- `*.gif`, `*.ogg`, `crtpi.glsl` — Original game assets (**do not modify**)
- `fonts/` — New font assets for overlay/UI
- `ui/` — New UI graphics for overlay
### Main Loop (`source/main.cpp`)
A state machine alternates between `ModuleSequence` (state 1) and `ModuleGame` (state 0). Each module's `Go()` returns the next state (-1 to quit). Modules are allocated/freed each transition.
### Golden Rule: Do Not Touch Gameplay
The original game logic (gameplay, entities, map, scoring, collisions, animations) must remain untouched. All modernization work targets the presentation layer and infrastructure only: window management, configuration/persistence, rendering pipeline (overlay/UI), and build system. Any new feature (save states, options menu, etc.) must be implemented as an overlay on top of the existing game, never by modifying the original gameplay code.
### Key Conventions
- All surfaces are 320x200 = 64000 bytes. Pixel coordinates assume this fixed resolution
- Graphics loaded from GIF files, palettes extracted from GIF headers
- Music files are numbered OGG files (`00000001.ogg` etc.)
- `trick.ini` presence enables the secret character
- Includes use absolute paths from `source/` (e.g., `#include "core/jgame.hpp"`, `#include "game/info.hpp"`)
- Includes use absolute paths from `source/` (e.g., `#include "core/jail/jgame.hpp"`, `#include "game/info.hpp"`)
- Headers use `.hpp` extension; external third-party headers in `source/external/` keep `.h`