Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Build Paddle

In this tutorial, you’ll build a complete Paddle game from scratch. By the end, you’ll have a fully playable game with:

  • Two paddles (player-controlled or AI)
  • Ball physics with collision detection
  • Score tracking and win conditions
  • Sound effects
  • Title screen and game over states
  • Automatic online multiplayer via Emberware’s rollback netcode

Paddle game preview

What You’ll Learn

PartTopics
Part 1: Setup & DrawingProject creation, FFI imports, draw_rect()
Part 2: Paddle MovementInput handling, game state
Part 3: Ball PhysicsVelocity, collision detection
Part 4: AI OpponentSimple AI for single-player
Part 5: MultiplayerThe magic of rollback netcode
Part 6: Scoring & Win StatesGame logic, state machine
Part 7: Sound EffectsProcedural audio
Part 8: Polish & PublishingTitle screen, publishing to archive

Prerequisites

Before starting this tutorial, you should have:

Final Code

The complete source code for this tutorial is available in the examples:

emberware/examples/paddle/
├── Cargo.toml
├── ember.toml
└── src/
    └── lib.rs

You can build and run it with:

cd examples/paddle
cargo build --target wasm32-unknown-unknown --release
ember run target/wasm32-unknown-unknown/release/paddle.wasm

Time Investment

Each part takes about 10-15 minutes to complete. The full tutorial can be finished in about 2 hours.


Ready? Let’s start with Part 1: Setup & Drawing.