What's changing?

This game is an ideal candidate for porting because it uses SDL2, a widely used library with an existing Emscripten port. Including SDL2 in the compilation step requires only one additional argument passed to the emcc command. An Emscripten port of the SDL2_ttf library also exists, but keeping it in the code base doesn't make much sense. Its sole purpose is to render the score (amount of rows cleared) as text. We would need to include the TTF file with the application and complicate the build process. Emscripten provides the means for using JavaScript code within our C++, so we're going to take a much simpler route: show the score in the DOM.

In addition to changing the existing code, we'll need to create an HTML and CSS file for displaying and styling the game in the browser. The JavaScript code we write will be minimal — we just need to load the Emscripten module and all our functionality is handled in the C++ code base. We'll also need to add a few <div> elements and lay them out accordingly to display the score. Let's start porting!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset