Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions docs/docs/technical-docs/client/resources/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,104 @@ This avoids leaking filesystem details into gameplay or UI code.

---

## Asset Embedding

To ensure assets are bundled with the executable and avoid external dependencies,
assets are embedded directly into the client binary at compile time.

### Embedding Process

1. **Asset Discovery**: CMake script (`generate_embedded_assets.cmake`) scans the `client/assets/` directory
2. **Binary Conversion**: Python script (`bin2header.py`) converts binary files to C++ header arrays
3. **Code Generation**: Generated `.cpp` files contain asset data as `unsigned char` arrays
4. **Compilation**: Embedded assets are compiled into the client executable

### Supported Asset Types

The embedding system supports:
- **Images**: PNG sprites and textures
- **Fonts**: OTF and TTF font files
- **Audio**: WAV and FLAC sound files
- **Shaders**: Fragment shaders
- **Data**: JSON configuration files (animations, levels)

### Generated Code Structure

Each asset generates a header file with:
```cpp
namespace EmbeddedResources {
extern const unsigned char asset_name[];
extern const unsigned int asset_name_size;
}
```

### Usage in Code

Embedded assets are accessed through the `EmbeddedResourceManager`:
```cpp
auto texture = resourceManager.loadTexture("sprites/player.png");
auto font = resourceManager.loadFont("fonts/main.otf");
auto soundBuffer = resourceManager.loadSound("sounds/shoot.wav");
```

### Build Integration

- Run `generate_embedded_assets.cmake` during the CMake configure step
- Generated files are placed in `build/client/embedded_resources/`
- Assets are automatically linked into the client executable

This approach ensures:
- No external asset files required at runtime
- Faster loading (no filesystem I/O)
- Self-contained executables
- Consistent asset availability across platforms

---

## JSON Asset Definitions

In addition to binary assets, the client uses JSON files to define complex asset behaviors:

### Animation Definitions

JSON files define sprite animations with frame sequences and timing:

```json
{
"sprite": "player",
"spriteId": 7,
"default_animation": "idle",
"animations": {
"idle": {
"loop": true,
"frames": [
{ "x": 0, "y": 0, "w": 33, "h": 18, "duration": 0.5 },
{ "x": 33, "y": 0, "w": 33, "h": 18, "duration": 0.5 }
]
}
}
}
```

### Background Definitions

Background layers are defined with scrolling properties:

```json
{
"spriteId": 101,
"scrollSpeed": -50.0,
"tileWidth": 2584.0,
"tileHeight": 720.0
}
```

### Entity Definitions

Game entities (players, enemies, power-ups) have JSON definitions for sprites, sounds, and behaviors.

---

## Failure Handling

- Missing or invalid assets must not crash the client
Expand Down
154 changes: 154 additions & 0 deletions docs/docs/technical-docs/server/engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
---
id: engine
title: Engine Details
sidebar_label: Engine Details
---

# R-TYPE Engine Details

This document provides detailed information about the Entity Component System (ECS) components and systems implemented in the R-TYPE server engine.

## ECS Components

The ECS architecture uses components to define entity properties and behaviors. Below are the key components implemented:

### Core Components

- **Id**: Unique identifier for entities
- **Position**: 2D position (x, y) in the game world
- **Velocity**: Movement velocity (dx, dy)
- **Direction**: Facing direction vector
- **Lifetime**: Time-to-live for temporary entities

### Combat Components

- **Health**: Current and maximum hit points
- **Damage**: Damage value for projectiles
- **Damageable**: Marks entities that can take damage
- **Attack**: Attack properties and cooldowns
- **Projectile**: Projectile-specific properties (speed, damage, type)
- **HomingProjectile**: Homing behavior (target ID, strength, max speed)

### Enemy AI Components

- **AIBrain**: AI behavior state and decision-making
- **AIShoot**: AI shooting patterns and timing
- **MovementPattern**: Complex movement behaviors (sinusoidal, circular, etc.)
- **Target**: Target tracking for homing projectiles

### Power-Up Components

- **PowerUp**: Marks collectible power-up entities
- **PowerUpType**: Defines power-up categories (force, laser, bubble)
- **PlayerPowerUp**: Active power-up state on players
- **BubblePowerUp**: Bubble shield mechanics
- **LaserPowerUp**: Laser weapon mechanics

### Boss Components

- **BossPart**: Multi-part boss hitboxes with damage multipliers
- **BossPhase**: Boss phase transitions and behaviors
- **TailFollower**: Boss tail segment following logic

### Physics Components

- **Collision**: Collision detection properties
- **PixelCollision**: Pixel-perfect collision data
- **GravityAffected**: Entities affected by gravity fields
- **GravityField**: Gravity source entities
- **Controllable**: Player-controlled entities

### Rendering Components

- **Drawable**: Rendering properties (sprite ID, layer)

### Scoring Components

- **KillScore**: Points awarded for destroying enemies
- **Score**: Player score tracking

### Input Components

- **InputComponent**: Player input state

### Background Components

- **Background**: Background layer properties

## ECS Systems

Systems process entities with specific component combinations. Each system runs in order during the game loop.

### Movement Systems

- **MovementSystem**: Applies velocity to positions using delta-time. Updates Position components based on Velocity components.

- **MovementPatternSystem**: Handles complex enemy movement patterns (sinusoidal waves, circular paths, etc.).

### Combat Systems

- **CollisionSystem**: Detects collisions between entities and applies damage. Handles projectile-enemy and projectile-player interactions.

- **ShootingSystem**: Manages weapon firing, cooldowns, and projectile creation.

- **PowerUpShootingSystem**: Handles special power-up weapons (laser, bubble) with unique firing mechanics.

- **AIShootSystem**: Controls enemy shooting patterns and timing.

- **HomingSystem**: Updates homing projectile trajectories toward targets.

### Physics Systems

- **GravitySystem**: Applies gravitational forces to affected entities.

- **LifetimeSystem**: Removes entities when their lifetime expires.

### Boss Systems

- **BossSystem**: Manages boss behaviors, phase transitions, and multi-part logic.

- **TailFollowerSystem**: Updates boss tail segments to follow the main body.

### Power-Up Systems

- **PowerUpAttachmentSystem**: Manages power-up collection and attachment to players.

- **PowerUpBarSystem**: Updates power-up charge bars and UI.

- **BubblePowerUpSystem**: Handles bubble shield mechanics and collision immunity.

- **LaserPowerUpSystem**: Manages laser weapon charging and firing.

### Utility Systems

- **InputSystem**: Processes player input and updates controllable entities.

- **HealthSystem**: Manages damage application and entity destruction.

- **SnapshotSystem**: Prepares world state for network synchronization.

- **BackgroundSystem**: Updates scrolling background layers.

## System Execution Order

Systems are executed in a specific order to ensure correct dependencies:

1. InputSystem (process player input)
2. MovementSystem (apply velocities)
3. MovementPatternSystem (complex movements)
4. ShootingSystem (create projectiles)
5. PowerUpShootingSystem (special weapons)
6. AIShootSystem (AI decisions)
7. HomingSystem (update projectile paths)
8. GravitySystem (apply gravity)
9. CollisionSystem (detect and resolve collisions)
10. HealthSystem (apply damage and destroy entities)
11. LifetimeSystem (remove expired entities)
12. BossSystem (boss-specific logic)
13. TailFollowerSystem (boss tail updates)
14. PowerUpAttachmentSystem (power-up collection)
15. PowerUpBarSystem (UI updates)
16. BubblePowerUpSystem (shield mechanics)
17. LaserPowerUpSystem (laser mechanics)
18. BackgroundSystem (visual updates)
19. SnapshotSystem (network prep)
36 changes: 26 additions & 10 deletions docs/docs/technical-docs/server/engine/audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,34 @@ sidebar_label: Audio

# Audio System

The audio module manages all sound effects and background music.
The audio system manages sound effects and music on the server side. The server does not play audio directly - it tracks audio events and includes them in snapshots sent to clients.

## Features

- Play and stop sounds.
- Volume control per entity or global.
- Looping music tracks.
- Positional audio for immersive experience.
- Sound effect triggering for game events.
- Music track management.
- Audio state synchronization across clients.
- Volume and priority management.

## Example
## Components Used

```cpp
AudioSystem::playSound("laser.wav");
AudioSystem::playMusic("background.mp3", loop=true);
```
- **Attack**: May include sound effect references
- **Projectile**: Sound effects for firing
- **Health**: Death sound effects
- **PowerUp**: Collection and activation sounds

## Workflow

1. Track audio events during gameplay (shots, deaths, power-ups).
2. Include audio commands in network snapshots.
3. Ensure all clients play synchronized sound effects.
4. Manage music transitions for level changes.

## Server Audio Responsibilities

- Determine when sounds should play
- Include audio events in authoritative snapshots
- Ensure consistent audio experience across all clients
- Handle music track changes for game phases

Actual audio playback is handled by clients using SFML audio capabilities.
69 changes: 56 additions & 13 deletions docs/docs/technical-docs/server/engine/ecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,62 @@ For example:
**Components are pure data** structures.
Each component represents one aspect of an entity.

### Common Components in R-TYPE ECS

- **Health**: Tracks life points, damage state, death flag.
- **Position**: Stores X/Y coordinates.
- **Velocity**: Movement speed and direction.
- **Direction**: Orientation of entity or facing vector.
- **AI_Brain**: Controls enemy behavior or NPC decision-making.
- **Drawable**: Reference to sprite, animation, or visual asset.
- **Damageable**: Marks entity as capable of receiving damage.
- **Damage**: Represents damage dealt to other entities.
- **Collision**: Defines hitboxes and interaction rules.
- **Controllable**: Marks entity as controlled by a player.
- **Attack**: Stores attack patterns, cooldowns, and projectiles.
### Complete List of Components in R-TYPE ECS

#### Core Components
- **Id**: Unique entity identifier
- **Position**: 2D position (x, y) coordinates
- **Velocity**: Movement velocity (dx, dy)
- **Direction**: Facing direction vector
- **Lifetime**: Time-to-live for temporary entities

#### Combat Components
- **Health**: Current and maximum hit points
- **Damage**: Damage value for projectiles
- **Damageable**: Marks entities that can take damage
- **Attack**: Attack properties and cooldowns
- **Projectile**: Projectile-specific properties (speed, damage, type)
- **HomingProjectile**: Homing behavior (target ID, strength, max speed)
- **WeaponConfig**: Weapon configuration and upgrades

#### Enemy AI Components
- **AIBrain**: AI behavior state and decision-making
- **AIShoot**: AI shooting patterns and timing
- **MovementPattern**: Complex movement behaviors (sinusoidal, circular, etc.)
- **Target**: Target tracking for homing projectiles
- **Controllable**: Player-controlled entities

#### Power-Up Components
- **PowerUp**: Marks collectible power-up entities
- **PowerUpType**: Defines power-up categories (force, laser, bubble)
- **PlayerPowerUp**: Active power-up state on players
- **BubblePowerUp**: Bubble shield mechanics
- **LaserPowerUp**: Laser weapon mechanics
- **PowerUpBar**: Power-up charge visualization

#### Boss Components
- **BossPart**: Multi-part boss hitboxes with damage multipliers
- **BossPhase**: Boss phase transitions and behaviors
- **TailFollower**: Boss tail segment following logic

#### Physics Components
- **Collision**: Collision detection properties
- **PixelCollision**: Pixel-perfect collision data
- **GravityAffected**: Entities affected by gravity fields
- **GravityField**: Gravity source entities

#### Rendering Components
- **Drawable**: Rendering properties (sprite ID, layer)

#### Scoring Components
- **KillScore**: Points awarded for destroying enemies
- **Score**: Player score tracking

#### Input Components
- **InputComponent**: Player input state

#### Background Components
- **Background**: Background layer properties
- **Score**: Tracks points gained from actions.

**Key points:**
Expand Down
Loading
Loading