How sebsowter/phaser-simple-soccer works
Project Type & Purpose
• This is a single‐page browser game built with Phaser (a JavaScript/TypeScript game framework).
• It implements Chapter 4 of “Programming Game AI by Example” (a simple soccer simulation).
• It has no server side; it is a static web application bundled via Webpack and deployed (for example) to GitHub Pages.
High‐Level Components
a. Build Pipeline
• TypeScript source files (src/js/…)
• Webpack (webpack.config.js)
• tsconfig.json for compilation settings
→ Produces a bundled JavaScript file (bundle.js) and copies assets.
b. Static Hosting
• index.html loads the bundle & assets at runtime
• assets/images (sprites, textures)
c. Runtime Engine
• Phaser library (external dependency, included via package.json)
• LoaderScene (preloads images, audio)
• PitchScene (main game loop)
d. Game Modules
• constants (physics, players, teams)
• types (shared TypeScript types)
• utils (helper functions)
• gameObjects (FieldPlayer, Goal, Ball, Team, Score, SupportSpots, etc.)
• PlayerFactory (builds players on demand)
e. Data Flow & Interactions
• index.html → bundle.js → Phaser.Game initialization
• LoaderScene loads assets → transitions to PitchScene
• PitchScene instantiates gameObjects via PlayerFactory & uses constants/types/utils
• GameObjects update and render each frame
Architectural Patterns & Principles
• Modular code organization by feature: constants, types, utils, gameObjects, scenes
• Factory pattern for player creation (PlayerFactory)
• Scene graph pattern (Phaser Scenes manage lifecycle)
• Single‐page static application (no backend)