rust-sdl2-emscripten

This is a demo of a simple program written in Rust using the SDL2 library and compiled to WebAssembly using Emscripten.
The game loop is implemented directly in Rust and uses Emscripten's Asyncify feature, using hooks to Emscripten's emscripten_sleep and emscripten_get_now for sleeping and timing.

Notes

This demo uses all four SDL2 extensions; Image, Mixer, TTF, and GFX.
Builds are available in all major platforms, while Web Assembly is deployed to GitHub pages directly.
Target-specific code is used to handle platform-specific features such as networking and file I/O.
For example, volume is saved to a file on native platforms, while it is saved to local storage on the web (code).
This project was created as a learning experience and test-bed for SDL2+Emscripten in support of my Pac-Man project.

Controls

  • ← ↑ → ↓ Move Sprite
  • space Change Sprite
  • shift + ↑↓ Change Volume