A modular text adventure game engine with voice interaction using:
- React + Vite + TypeScript
- Pixi.js for graphics rendering
- PWA service worker via
vite-plugin-pwa - Capacitor (iOS/Android support)
- Web Speech API for voice input/output
- Deterministic rule-based game logic
- GitHub Pages deploy via Actions
- Testing via Vitest + Testing Library
npm install
npm run devsrc/
├── types.ts # TypeScript type definitions
├── App.tsx # Main React component (PixiJS integration)
├── main.tsx # React entry point
├── styles.css # Global styles
├── utils/
│ ├── lexicons.ts # Word category mappings
│ ├── parser.ts # Natural language parser
│ ├── speech.ts # Text-to-speech utilities
│ ├── audio.ts # Recording & speech recognition
│ └── pixi.ts # PixiJS graphics utilities
├── engine/
│ └── engine.ts # Rule processing engine
├── data/
│ └── replies.ts # Game response text database
├── rooms/
│ ├── BaseRoom.ts # Abstract room class
│ └── Scene2Room.ts # Junk Bay room implementation
└── game/
└── Game.ts # Game orchestration & global rules
tests/
├── parser.test.ts # Parser logic tests
├── engine.test.ts # Game engine tests
├── speech.test.ts # Speech utilities tests
├── audio.test.ts # Audio recording tests
├── pixi.test.ts # PixiJS utilities tests
├── room.test.ts # Room system tests
└── game.test.ts # Game class tests
The codebase is organized into distinct, testable modules:
-
Utilities (
src/utils/): Reusable functionality- Lexicons for natural language understanding
- Parser for command tokenization
- Speech synthesis and recognition
- Audio recording management
- PixiJS helper functions
-
Engine (
src/engine/): Core game logic- Rule processing system
- State management (context, flags, counters)
- Variant selection for response diversity
-
Room System (
src/rooms/): Scene-specific logicBaseRoom: Abstract interface for all roomsScene2Room: Current junk bay implementation- Each room defines: background, rules, lexicons, flags
-
Game Class (
src/game/): Orchestration layer- Combines global + room-specific rules
- Manages room transitions
- Processes player commands
-
Data (
src/data/): Content database- Response text strings
- Separated from logic for easy content updates
npm test # Run tests in watch mode
npm test -- --run # Run tests once
npm run test:ui # Open Vitest UIAll core modules have comprehensive test coverage.
- In dev, the PWA plugin is enabled so you can validate SW registration
- In production, the SW is generated at build time
- Offline caching supports up to 4MB files
After install:
npx cap init
npm run build
npx cap add ios
npx cap add android
npm run cap:syncThen open the native project:
npm run cap:open:ios # Opens Xcode
npm run cap:open:android # Opens Android StudioAutomated deployment via GitHub Actions:
- Update
basein vite.config.ts to your repo name - In GitHub: Settings → Pages → set source to "GitHub Actions"
- Push to
mainbranch triggers build & deploy
- No AI/LLM - purely rule-based
- ~100 priority-sorted rules
- Natural language parsing via lexicons
- Pronoun resolution using focus tracking
- Deterministic variant cycling for response diversity
Each room is a self-contained module with:
- Background image path
- Room-specific nouns, verbs, adjectives
- Custom rules for interactions
- Default scene flags
- Create class extending
BaseRoom - Define lexicons, rules, background
- Add to Game class room registry
See src/rooms/Scene2Room.ts for example.
- PixiJS Integration: React manages lifecycle, PixiJS handles rendering
- Memory Management: Always destroy PixiJS resources on unmount
- Type Safety: Strict TypeScript enabled throughout
- Browser Compat: ES2022 target, modern browsers only
- Web Speech API: Chrome/Edge/Safari (fallback messages for others)
MIT