# marvelous616/pong architecture

> Architecture diagram of the GitHub repository marvelous616/pong, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marvelous616/pong
- Repository: https://github.com/marvelous616/pong

## Overview

PONG is a Linux framebuffer Pong game. The principal workflow is keyboard input → game-state updates and collision handling → drawing the scene and score into a CPU framebuffer → copying it to the display. The README also documents configurable screen dimensions and input-device setup; the source shows framebuffer initialization and the main loop. Some declared modules and integrations are unsampled, so uncertain connections are omitted.

Main entry points: [`src/main.c`](https://github.com/marvelous616/pong/blob/main/src/main.c) (Game loop), [`src/inp_event.c`](https://github.com/marvelous616/pong/blob/main/src/inp_event.c) (Keyboard events), [`src/render.c`](https://github.com/marvelous616/pong/blob/main/src/render.c) (CPU framebuffer), [`src/entity.c`](https://github.com/marvelous616/pong/blob/main/src/entity.c) (Entity model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game"]
  node_main_loop["Game loop<br/>[main.c]"]
end

subgraph group_input["Input"]
  node_keyboard["Keyboard events<br/>[inp_event.c]"]
end

subgraph group_graphics["Graphics"]
  node_framebuffer["CPU framebuffer<br/>[render.c]"]
  node_score_text["Score typography<br/>[num.c]"]
  node_sprite_tools["Sprite tools<br/>[sprite.c]"]
  node_assets["Image data"]
end

subgraph group_model["Game model"]
  node_entities["Entity model<br/>[entity.c]"]
  node_primitives["Points and pixels<br/>[point.h]"]
end

node_player(("Player"))
node_linux_input["Linux input device"]
node_display["Linux framebuffer"]

node_player -->|"provides input"| node_keyboard
node_keyboard -.->|"reads events"| node_linux_input
node_main_loop -->|"updates input"| node_keyboard
node_main_loop -->|"initializes and draws"| node_framebuffer
node_main_loop -->|"draws score"| node_score_text
node_main_loop -->|"maps display"| node_display
node_framebuffer -.->|"copies pixels"| node_display
node_main_loop -->|"maps image"| node_assets
node_entities -->|"uses positions"| node_primitives
node_entities -->|"uses sprites"| node_sprite_tools
node_sprite_tools -.->|"draws sprites"| node_framebuffer

click node_main_loop "https://github.com/marvelous616/pong/blob/main/src/main.c"
click node_keyboard "https://github.com/marvelous616/pong/blob/main/src/inp_event.c"
click node_framebuffer "https://github.com/marvelous616/pong/blob/main/src/render.c"
click node_score_text "https://github.com/marvelous616/pong/blob/main/src/num.c"
click node_sprite_tools "https://github.com/marvelous616/pong/blob/main/src/sprite.c"
click node_assets "https://github.com/marvelous616/pong/blob/main/468x897_hand_dithered_1_bit.data"
click node_entities "https://github.com/marvelous616/pong/blob/main/src/entity.c"
click node_primitives "https://github.com/marvelous616/pong/blob/main/include/point.h"

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_loop toneBlue
class node_keyboard toneAmber
class node_framebuffer,node_score_text,node_sprite_tools,node_assets toneMint
class node_entities,node_primitives toneRose
class node_player,node_linux_input,node_display toneIndigo
```

## Components

### Game

- [Game loop](https://github.com/marvelous616/pong/blob/main/src/main.c): `src/main.c`

### Input

- [Keyboard events](https://github.com/marvelous616/pong/blob/main/src/inp_event.c): `src/inp_event.c`

### Graphics

- [CPU framebuffer](https://github.com/marvelous616/pong/blob/main/src/render.c): `src/render.c`
- [Score typography](https://github.com/marvelous616/pong/blob/main/src/num.c): `src/num.c`
- [Sprite tools](https://github.com/marvelous616/pong/blob/main/src/sprite.c): `src/sprite.c`
- [Image data](https://github.com/marvelous616/pong/blob/main/468x897_hand_dithered_1_bit.data): `468x897_hand_dithered_1_bit.data`

### Game model

- [Entity model](https://github.com/marvelous616/pong/blob/main/src/entity.c): `src/entity.c`
- [Points and pixels](https://github.com/marvelous616/pong/blob/main/include/point.h): `include/point.h`

### Other components

- **Player**
- **Linux input device**
- **Linux framebuffer**

## Connections

- Player → Keyboard events: provides input (evidence: `README.md`)
- Keyboard events → Linux input device: reads events
- Game loop → Keyboard events: updates input (evidence: `src/main.c`)
- Game loop → CPU framebuffer: initializes and draws (evidence: `src/main.c`)
- Game loop → Score typography: draws score (evidence: `src/main.c`)
- Game loop → Linux framebuffer: maps display (evidence: `src/main.c`)
- CPU framebuffer → Linux framebuffer: copies pixels
- Game loop → Image data: maps image (evidence: `src/main.c`)
- Entity model → Points and pixels: uses positions
- Entity model → Sprite tools: uses sprites
- Sprite tools → CPU framebuffer: draws sprites
