How rohanchacko/subway-surfers works
Subway Surfers is a browser-based WebGL endless-runner. The player opens the game, steers or jumps between lanes, collects coins and boosts, and avoids obstacles while the world scrolls; coin score can trigger the finish-line sequence. The graph separates game orchestration, runner rules, world and pickups, and rendering support. Main-loop calls and several entity behaviors are evidenced by sampled source; additional documented features, including textured objects, lighting, and background music, are represented without asserting unsampled wiring.
Main entry points: main.js Game loop · player.js Player · draw.js Scene renderer · game.html WebGL canvas
Components 18
Game runtime
- Game loop
src/main.js - Game utilities
src/utility.js
Runner gameplay
- Player
src/player.js - Police pursuer
src/police.js - Keyboard input
src/keyhandler.js
World and pickups
- Train obstacles
src/obstacle.js - Barriers
src/barrier.js - Coin scoring
src/coin.js - Power-ups
src/boost.js - Track segments
src/track.js - Ground
src/ground.js - Track walls
src/wall.js - Finish line
src/finishline.js
Rendering and assets
- Scene renderer
src/draw.js - Camera
src/camera.js - Texture loading
src/texture.js - Background music
assets/bgmusic.mp3
Other components
- WebGL canvas
game.html
Connections 20
- WebGL canvas → Game loop: starts game
- Keyboard input → Player: sets key state
- Game loop → Player: updates
- Game loop → Police pursuer: updates
- Game loop → Barriers: ticks
- Game loop → Coin scoring: ticks
- Game loop → Power-ups: ticks
- Game loop → Track segments: ticks
- Game loop → Ground: ticks
- Game loop → Train obstacles: spawns
- Game loop → Finish line: ticks at score
- Game loop → Scene renderer: draws scene
- Scene renderer → WebGL canvas: renders frames
- Scene renderer → Camera: uses view setup
- Player → Coin scoring: collects for score
- Player → Power-ups: activates
- Player → Train obstacles: collision ends run
- Barriers → Police pursuer: sets back
- Finish line → Player: checks score
- Texture loading → WebGL canvas: loads textures