sourencho / ungroup_game

A multiplayer game about temporary alliances written with a custom engine in C++ and SFML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ungroup

Build Status

demo

Intro

A multiplayer game where the main mechanic to win is forming temporary alliances.

  • The game is played in rounds.
  • Each player spawns as a circle and has a unique set of resources they need to collect to win.
  • Resources are collected from mines by bumping into them.
  • The first player to reach their goal of resources wins.
  • Players can form groups with other players by merging their circles into a group.
  • The larger a group is the faster it moves/mines and when mining resources are divided among members.
  • A player may leave a group and become a solo circle at any time.

Custom engine written in C++11 using the SFML framework.

Created by @sourenp and @copacetic mostly for learning purposes.

Build

  • You can statically link libraries by setting the cmake flag -DUNGROUP_STATIC=TRUE
  • If you are running from a remote server, you might need to open the tcp and udp ports on your machine.

Cmake variables

  • Set a variable by adding the arg -GVAR_NAME=TRUE to cmake
Variable Meaning
UNGROUP_STATIC Statically link SFML
BUILD_TESTS Build tests
ONLY_SERVER Only build server
ONLY_CLIENT Only build client

Unix

1. Clone this repo

git clone https://github.com/SourenP/ungroup_game.git
cd ungroup_game

2. Install/Download requirements

3. Build

cmake -S . -B build
cmake --build build -- -j

4. Run server and client in seperate terminals

./build/src/server/ug-server
./build/src/client/ug-client

Windows

1. Clone this repo

git clone https://github.com/SourenP/ungroup_game.git
cd ungroup_game

2. Install/Download requirements

3. Build

The server currently doesn't build on windows (#194)

cmake -DONLY_CLIENT=TRUE -DSFML_DIR="Path/to/SFML/lib/cmake/SFML" -DBOOST_ROOT="Path/to/Boost" -G "MinGW Makefiles" -S . -B build\
cmake --build build

4. Run server and client in seperate terminals

 .\build\src\client\ug-client.exe

The server currently doesn't run on windows (#194)

.\build\src\server\ug-server.exe

Testing

  • Build with the cmake flag -GBUILD_TESTS=TRUE
  • Run tests
./build/tests/ug-test "~[skip]"

Game Engine

Custom engine written in C++11 using the SFML framework.

Features:

  • Game functionality
    • Variable time step
    • Unique ID system for game objects
  • Physics
    • Velocity with lerping
    • 2D Circle collision detection and handling
    • 2D Circle perfect ellastic collision impulses
  • Networking
    • Server-Client separation
    • Authoritative server
    • Multi threaded UDP/TCP communication between server and client
    • Reliable (TCP) and Unreliable (UDP) updates
    • Networked physics
      • Hermite Interpolation
      • Event updates
    • Tick sync
    • Works locally and over the internet
  • Rendering
    • 2D Cirlce shapes, textures and shaders
    • Animations with texture sprite sheets
    • Parallax background
    • Variable window size support and zooming/scaling
    • Camera centering
  • Resources
    • Resource manager for textures, fonts, and shaders
  • Levelling
    • Configurable levels
  • UI
    • Client HUD with configurable elements that are alignable to window edges
    • Server terminal ui with tables and panes that displays real time statistics
  • Bots
    • Template for writing bots that query game state and input moves as a client
  • Events
    • Custom event objects with data
    • Subscribe callback to event
  • Metrics
    • Track temporal metrics
  • Util
    • 2D vector operations

Development

Playtesting

Create a new release and write notes in Wiki: Playtesting

Compiliation

  • When you create/delete a file you need to add the <new_file>.cpp to the corresponding CMakeLists.txt file.

Writing Tests

  • We use Catch2 for testing.
  • Add tests for a file in a mirror directory under tests/.
  • Test file should be named tests-<FileName>.cpp
  • Add a test tag for each subdirectory and the file name.

Todo

todo(username|#issue|date): description

Style

  • We use ClangFormat. You can use the xaver.clang-format VSCode extension to automatically format.
  • Class member variables have the style m_camelCase.
  • Class methods have the style camelCase.
  • Local variables have the style snake_case.
  • Variables with the suffix _t are used by multiple threads and have a corresponding <var>_lock mutex.
  • Variables with the suffix _ta are used by multiple threads but don't have a mutex because they are atomic.

Debugging

Compile in debug mode

To compile in debug mode add the flag -DCMAKE_BUILD_TYPE=Debug:

cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build
cmake --build build -- -j

Compiling in debug mode will give you stacktraces for segfaults and detect memory issues.

Profiling

Use gperftools (cpuprofile tutorial)

Vscode lldb

In vscode on a mac you can debug using lldb.

1. Install the extention "Native Debug"

Link: https://marketplace.visualstudio.com/items?itemName=webfreak.debug

2. Setup tasks

Set tasks.json to: https://gist.github.com/SourenP/46d3f5282de7fd7ecaf681384fc8e4dc

3. Setup launch

Set launch.json to: https://gist.github.com/SourenP/47746e0c2b39545975f8e7768e281849

4. Run tasks

Debug build:

  • CMD + SHIFT + P > Tasks: Run Task > build_debug

Debug run:

  • Set breakpoints
  • Run (lldb) Launch ug-server and/or (lldb) Launch ug-client via the debug tab.

Travis CI Debug Build

Run this command to enable debug mode on a specific build: https://gist.github.com/SourenP/3ae15ba0e634a3e0ccceebbb7a27a391

Resources

Game Engine

Physics

Networking

Graphics

Game Design

C++

SFML

Misc

About

A multiplayer game about temporary alliances written with a custom engine in C++ and SFML


Languages

Language:C++ 94.6%Language:GLSL 2.4%Language:CMake 2.0%Language:Ruby 0.5%Language:JavaScript 0.3%Language:Shell 0.3%