How chieri-jn/zenmode works
Project type and purpose
• ZenMode is a standalone, client-side desktop game written in Python.
• It uses the CMU 15-112 graphics framework (cmu_112_graphics.py) to render screens and handle user events.
• The game logic revolves around a “zen” quiz, word-collection gameplay (synonyms/antonyms), and multiple screens (start, quiz, game, pause, help, win/loss).
File structure
Top-level files and folders:
• Main.py – entry point; defines screens, event handlers, game loop
• cmu_112_graphics.py – graphics & UI engine (event loop, drawing callbacks)
• classes.py – game-domain classes (e.g., Word objects, Player state, maybe fractal tree generator)
• dictionaries.py – word lists (synonyms, antonyms) and data structures to look them up
• drawings.py – drawing routines for custom graphics (fractal tree, UI widgets)
• slimeSprites/ – image assets for word “slimes” and UI elements
• README.md & demo-video.txt – documentation
Key insights from the README
• Libraries: only PIL (for image handling) and cmu_112_graphics.
• No network, no database—everything is file-based and in-memory.
• Users navigate between screens via keyboard; game state is advanced in response to key events.
Main components
1. Frontend / UI Engine
– CMU_112_Graphics Framework (cmu_112_graphics.py)
• Event Loop & Event Dispatcher
• Canvas Manager & Drawing API
2. Application Controller
– Main.py
• Screen Manager (Start, Quiz, Game, Pause, Help, Win/Loss)
• Keyboard & Mouse Event Handlers
• State Machine Transitions
3. Game Logic Layer
– classes.py
• Data Models: PlayerState, WordItem, ZenQuiz, FractalTree
• Game Rules Engine: collision detection, point updates
4. Domain Data / Resources
– dictionaries.py
• Synonym & Antonym Data Structures
– slimeSprites/
• Image assets loaded via PIL
– texts_colours.py
– drawings.py
• Helper functions for drawing fractal trees, backgrounds, UI elements
5. External Library
– PIL (Python Imaging Library)
Relationships and data flows
• User Input (keyboard) → CMU Graphics Event Loop → Main.py handler
• Main.py → updates Game State via classes.py → queries dictionaries.py → returns word buckets
• CMU Graphics → renders frames → user sees updated UI on screen
• Asset loading: slimeSprites images are loaded once (at startup or on-demand) via PIL into memory
Architectural patterns & design principles
• Model-View-Controller (MVC) style separation:
– Model: classes.py + dictionaries.py
– View: cmu_112_graphics + drawings.py + texts_colours.py + slimeSprites
– Controller: Main.py orchestrating screens and events
• Event-driven architecture: all user interactions route through the CMU event loop.
• Modular design: each concern (data, drawing, control) lives in its own module.