JamTemplateCpp
About
This is the JamTemplate for kickstarting your gamejam entry. It will compile C++17 code for native (Win, Linux) and web (webassembly) games. Internally it uses SFML and SDL.
Some games created with this JamTemplate are
- Funky Trip (Native & Web, Alakajam 14 2022)
- Gemga (Native & Web, FrankenGameJam 2021)
- Quasar Rush (Native & Web, A Game By Its Cover 2021)
- Space Turtles (Native, MultiplayerKajam 2021)
- Tricky Tractor (Native, FrankenGameJam 2020)
- Burning Glyphs (Web, 7DFPS 2020)
- Grounded (Native, FrankenGameJam 2019)
and some more at my game portfolio.
Setup
Windows & Visual studio (code)
- create build directory
build
at root level - open command line (win+r
cmd
) - navigate to the just created build folder
- type
cmake ../
Clion
- open project folder in clion
Hint: There is a file template available in the .idea
folder that will make take away some of the boilerplate code
during creation of Gameobject classes.
Windows 32 bit
There should be no need for a 32 bit executable anymore. However, if strictly required, perform the steps from above except:
- Get the win32 zip from the sfml website
cmake -A Win32 ../
Web
I run it with WSL2, but every system capable of running webassembly / emscripten should work.
Preconditions:
- have emscripten set up on your machine: See the Getting started page
Setup
emcmake cmake -DJT_ENABLE_WEB=ON ../
- on the first run
emmake make
(do not pass-j
, otherwise emscripten will get stuck with pulling libraries) - on consecutive runs:
emmake make -j
http-server .
to start a webserver locally. (needs to be installed separately)- 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 or place them in the assets folder.
Cmake options
All of those options can be set to ON or OFF via the cmake commandline
JT_ENABLE_UNITTESTS
- Enables gtest and the unit testsJT_ENABLE_DEMOS
- Enables the demos (small example programs which showcase a specific theme)JT_ENABLE_WEB
- WebbuildUSE_SFML
- IfON
, SFML will be used, ifOFF
, SDL will be used (SDL works best on linux)JT_ENABLE_AUDIO_TESTS
- Some of the tests rely on a working audio setup, which seemingly cannot be faked easily. This switch disables those specific tests, in case no audio is available on the respective machine.JT_ENABLE_CLANG_TIDY
- Enable clang tidy checker
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 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.
gamejam setup recommended steps
- Use this repo as a template
- Clone the new repository
- remove the folders
test
assets/test
.github/workflows/
everything exceptdeploy.yml
- Changes in
CMakeLists.txt
:- Set the project name
- Remove or comment the line
add_subdirectory(test)
- Change js filename in
index.html
- Set most cmake variables to
OFF
inconfig/cmake/cache_variables.cmake
- Import a new palette into
impl/gamelib/game_properties.cpp
, e.g. from this website ( save as gpl and paste file content) - Change
impl/gamelib/game_properties.hpp
settings as needed (window size, jam, author and date)