Skip to content

A Simple Game Loop Written in C & SDL, running in the browser thanks to WebAssembly binding it to an HTML5 canvas

License

Notifications You must be signed in to change notification settings

rafaeletc/wasm-sdl-gameloop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wasm-sdl-gameloop License: MIT

A Simple Game Loop Written in C & SDL1 running in the browser thanks to WebAssembly binding it to an HTML5 canvas.

Live demo: https://rafaeletc.github.io/wasm-sdl-gameloop

Installation:

  1. Install Emscripten:
    https://emscripten.org/docs/getting_started/downloads.html

  2. Clone the repository:
    git clone https://github.com/rafaeletc/wasm-sdl-gameloop
    cd wasm-sdl-gameloop

  3. Run make build-wasm or build manually:
    emcc src/*.c -s WASM=1 -s USE_SDL=2 -o public/index.js

  4. Browsers doesn't support file XHR requests so you need to open index.html from a web server.
    Run make run-wasm or manually:
    emrun public/index.html

  5. 🕹️ Use the keys ⬅️ and ➡️ to move the paddle, key R to start again.

  6. You can run on terminal too, with compiler and SDL2 dependencies on place, just hit make build; make run

Captura de tela de 2024-04-03 16-58-20

Todos:

  • Improve Makefile
  • Better physics for the game
  • Build a game interface for pontuation
  • Add a game start scene
  • Add a game over scene

Footnotes

  1. Game design taken from Pikuma's Creating a Game Loop with C & SDL (Tutorial)

About

A Simple Game Loop Written in C & SDL, running in the browser thanks to WebAssembly binding it to an HTML5 canvas

Topics

Resources

License

Stars

Watchers

Forks