How badestrand/theaviator2 works
Project type and purpose
• This is a browser‑based 3D arcade game (“The Aviator 2”) built on top of Three.js and TweenMax.
• There is no separate backend business logic or database—just a static file server (e.g. PHP built‑in server) delivering HTML, CSS, JS, 3D models, and audio assets to the client.
File structure
• Top level:
• index.html – entry point
• game.css – styles
• game.js – the main game script
• audio/ – sound effects (mp3 files)
• models/ – 3D model assets (OBJ/MTL)
• No “src” or “backend” directories, meaning the entire game runs in the browser.
• README lists dependencies: Three.js (WebGL renderer) and TweenMax (animations).
README for additional insights
• Describes how to serve the project with php -S (or any static file server).
• Credits the libraries and audio sources.
• Mentions game features: levels, collectibles, enemies, audio integration, and state handling.
Main components & their relationships
a. Components:
1. Static File Server
• Serves index.html, CSS, JS, audio, and model files over HTTP.
2. Browser Client
• HTML/CSS layer (UI overlay, score, life hearts)
• JavaScript Game Engine (game.js)
• Asset Loader (XHR/Fetch or Three.js loaders for models & audio)
• Scene Manager (Three.js WebGLRenderer, Camera, Scene graph)
• Input Manager (keyboard/mouse or touch)
• Physics & Collision Handler (basic collision detection)
• Audio Manager (HTML5 Audio or Web Audio API)
• Tween Manager (TweenMax for transitions)
3. Assets
• 3D Models: heart.obj/.mtl
• Audio Files: sound effects under /audio
b. Interactions:
• Browser sends HTTP GETs to the Static File Server to load index.html, CSS, JS, models, and audio.
• game.js initializes Three.js renderer, loads models & sounds, and enters the game loop.
• Input events flow from user → Input Manager → Game Engine
• Game state updates fire rendering passes → Scene Manager draws to canvas
• Audio Manager plays sound effects on events (coin collected, crash, shot, etc.)
• TweenMax drives UI and game object animations.
Architectural patterns & design principles
• Modular client‑side architecture: separate concerns (Asset Loading, Rendering, Input, Audio, Tweening).
• Event‑driven game loop: update → render → requestAnimationFrame.
• Use of external libraries (Three.js for rendering, TweenMax for animations) avoids reinventing core functionality.
Essential elements
• Labels for every component and sub‐component.
• A note on external libraries integrated into the game engine.
1) Static File Server
2) Browser Client (HTML/CSS + JS Game Engine + Third‑party libs)
3) Assets (models + audio)