Skip to content

Pong - 2D Game Example

Similar to the balls example, this example uses twr-wasm's 2D Draw API and a C++ canvas class to implement a simple game of 2 player and single player Pong with WebAssembly.

The Pong example demonstrates

  • C++
  • Using twr-wasm draw 2D APIs that match Javascript Canvas APIs.
  • Using the twr-wasm canvas.cpp class.
  • A custom typescript library
  • User mouse and keyboard input via events
  • Using the Audio Library to play simple sounds

This example does not use libc++, which results in smaller code size. For an example that uses libc++ see tests-libcxx.

Screen Grab of Pong Example