Files
logic-gates/js/state.js
Jose Luis b2e367817c feat: add Turing Complete-style puzzle system
Add progressive puzzle mode alongside the existing sandbox:
- 8 levels from basic gates to 2-bit adder
- Truth table verification with pass/fail feedback
- Gate restrictions per level
- Custom components system (save circuits as reusable chips)
- Save/load circuits as JSON
- Level selection sidebar with difficulty ratings
- Mode toggle: Sandbox (free play) vs Puzzle (guided levels)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 02:06:57 +01:00

41 lines
850 B
JavaScript

// Shared application state — single source of truth
export const state = {
// Circuit
gates: [],
connections: [],
nextId: 1,
// Interaction
placingGate: null,
dragging: null,
dragOffset: { x: 0, y: 0 },
connecting: null,
hoveredGate: null,
hoveredPort: null,
mouseX: 0,
mouseY: 0,
// Camera (pan/zoom)
camX: 0,
camY: 0,
zoom: 1,
// Waveform
waveformVisible: false,
waveformHeight: 220,
recording: true,
waveData: {}, // { gateId: [{ t, value }] }
timeStep: 0,
waveZoom: 20, // pixels per time step
waveScroll: 0,
resizingWave: false,
// Simulation
simRunning: false,
simInterval: null,
simSpeed: 500, // ms per tick
// Puzzle/Components
customComponents: {} // { id -> component definition }
};