# Pong [Play Demo](/demos/game_pong.html) Build a classic Pong game demonstrating input actions, collision detection, signals, and game state management. ## What You Will Learn - **Input actions** -- Bind keys to named actions with `InputMap.add_action()` - **Input.get_strength()** -- Read analogue input strength for smooth movement - **Signals** -- Decouple game events (the ball emits `scored` when it passes a paddle) - **Collision** -- Manual AABB overlap for paddle-ball bouncing - **Game state** -- Track and display scores ## Controls | Key | Action | |-----|--------| | W / S | Left paddle up / down | | Up / Down | Right paddle up / down | ## How It Works Three node types compose the game: - **Paddle** reads two input actions (up/down) and clamps position to the screen - **Ball** moves at a velocity, bounces off top/bottom edges, and emits a `scored` signal when it exits left or right - **PongGame** (root) creates paddles and ball in `ready()`, connects the `scored` signal to update the score, and handles paddle-ball collision in `process()` by reflecting the ball's velocity based on where it hits the paddle Input actions are registered in `__main__` via `InputMap.add_action()`, mapping physical keys (`Key.W`, `Key.S`, `Key.UP`, `Key.DOWN`) to named actions that the paddle nodes query each frame. ## Source Code ```{literalinclude} ../../packages/graphics/examples/game_pong.py :language: python :linenos: ```