Laguna1989 / JamTemplateCpp

This is the JamTemplate for kickstarting your gamejam entry. It will compile C++20 code for native (Win, Linux, Mac) and web (webassembly) games.
Creative Commons Zero v1.0 Universal
22 stars 3 forks source link
cmake cplusplus-20 cpp cpp20 cpp20-lib cpp20-library emscripten game-development gamedev gamejam sdl2 sfml2 webassembly

JamTemplateCpp

Build Status codecov

About

This is the JamTemplate for kickstarting your gamejam entry. It will compile C++20 code for native (Win, Linux) and web (webassembly) games. Internally it uses SFML, SDL and OpenALpp.

Some games created with this JamTemplate are

and more at my game portfolio.

Setup

Visual Studio

  1. create build directory build at root level
  2. open command line (win+r cmd)
  3. navigate to the just created build folder
  4. type cmake ../
  5. Open generated solution file with Visual Studio

Clion (Win, Linux)

  1. open project folder in clion

Building for Web

I run it with WSL2, but every system capable of running webassembly / emscripten should work.

Preconditions:

Setup

  1. emcmake cmake -DJT_ENABLE_WEB=ON ../
  2. on the first run emmake make (do not pass -j, otherwise emscripten will get stuck with pulling libraries)
  3. on consecutive runs: emmake make -j
  4. http-server . to start a webserver locally. (needs to be installed separately)
  5. open browser on http://127.0.0.1:8080/ to test locally

Mac

For mac os you have to install cmake and sfml via homebrew: brew install cmake sfml If you use another package manager or want to install the dependencies yourself, you have to modify the paths in CMakeLists.txt.

Deployment

Automatic creation of the files is automated via github actions. If a release is created with semantic versioning ( e.g. v1.2.3), a deployment build is triggered, which builds the game executable for windows, linux, mac and web and attaches the zipped files to the release once the build is finished. The archives can directly be uploaded on itch, gamejolt or any other website.

Note: Only the game executable and the assets folder is included in the archive. If more files are required, either adjust the deployment script (.github/workflows/deploy.yml) or place them in the assets folder.

CMake options

The options can be set to ON or OFF via the cmake commandline or cmake-gui:

e.g. calling cmake ../ -DJT_ENABLE_UNITTESTS=ON -DENABLE_DEMOS=ON

Code Coverage

Code Coverage is reported via CodeCov

A local run (without the artifacts) can be executed e.g. on Windows via OpenCppCoverage:

OpenCppCoverage.exe --sources C:\projects\JamTemplateCpp\* --excluded_sources C:\projects\JamTemplateCpp\test\* --excluded_sources C:\projects\JamTemplateCpp\ext\* --excluded_sources C:\projects\JamTemplateCpp\cmake-build-debug\* .\cmake-build-debug\test\unit\jt_test\jt_tests.exe

Performance benchmark

Please check the performance benchmark report.

1hgj setup (recommended steps)

Starting on Linux

FMod cannot be linked statically in the indie tier. Thus you need to provide the so while loading. Linux does not look in the local path by default. To fix this, you can add the following variable when starting the exe

LD_LIBRARY_PATH=<path_to_build_dir>impl/game