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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access