# javier0f/juego-de-naves architecture

> Architecture diagram of the GitHub repository javier0f/juego-de-naves, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/javier0f/juego-de-naves
- Repository: https://github.com/javier0f/juego-de-naves

## Overview

This is a Macroquad-based Asteroids-style arcade game. The main loop initializes the world and game, dispatches menu/run/end behavior, and in the running state coordinates player input, bullets, particles, rendering, collisions, and the life display. Restarting rebuilds player, asteroid, and particle state. The graph preserves the distinct gameplay systems and their shared ECS components; the README is empty, and unsampled source is not used to infer additional behavior.

Main entry points: [`src/main.rs`](https://github.com/javier0f/juego-de-naves/blob/main/src/main.rs) (Game Loop), [`src/components.rs`](https://github.com/javier0f/juego-de-naves/blob/main/src/components.rs) (ECS Components), [`src/states/menu.rs`](https://github.com/javier0f/juego-de-naves/blob/main/src/states/menu.rs) (Menu and Restart), [`src/entitys/player.rs`](https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/player.rs) (Player Control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_main["Game Loop<br/>[main.rs]"]
  node_menu["Menu and Restart<br/>[menu.rs]"]
  node_ui_style["UI Styling<br/>[ui_style.rs]"]
end

subgraph group_gameplay["Gameplay Systems"]
  node_collision["Collision<br/>[collision.rs]"]
  node_lifebar["Life Display<br/>[lifebar.rs]"]
end

subgraph group_entities["Entity Systems"]
  node_player_system["Player Control<br/>[player.rs]"]
  node_asteroids["Asteroids<br/>[asteroids.rs]"]
  node_bullets["Bullets<br/>[bullets.rs]"]
  node_particles["Particles<br/>[particles.rs]"]
end

subgraph group_shared["Shared State"]
  node_game_states["Game State<br/>[game_state.rs]"]
  node_components["ECS Components<br/>[components.rs]"]
end

node_player(("Player"))
node_display(("Game Display"))

node_player -->|"provides input"| node_player_system
node_main -->|"reads state"| node_game_states
node_main -->|"dispatches menu"| node_menu
node_main -->|"runs control"| node_player_system
node_main -->|"updates bullets"| node_bullets
node_main -->|"updates particles"| node_particles
node_main -->|"moves and renders"| node_asteroids
node_main -->|"runs collisions"| node_collision
node_main -->|"updates life"| node_lifebar
node_main -->|"loads skin"| node_ui_style
node_main -->|"draws frame"| node_display
node_menu -->|"switches state"| node_game_states
node_menu -->|"creates player"| node_player_system
node_menu -->|"creates asteroids"| node_asteroids
node_menu -->|"reinitializes system"| node_particles
node_bullets -->|"damages asteroids"| node_asteroids
node_bullets -->|"queries components"| node_components
node_player_system -->|"queries components"| node_components
node_asteroids -->|"queries components"| node_components
node_particles -->|"queries components"| node_components
node_collision -->|"queries components"| node_components
node_lifebar -->|"reads life and position"| node_components
node_lifebar -->|"ends game"| node_game_states

click node_main "https://github.com/javier0f/juego-de-naves/blob/main/src/main.rs"
click node_game_states "https://github.com/javier0f/juego-de-naves/blob/main/src/states/game_state.rs"
click node_menu "https://github.com/javier0f/juego-de-naves/blob/main/src/states/menu.rs"
click node_player_system "https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/player.rs"
click node_asteroids "https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/asteroids.rs"
click node_bullets "https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/bullets.rs"
click node_particles "https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/particles.rs"
click node_collision "https://github.com/javier0f/juego-de-naves/blob/main/src/collision.rs"
click node_lifebar "https://github.com/javier0f/juego-de-naves/blob/main/src/lifebar.rs"
click node_components "https://github.com/javier0f/juego-de-naves/blob/main/src/components.rs"
click node_ui_style "https://github.com/javier0f/juego-de-naves/blob/main/src/ui_style.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_menu,node_ui_style toneBlue
class node_collision,node_lifebar toneAmber
class node_player_system,node_asteroids,node_bullets,node_particles toneMint
class node_game_states,node_components toneRose
class node_player,node_display toneIndigo
```

## Components

### Game Runtime

- [Game Loop](https://github.com/javier0f/juego-de-naves/blob/main/src/main.rs): `src/main.rs`
- [Menu and Restart](https://github.com/javier0f/juego-de-naves/blob/main/src/states/menu.rs): `src/states/menu.rs`
- [UI Styling](https://github.com/javier0f/juego-de-naves/blob/main/src/ui_style.rs): `src/ui_style.rs`

### Gameplay Systems

- [Collision](https://github.com/javier0f/juego-de-naves/blob/main/src/collision.rs): `src/collision.rs`
- [Life Display](https://github.com/javier0f/juego-de-naves/blob/main/src/lifebar.rs): `src/lifebar.rs`

### Entity Systems

- [Player Control](https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/player.rs): `src/entitys/player.rs`
- [Asteroids](https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/asteroids.rs): `src/entitys/asteroids.rs`
- [Bullets](https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/bullets.rs): `src/entitys/bullets.rs`
- [Particles](https://github.com/javier0f/juego-de-naves/blob/main/src/entitys/particles.rs): `src/entitys/particles.rs`

### Shared State

- [Game State](https://github.com/javier0f/juego-de-naves/blob/main/src/states/game_state.rs): `src/states/game_state.rs`
- [ECS Components](https://github.com/javier0f/juego-de-naves/blob/main/src/components.rs): `src/components.rs`

### Other components

- **Player**
- **Game Display**

## Connections

- Player → Player Control: provides input (evidence: `src/entitys/player.rs`)
- Game Loop → Game State: reads state (evidence: `src/main.rs`)
- Game Loop → Menu and Restart: dispatches menu (evidence: `src/main.rs`)
- Game Loop → Player Control: runs control (evidence: `src/main.rs`)
- Game Loop → Bullets: updates bullets (evidence: `src/main.rs`)
- Game Loop → Particles: updates particles (evidence: `src/main.rs`)
- Game Loop → Asteroids: moves and renders (evidence: `src/main.rs`)
- Game Loop → Collision: runs collisions (evidence: `src/main.rs`)
- Game Loop → Life Display: updates life (evidence: `src/main.rs`)
- Game Loop → UI Styling: loads skin (evidence: `src/main.rs`)
- Game Loop → Game Display: draws frame (evidence: `src/main.rs`)
- Menu and Restart → Game State: switches state (evidence: `src/states/menu.rs`)
- Menu and Restart → Player Control: creates player (evidence: `src/states/menu.rs`)
- Menu and Restart → Asteroids: creates asteroids (evidence: `src/states/menu.rs`)
- Menu and Restart → Particles: reinitializes system (evidence: `src/states/menu.rs`)
- Bullets → Asteroids: damages asteroids (evidence: `src/entitys/bullets.rs`)
- Bullets → ECS Components: queries components (evidence: `src/entitys/bullets.rs`)
- Player Control → ECS Components: queries components (evidence: `src/entitys/player.rs`)
- Asteroids → ECS Components: queries components (evidence: `src/entitys/asteroids.rs`)
- Particles → ECS Components: queries components (evidence: `src/entitys/particles.rs`)
- Collision → ECS Components: queries components (evidence: `src/collision.rs`)
- Life Display → ECS Components: reads life and position (evidence: `src/lifebar.rs`)
- Life Display → Game State: ends game (evidence: `src/lifebar.rs`)
