How sebaw65/rocket_game works
Project Type and Purpose
• Project type: A browser-based 2D game built with TypeScript and ECS (Entity‑Component‑System) architecture.
• Purpose: Simulate and render a cellular‑automata‑driven environment (“rocket” game) in a canvas context, processing user input, physics, and rendering in a game loop.
File Structure
Top‑level folders & files:
• public/index.html – Hosts the canvas and bootstraps the game.
• src/
– core/application/GameApplication.ts – The central game loop and system orchestrator.
– components/… – Definitions of ECS components (e.g. InputComponent, PositionComponent, RenderComponent).
– entities/Entity.ts – Base entity class holding components.
– systems/… – Distinct systems grouped by concern:
· input/MouseSystem.ts
· physics/CellularAutomataSystem.ts, GravitySystem.ts
· rendering/CanvasSystem.ts, RenderSystem.ts, ResizeSystem.ts
– main.ts – Entry point that instantiates GameApplication.
README
• Confirms ECS architecture, Canvas API for rendering, cellular automata for simulation.
• No external backend or microservice layer – it’s pure front end with a rendering engine.
a) Main Components
1) Entry Point (main.ts)
2) GameApplication (core) – orchestrator & loop
3) Entity Store – holds all Entity instances
4) Component Registry – available component types
5) Systems:
• Input System (MouseSystem)
• Physics Systems (CellularAutomataSystem, GravitySystem)
• Rendering Systems (CanvasSystem, RenderSystem, ResizeSystem)
6) Canvas Context (HTML5 Canvas)
7) Browser/Event Layer (DOM events for input & resize)
b) Relationships and Interactions
1) main.ts → GameApplication (initialization)
2) GameApplication registers Systems & Entities
3) Game loop tick:
• Input System reads DOM events → updates InputComponents
• Physics Systems read PositionComponent & neighbor data → mutate PositionComponent
• CanvasSystem issues actual Canvas API calls to HTML5 Canvas
4) Resize System listens to window resize events → updates Canvas dimensions
5) Entities act as data carriers; Components are plain data
c) Architectural Patterns & Principles
• ECS: Decoupling of data (Components) and logic (Systems)
• Single Responsibility: Each System focuses on one concern (input, physics, rendering)
• Dependency Injection: GameApplication injects references to Systems & Entity store
d) Key Technologies & Frameworks
• TypeScript + ES Modules
• Vite (build & dev server)
• Canvas API for rendering
• Cellular Automata algorithm in physics