Emscripten is a compiler that allows you to take standard C/C++ and compile it to JavaScript, making it possible to port your C/C++ programs and run them in any modern browser. This tutorial series aims to be your guide and lead you to using the SDL2 library to implement all the basic components of a 2D game; showing an image, moving an image and listening for user input, and enabling you to make a game like this example of ‘snake’ with relative ease in C/C++, all without writing a single line of JavaScript.
The tutorial is broken into the following stages, that take you from an introduction into what Emscripten does to making a customised web-site to host your application:
Introduction to LLVM, Emscripten and asm.js – a discussion of the various tools that will be used and how they work together
Hello World – the Emscripten compiler is downloaded and the classic hello world program written and compiled
Look, Owl – the SDL2 media library is used with Emscripten to display a delightful image of an owl
Move, Owl – upping the complexity level and moving the owl depending on user input
Write Owl – using the SDL2_TTF font rendering library to put some text into the scene
Get Naked, Owl – making some final tweaks to the presentation of our application
Making Something Practical– a bigger project, a game of snake, is discussed and issues surrounding bigger projects addressed
I hope this tutorial’s helpful to you and wish you all the best as you dive into the brave new world of transpiling C/C++ into JavaScript!