How hozngvan/endlessrunnergame works
Project type and purpose
• This is a browser-based endless runner game written in JavaScript and delivered as a single-page front-end application. The game logic lives entirely in the client, leveraging an HTML5 canvas or WebGL context (via index.html) and a set of JS modules under the js/ directory. Textures and other assets live in the textures/ folder.
File structure
• index.html
• Entry point: declares the canvas, includes your bundled or individual JS files
• js/
• main.js: game initialization, asset loading, start of the game loop
• game.js: orchestrates the game loop (update, render)
• world.js: world‐building logic, ground tiling, environment generation
• obstacleManager.js: generates, spawns and recycles obstacles
• player.js: handles player state, input and collision checks
• ui.js: draws on‐screen UI (score, game over, menus)
• textures/: PNGs, JPEGs, material definitions, USD composer files for your 3D/texturing pipeline
Information from the README
• Title “Endless Runner Game” confirms the front-end game nature. No additional architecture notes provided.
a. Main components
• Browser / Canvas Context
• Asset Loader
• Game Loop Manager (game.js)
• World Manager (world.js)
• Obstacle Manager (obstacleManager.js)
• Player Controller (player.js)
• UI Manager (ui.js)
• Renderer
• External textures & material assets
b. Relationships & data flow
1. index.html → loads main.js
2. main.js → Asset Loader → loads textures into GPU
3. main.js → instantiates Game Loop Manager
4. Game Loop Manager each tick:
– reads user Input → Player Controller → updates player state
– invokes World Manager → extends ground, recycles old tiles
– invokes Obstacle Manager → spawns/moves obstacles, checks collisions
– invokes UI Manager → updates score, displays status
– sends updated scene graph to Renderer → draws frame to Canvas
5. Texture files → consumed by Asset Loader → provided to Renderer
c. Architectural patterns & design principles
• Modular single-page architecture: each JS file encapsulates a core subsystem
• Central game loop dispatching update & render calls (typical game-engine pattern)
• Separation of concerns: world generation, obstacle handling, player logic, UI rendering
d. Key technologies
• Vanilla JavaScript (ES6 modules or namespaces)
• HTML5 Canvas or WebGL context in index.html
• Asset format: JPG, USD Composer (.usdc), MaterialX (.mtlx)
• (Optional) Build tool (webpack/parcel) as indicated by package.json
Recommendation
• Be precise in naming each module exactly as in the js/ directory
• Textures folder as an external asset source feeding into the Asset Loader