How lissmann/pong works
Pong is a browser-based JavaScript game: players use keyboard controls to play, rallies update the score, and the first player to five wins. The app entry point creates the game; its main loop advances game state, moves and draws the ball and paddles, checks collisions, and renders the scoreboard. Keyboard and scoring events drive state changes and winner messages. The README also describes a cheap computer opponent, implemented as right-paddle movement in the game loop. Message implementation details are unsampled; its path is supported by the tree.
Main entry points: EventHandler.js Input and scoring · Pong.js Game loop · Factory.js Object factory · Ball.js Ball
Components 14
Game runtime
- App entry
src/main.js - Game loop
src/classes/Pong.js - Input and scoring
src/classes/events/EventHandler.js - Game state
src/classes/enumerations/State.js - Game settings
src/classes/enumerations/Settings.js
Game objects
- Object factory
src/classes/drawables/Factory.js - Drawable base
src/classes/drawables/Drawable.js - Ball
src/classes/drawables/Ball.js - Paddles
src/classes/drawables/Paddle.js - Scoreboard
src/classes/drawables/Scoreboard.js - Game messages
src/classes/drawables/Message.js
Browser presentation
- Game canvas
index.html - Game styling
src/styles/pong.css
Other components
- Player
Connections 26
- Player → Input and scoring: presses keys
- App entry → Game loop: creates
- Game loop → Object factory: creates objects
- Game loop → Input and scoring: initializes
- Object factory → Game settings: reads settings
- Object factory → Game canvas: gets context
- Object factory → Ball: creates
- Object factory → Paddles: creates
- Object factory → Scoreboard: creates
- Object factory → Game messages: creates
- Ball → Drawable base: extends
- Paddles → Drawable base: extends
- Scoreboard → Drawable base: extends
- Game loop → Game state: checks state
- Game loop → Ball: draws and resets
- Game loop → Paddles: draws and moves
- Game loop → Scoreboard: draws
- Game loop → Game messages: shows intro
- Input and scoring → Game state: advances state
- Input and scoring → Ball: starts rally
- Input and scoring → Paddles: controls
- Input and scoring → Scoreboard: updates score
- Input and scoring → Game messages: shows winner
- Ball → Input and scoring: dispatches score
- Input and scoring → Game canvas: listens for score
- Game styling → Game canvas: styles