A ball is bouncing around the canvas while background music is played. A sound effect played when the ball hits a wall.
Checkout the Demo.
- Emscripten SDK
- git
- Checkout project:
git clone --recursive https://github.com/AlbertVeli/wasm_sdl2_test
cd wasm_sdl2_test
make
python -m SimpleHTTPServer 8080
- or
emrun --no_browser --port 8080 .
(add --emrun to linker flags to run this way) - Visit http://localhost:8080/
- Audio API - Emscripten only supports SDL_mixer 1. Can be used together with SDL2.
- https://github.com/timhutton/sdl-canvas-wasm - Even more minimal example than this
- I only got file loading to work together with emscripten by adding --preload-file to CFLAGS. This in turn only works with the
_RW
versions of the load files. LikeMix_LoadWAV_RW(SDL_RWFromFile("assets/bounce.ogg", "rb"), 1);
. - To preload all files in the assets directory
--preload-file assets
is added to CFLAGS (in Makefile). - Ogg vorbis support is added automatically to SDL_mixer by adding
-s USE_OGG=1 -s USE_VORBIS=1
to CFLAGS.
~~=) All Rights Reversed - No Rights Reserved (=~~
Boomtime, the 41st day of Confusion in the YOLD 3184
Albert Veli