Just a sample game engine - mostly as a learning experiment. Built in C++ on top of SDL, scriptable in Lua through Sol2 bindings. Cross platform thanks to CMake, and compiles to wasm and js via emscripten.
git clone REPO
cd game_engine
git submodule update --init
- open the folder with Visual Studio, it should detect CMake automatically
- right-click on CMakeLists.txt, then click "Debug" to run the project
- the
sample
folder, which contains a test game, is symlinked alongside the compiled executable, so modifymain.lua
and it should be fine
Make sure these dependencies are installed and in your terminal PATH (easy enough with chocolatey):
- CMake (
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=User'
) - Ninja (
choco install -y ninja
) - Python (
choco install -y python --version=3.9.5
)
- open a developer command prompt (in Visual Studio, Tools->Command Line->Developer Command Prompt)
- run the following commands:
cd externals\emsdk
emsdk install latest
emsdk activate latest
emcc --check
At this point, there might be some errors. Run emsdk list
to see if you can install them through emsdk.
For example:
emsdk install fastcomp-clang-e1.38.30-64bit
emsdk activate fastcomp-clang-e1.38.30-64bit
In the same terminal:
# back to the root folder
emcmake cmake . -B web-build -G Ninja
# this is the command that you will re-run every time you want to recompile
cmake --build web-build
Since WASM is only possible when files are served from a server, run python -m http.server
(in another terminal) to quickly serve your files, and navigate to localhost:8000 to test it.
# reactivate the environment
externals\emsdk\emsdk_env.bat
# recompile the sources
cmake --build web-build
- Lua, as a submodule, will be built from source and compiled to a static lib
- SDL, as a submodule, will be build from source and compiled to a static lib
- Sol, as a single header
- emsdk, as a submodule