How mathuska/ship-game works
This is a browser-based, Three.js arcade game: players rotate to landscape, then control a ship through a 3D world containing generated obstacles and asteroid fields, with score and game-state controls. The graph follows the app-to-game entry and the documented component references; sampled code confirms the obstacle generation and asteroid behavior. Several visual components and game features are only indexed, not excerpted, so their internal behavior and some connections are omitted.
Main entry points: Obstacles.tsx Obstacle generation · useGameStore.ts Game state · Game2.tsx Game scene and HUD · World.tsx World composition
Components 25
App and game
- Orientation gate
src/App.tsx - Telegram wrapper
src/components/TelegramWebApp.tsx - Game scene and HUD
src/games/Game2.tsx
3D world
- World composition
src/components/game2/World.tsx - Scrolling floor
src/components/game2/Floor.tsx - Obstacle generation
src/components/game2/Obstacles.tsx - Box obstacle
src/components/game2/obstacles/Box.tsx - Cylinder obstacle
src/components/game2/obstacles/Cylinder.tsx - Obstacle instances
src/components/game2/obstacles/ObstacleInstances.tsx - Asteroid field
src/components/AsteroidField.tsx - Asteroid models
src/objects/Aster2_5.tsx - Asteroid variants
src/objects/Aster2-1.tsx - Custom stars
src/components/game2/CustomStars.tsx - Collectibles
src/components/game2/Collectibles.tsx
Gameplay and controls
- Player ship
src/ships/Ship1.tsx - Camera follow
src/components/CameraController.tsx - Device orientation
src/hooks/useDeviceOrientation.tsx - Asteroid motion
src/hooks/useAsteroidLogic.tsx - Procedural asteroid
src/components/RandomAsteroid.tsx - Perlin noise
src/lib/perlin-noise.ts
State and generation
- Game state
src/stores/useGameStore.ts - Game settings
src/stores/useSettingsStore.ts - Generation logic
src/hooks/useGenerateLogic.tsx - Random range
src/utils/getRandomInRange.ts
Other components
- Player
Connections 30
- Player → Orientation gate: opens
- Orientation gate → Telegram wrapper: wraps
src/App.tsx - Orientation gate → Game scene and HUD: renders
src/App.tsx - Game scene and HUD → Player ship: renders
src/games/Game2.tsx - Game scene and HUD → Camera follow: renders
src/games/Game2.tsx - Game scene and HUD → World composition: renders
src/games/Game2.tsx - Game scene and HUD → Game state: reads and updates
src/games/Game2.tsx - World composition → Scrolling floor: renders
src/components/game2/World.tsx - World composition → Obstacle generation: renders
src/components/game2/World.tsx - World composition → Asteroid field: renders
src/components/game2/World.tsx - World composition → Custom stars: renders
src/components/game2/World.tsx - Obstacle generation → Box obstacle: renders
src/components/game2/Obstacles.tsx - Obstacle generation → Cylinder obstacle: renders
src/components/game2/Obstacles.tsx - Obstacle generation → Generation logic: generates with
src/components/game2/Obstacles.tsx - Obstacle generation → Game state: stores references
src/components/game2/Obstacles.tsx - Obstacle generation → Game settings: reads
src/components/game2/Obstacles.tsx - Asteroid field → Generation logic: generates with
src/components/AsteroidField.tsx - Asteroid field → Asteroid models: renders
src/components/AsteroidField.tsx - Asteroid field → Asteroid variants: renders
src/components/AsteroidField.tsx - Player ship → Device orientation: reads input
src/ships/Ship1.tsx - Player ship → Game state: uses state
src/ships/Ship1.tsx - Camera follow → Game state: reads ship reference
src/components/CameraController.tsx - Asteroid models → Asteroid motion: uses
src/objects/Aster2_5.tsx - Asteroid motion → Game state: reads and updates
src/hooks/useAsteroidLogic.tsx - Asteroid motion → Game settings: reads
src/hooks/useAsteroidLogic.tsx - Asteroid motion → Random range: samples range
src/hooks/useAsteroidLogic.tsx - Generation logic → Game settings: reads
src/hooks/useGenerateLogic.tsx - Generation logic → Random range: samples range
src/hooks/useGenerateLogic.tsx - Procedural asteroid → Perlin noise: uses
src/components/RandomAsteroid.tsx - Procedural asteroid → Game state: uses state
src/components/RandomAsteroid.tsx