How naskarepo/demos works
This repository is a set of three Windows-oriented terminal animation demos: granular materials, flocking boids, and a vortex. Each demo initializes its own simulation, updates it in a loop, and renders frames; the sand demo additionally accepts keys to move a spawner and create materials. Shared utilities handle keyboard input, 2D maps, and incremental frame rendering. The README and sampled files establish these flows; the demos otherwise operate independently.
Main entry points: keyboard.py Keyboard thread · frameBuffer.py Frame buffer · map2d.py 2D map helpers · sand.py Sand simulation
Components 10
Simulation demos
- Sand simulation
sand.py - Flocking simulation
flocking.py - Vortex simulation
vortex.py
Shared utilities
- Keyboard thread
utils/keyboard.py - Key decoder
utils/getKey.py - 2D map helpers
utils/map2d.py - Frame buffer
utils/frameBuffer.py
Terminal and input
- Windows key input
- Terminal display
Other components
- Keyboard user
Connections 18
- Keyboard user → Windows key input: presses keys
- Windows key input → Key decoder: provides key bytes
- Sand simulation → Keyboard thread: starts input thread
- Flocking simulation → Keyboard thread: starts input thread
- Vortex simulation → Keyboard thread: starts input thread
- Keyboard thread → Key decoder: reads keys
- Keyboard thread → Sand simulation: dispatches callback
- Keyboard thread → Flocking simulation: dispatches callback
- Keyboard thread → Vortex simulation: dispatches callback
- Sand simulation → 2D map helpers: creates and swaps
- Flocking simulation → 2D map helpers: creates map
- Vortex simulation → 2D map helpers: creates map
- Sand simulation → Frame buffer: draws frames
- Flocking simulation → Frame buffer: draws frames
- Vortex simulation → Frame buffer: draws frames
- Frame buffer → 2D map helpers: prints initial map
- 2D map helpers → Terminal display: prints map
- Frame buffer → Terminal display: prints changed cells