![Hands-On Game Development with WebAssembly](https://wfqqreader-1252317822.image.myqcloud.com/cover/571/36698571/b_36698571.jpg)
Compiling game_objects.html
Now that we have built all of these game objects, we no longer have everything inside a single file. We will need to include several CPP files and compile them all into a single output file we will call game_objects.html. Because we have moved from the world of C to C++, we will be using em++ to indicate that the files we are compiling are C++ files and not C files. That is not strictly necessary, because Emscripten will figure out that we are compiling with C++ when it receives files with the .cpp extension as input. We are also telling the compiler explicitly the version of C++ we are using when we pass in the -std=c++17 flag. Go ahead and compile the game_objects.html file with the following em++ command:
em++ main.cpp enemy_ship.cpp player_ship.cpp projectile.cpp projectile_pool.cpp -std=c++17 --preload-file sprites -s USE_WEBGL2=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS=["png"] -o game_objects.html
Now that we have our game_objects.html file compiled use a web server to serve the files and open it in a browser, it should look like this:
![](https://epubservercos.yuewen.com/1EACDC/19470378408806806/epubprivate/OEBPS/Images/23123d7f-c321-4339-b623-e4be90bc4388.png?sign=1738818949-t6Xj2LX8Z3EBPpxo7dZgxXNexwb3ptht-0-0227203a1489babf97ad34eec91589db)
You can move your spaceship around the canvas with the arrow keys, and fire a projectile with the spacebar. The enemy ship will move around the canvas shooting randomly.