reestructuració
This commit is contained in:
88
CLAUDE.md
88
CLAUDE.md
@@ -4,67 +4,67 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## 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
|
||||
|
||||
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
|
||||
# Linux
|
||||
make linux # Release build → ./coffee_crisis
|
||||
make linux_debug # Debug build (defines DEBUG and PAUSE) → ./coffee_crisis_debug
|
||||
|
||||
# macOS
|
||||
make macos # Release build with clang++
|
||||
make macos_debug # Debug build
|
||||
|
||||
# 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
|
||||
make # Release build
|
||||
make debug # Debug build (defines DEBUG and PAUSE)
|
||||
make release # Empaqueta .tar.gz / .dmg / .zip segons SO
|
||||
make pack # Regenera resources.pack
|
||||
make controllerdb # Descarga gamecontrollerdb.txt
|
||||
make format # clang-format -i
|
||||
make tidy # clang-tidy
|
||||
make cppcheck # cppcheck
|
||||
```
|
||||
|
||||
There is also a CMakeLists.txt available as an alternative build system.
|
||||
|
||||
There are no tests or linter configured.
|
||||
|
||||
## 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.
|
||||
- **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.
|
||||
- **Input** (`input.h/cpp`): Abstracts keyboard and gamepad input.
|
||||
- **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.
|
||||
- **Lang** (`lang.h/cpp`): i18n system loading text strings from files in `data/lang/`.
|
||||
```
|
||||
source/
|
||||
├── main.cpp
|
||||
├── core/
|
||||
│ ├── audio/ jail_audio.hpp
|
||||
│ ├── 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
|
||||
- **AnimatedSprite** → extends Sprite with frame-based animation (loaded from `.ani` files)
|
||||
- **MovingSprite** → sprite with movement
|
||||
- **SmartSprite** → sprite with autonomous behavior (score popups, thrown items)
|
||||
- **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.
|
||||
- **Screen** (`core/rendering/screen.h`): abstracció de render. Canvas virtual 256×192 escalat a la finestra. Fullscreen/windowed, borders, fades.
|
||||
- **Input** (`core/input/input.h`): abstracció de teclat i gamepad.
|
||||
- **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
|
||||
- **Balloon** (`balloon.h/cpp`): Enemy entities with multiple types and split-on-pop behavior
|
||||
- **Bullet** (`bullet.h/cpp`): Projectiles fired by the player (left/center/right)
|
||||
- **Item** (`item.h/cpp`): Collectible items (points, clock, coffee, power-ups)
|
||||
- **Sprite** → base per dibuixar des d'un spritesheet PNG
|
||||
- **AnimatedSprite** → afegeix animació per frames (arxius `.ani`)
|
||||
- **MovingSprite** → sprite amb posició/velocitat
|
||||
- **SmartSprite** → sprite autònom (score popups, objectes llençats)
|
||||
|
||||
### 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.
|
||||
|
||||
### Key constants
|
||||
|
||||
Defined in `const.h`: block size (8px), virtual canvas (256×192), play area bounds, section/subsection IDs, and color definitions.
|
||||
**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.
|
||||
|
||||
## Data Directory
|
||||
|
||||
|
||||
Reference in New Issue
Block a user