How foxzool/jigsaw_puzzle works
Project type and purpose
• This is a standalone, single‐binary game application written in Rust using the Bevy game engine.
• It also includes a companion library crate (jigsaw_puzzle_generator) that implements the core puzzle‐piece generation algorithm.
• The game compiles to native and to WebAssembly (build/web) for browser deployment (index.html + sound.js + styles.css).
Main components of the system
a. Bevy Game Engine (ECS runtime)
b. Game Code (main binary crate)
• Entry point (src/main.rs)
• Game logic modules: main_menu.rs, gameplay.rs, lib.rs
c. Puzzle‐Piece Generator Library (jigsaw_puzzle_generator)
• Core algorithm in src/lib.rs
• Example generator in examples/generator.rs
d. Asset Server/Loader
e. Web Target & Static Host
• build/web: compiled WASM + support JS/CSS
• index.html for embedding WASM
f. CI / CD Pipeline
• GitHub Actions workflows: ci.yaml, deploy-page.yaml
Relationships and data flow
• At startup (main.rs), the Bevy App builder loads plugins and resources.
• The Main Menu system handles input events (keyboard, UI) to transition to the Gameplay state.
• Generated puzzle‐piece meshes and textures are passed back to Bevy as entities + components.
• Player interactions (drag/drop) are captured by Bevy input systems and drive the ECS update loop.
• On Web target, Rust → WASM via wasm32-unknown-unknown build; sound.js and styles.css support audio + styling.
• GitHub Actions: ci.yaml runs build/tests on PR; deploy-page.yaml publishes build/web to GitHub Pages.
Architectural patterns & design principles
• Entity Component System (ECS) at the core (Bevy)
• Plugin / State‐Driven architecture: separate systems by game state (Menu vs. Gameplay)
• Modularization: a dedicated crate (jigsaw_puzzle_generator) for puzzle logic, easily testable and reusable
• Target abstraction: same codebase → native and WebAssembly targets