Coder Social home page Coder Social logo

laguna1989 / jamtemplatecpp Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 3.0 91.59 MB

This is the JamTemplate for kickstarting your gamejam entry. It will compile C++20 code for native (Win, Linux, Mac) and web (webassembly) games.

License: Creative Commons Zero v1.0 Universal

CMake 1.36% C++ 96.44% HTML 0.43% CSS 0.07% C 1.26% Python 0.43%
webassembly game-development gamejam sfml2 sdl2 cmake cplusplus-20 cpp cpp20 cpp20-lib

jamtemplatecpp's Introduction

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

  • Fruit Lovin Monkey Pirates (Action Sailing Game, Native & Web, FrankenGameJam 2023)
  • Medibellum (Multiplayer Autobattler Game, Native, Kajam-13 2023)
  • Mines of Gloria (Incremental Clicker Game, Native & Web, ClickerJam Spring 2023)
  • Tworld (Jump and Run, Native & Web, FrankenGameJam 2022)
  • Funky Trip (Top Down ARPG, Native & Web, Alakajam 14 2022)
  • Gemga (Puzzler, Native & Web, FrankenGameJam 2021)
  • Quasar Rush (Physics based puzzle game, Native & Web, A Game By Its Cover 2021)
  • Space Turtles (Multiplayer SHMUP, Native, MultiplayerKajam 2021)
  • Tricky Tractor (Puzzler, Native, FrankenGameJam 2020)
  • Burning Glyphs (FPS, Web, 7DFPS 2020)
  • Grounded (2 Player Couch Battle, Native, FrankenGameJam 2019)

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:

  • JT_ENABLE_UNITTESTS - Enables gtest and the unit tests
  • JT_ENABLE_PERFORMANCETESTS Enables the performance tests
  • JT_ENABLE_DEMOS - Enables the demos (small example programs which showcase a specific theme)
  • JT_ENABLE_WEB - Webbuild
  • USE_SFML - If ON, SFML will be used, if OFF, 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
  • JT_ENABLE_LTO_OPTIMIZATION - Enable Link time optimization. This gives higher runtime performance for the cost of increased build and link times.

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)

  • Use this repo as a template
  • Clone the new repository
  • Remove the folders
    • test
    • assets/test
    • .github/workflows/ everything except deploy.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 in config/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)

jamtemplatecpp's People

Contributors

adkiem avatar cxong avatar dependabot[bot] avatar laguna1989 avatar spatialfruitsalad avatar thunraz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jamtemplatecpp's Issues

animation looping per animation

currently looping anymiations are either looping all sub animations or none. The user should be able to set this for individual animations.

StressTest implementation

StressTest:

  • ๐Ÿ‘ Tweens
  • ๐Ÿ‘ Smart Object functionality (e.g. flash)
  • ๐Ÿ‘ StateChances
  • ๐Ÿ‘ Animations

Dedicated sdl build

Will most likely just require a cmake switch, which graphics lib shall be used. All unit tests should work with SFML and SDL

SmartText

Another child class of SmartObject, working on SmartText

sfml text align for multiline text

Multiline text defintion:

  • jt::Text
  • contains at least one "\n"

This behaves differently for SFML (code) and SDL (code) builds due to differences between the implementations. SFML considers the full text box, while SDL considers each line (which results in the proper result)

Possible solution

  • Change the SFML implementation class to contain a vector of sf::Text objects instead of only one. One sf::Text per line.
  • Text needs to be split on linebreaks.
  • Make the doUpdate() function set the position of the individual sf::Text objects depending on the width of the longest line and the m_textAlign value.
  • Make the doDraw() functions (including flash and shadwo) draw those multiple sf::Text objects.

Please check

  • Adapt the Scroll/MoveCam demo to contain multiline text with different alignments
  • Check that all unit tests pass
  • Check that new code branches are tested. This might require some additions to the text_test and potentially the drawable_impl_test
  • Check/Adapt the state_menu if needed.

Animations

Implement an animation class, based on smartsprites.

Advanced Palette functions

  • Add Functions to easily manipulate colors, e.g.
    • desaturate() #184
    • saturate
    • rotate hue
    • darken
    • lighten
  • Palette from image
    • Load a jt::Sprite and use getColorAtPixel to fill a Palette.
    • The Palette class should get a new static function that acceppts the filename to an image and returns the respective Palette
  • Extend demos
  • Works for both SFML and SDL
  • MakeUnique

Color and Palette functionality

Colors currently only support rgb.

  • hsv2rgb
  • rgb2hsv
  • Add hexString support #93
  • Add random functions to get a color with a fixed saturation or hue #100
  • Add Palette class to group colors together and manipulate them together #100
  • Palette from gpl #102
  • Add Demo #102

Setting Up

Make setting up the game class in main.cpp easier

TweenScale

Tweening the Scale should be possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.