How h-sofie/maodie-runner works
Project type and purpose
• This is a small, static, single-page web application: a fork of the Chrome T-Rex-runner offline game, packaged as a self-contained HTML/CSS/JS bundle and served from a static web server (for example GitHub Pages).
File structure
• Top-level:
• index.html – the entry point
• README.md, LICENSE – documentation
• src/ – all game assets and code
• src/ subdirectories and files:
• src/offline.js – the core game engine (Runner class, input handlers, game loop)
• src/styles.css – all the CSS rules for the game UI
• src/sounds/... – MP3 files (button-press, hit, reached)
• No backend code or API layers—purely client-side.
Extract insights from the README
• The project is a trimmed-down extraction from Chromium’s neterror page.
• All external dependencies have been inlined or removed, making this a zero-dependency, static deliverable.
Main components and their interactions
a. Static HTTP Server
– Serves index.html, offline.js, styles.css, images, and sounds over HTTP(S).
b. Web Browser (Client)
– Resource Loader: issues HTTP GETs for index.html, CSS, JS, images, sounds.
– DOM & CSSOM: index.html + styles.css → layout and render tree.
– JavaScript Engine: executes offline.js → instantiates new Runner('.interstitial-wrapper') → initializes the game loop.
– Canvas/DOM Subtree: game visuals are painted.
– Asset Manager: preloads sprites and sounds into memory.
c. Game Engine (offline.js)
– Input Handler: listens for keyboard/touch to start/restart the game.
– Game Loop: updates obstacles, dinosaur sprite, collision detection, score.
– Sound Controller: plays button-press, hit, reached sounds at events.
Architectural patterns and principles
• Static front-end architecture (“JAMstack”–style): all logic runs in the browser, no server-side processing.
• Single Responsibility:
• offline.js → game logic
• styles.css → presentation
• index.html → application shell
• Asset bundling: images and sounds are loaded separately but referenced inlined or via paths.