How cisa-cell/pastanation works
Project Type and Purpose
• This is a single‐page, client‐side web game built with Phaser 3 and bundled via Vite.
• Its purpose is to run in the browser, load scenes, assets (audio, sprites, fonts), and deliver an interactive game experience.
High-Level File Structure Analysis
• Top-level:
• package.json / node_modules – dev dependencies (Phaser, Vite) and scripts.
• log.js – optional telemetry script.
• vite/config.dev.mjs & config.prod.mjs – Vite build configurations.
• index.html & public/style.css – host template and global styles.
• public/assets – static assets served in dev and copied to dist.
• src/main.js – game bootstrap (Phaser config & entry point).
• src/scenes – all Phaser Scenes (MainMenu, PreLoader, Game, GameOver, plus level-1 subfolder with intros and Outro).
• dist – production build output (bundled JS, CSS, and copied assets).
Core Components
a. Developer Environment
– Source code (src folder)
– Static assets (public/assets)
– Vite Dev Server (hot‐reload, local file watcher)
– log.js telemetry call to external API
b. Build Pipeline
– Vite config (dev vs. prod)
– npm run dev / npm run build scripts
– Output: dist/ (index.html, style.css, assets, hashed JS bundles)
c. Browser Runtime
– index.html loads CSS & JS bundle
– Phaser Engine initializes using config from main.js
– Scene Manager cycles through PreLoader → MainMenu → Game → GameOver (and level-1 intros/outro)
– AssetLoader loads fonts, audio, sprites from bundled imports or assets folder
d. External Services
– Optional telemetry endpoint at gryzor.co triggered by log.js
Relationships and Interactions
• Dev Machine: invokes Vite Dev Server → serves index.html + public assets + in‐memory JS bundles → browser
• Build: Vite reads src/, public/assets → applies plugins (JS transpile, CSS, asset inlining) → writes dist/
• Browser:
• index.html references dist/assets/index-*.js and style.css
• Phaser instantiates Game object → uses Scene modules
• Scenes call this.load to fetch assets (bundled or from dist/assets)
• Scenes push/pop in Phaser’s scene graph (directional flow)
• Telemetry (if enabled): log.js sends “template, env, Phaser version” via HTTP request
Architectural Patterns & Design Principles
• Modular Scene Pattern: each game state is encapsulated in its own JS class (PreLoader, MainMenu, etc.).
• Asset Pipeline Separation: code assets vs. static assets; code imports vs. public folder loads.
• Dev vs. Prod Config Branching: separate Vite configs for speed/hot-reload vs. optimization.
• Single‐Page‐App (SPA): one HTML entry point, dynamic scene switching.