ftz.Lyberta.net

Modern C++ goodness

ftz Engine

A 2D game engine

Key features

  • Multiplayer friendly - Single player is a multiplayer with only 1 client.
  • Free software - released under the terms of GNU AGPLv3 or any later version.

Architecture

                                            Game libraries

                      /--------------------------V-----------------------------\
                      |                          |                             |
                      |         libClient.so     |         libServer.so        |
                      |              ^           |              ^              |
           /----------+--------------|-----------^--------------|--------------<
           |          |              V                          V              |
           | Client <--->                                                      |
  Launcher |          |                                                        |
    apps   |----------|                   libftzengine.so                      |
           |          |                                                        |
           | Server <--->                                                      |
           |          |      ^          ^        ^       ^        ^        ^   |
           \----------+------|-----V----|----V---|---V---|---V----|----V---|---<
                      |      V     |    V    |   V   |   V   |    V    |   V   |
                      | FileSystem | Library | Video | Input | Network | Audio |
                      |            |         |       |       |         |       |
                      \------------^---------^-------^-------^---------^-------/

                                              Drivers

The engine has 4 components:

  • Main library (libftzengine.so). This library holds everything together.
  • Launcher apps. These are used to launch client and dedicated server.
  • Drivers. These provide functionaly outside of ISO C++. There are 4 driver types linked dynamically and 2 statically. Dynamic ones are: video, input, network and audio. Static ones are filesystem and library drivers.
  • Game libraries. These implement a game. There are 2 libraries: client and server.

Dependencies

Compiler support

  • G++ 7 or newer with libstdc++ and libstdc++fs

Platform support

  • POSIX + FHS

How to build

make

Installation

Minimum required

make install-min

Development (for compiling games and drivers)

make install-dev

Full

make install

Home directory overrides

Everything you put into your home directory will override files from the engine directory or system-wide directories.

  • Put config files into $XDG_CONFIG_HOME/ftz-engine.
  • Put drivers into $XDG_DATA_HOME/ftz-engine/Drivers.
  • Put games into $XDG_DATA_HOME/ftz-engine/Games.

Launching

There are 4 ways you can start a game.

Single player

  • Launch ftz-engine-client.
  • Enter startsingleplayer command.
  • The single player starts. You will be playing alone.

Join multiplayer game

  • Launch ftz-engine-client.
  • Enter connect [address] [port] command. You can omit port and/or address. Default address is 127.0.0.1 and port is 26196.
  • The client will try to connect to specified address and the multiplayer game will begin.

Listen server

  • Launch ftz-engine-client.
  • Enter startlistenserver command.
  • Listen server starts and your client will automatically connect to it. It will open port corresponding to sv_listenport variable and other players will be able to join.

Dedicated server

  • Launch ftz-engine-server.
  • Launch ftz-engine-client.
  • Use connect [address] [port] command to connect to the server.

How to develop games

You have to have two libraries: client and server. Client should derive from ftz::Engine::ClientInterface and ftz::Engine::ClientFactoryInterface. Server should derive from ftz::Engine::ServerInterface and ftz::Engine::ServerFactoryInterface. Both client and server should implement function CreateInterface that will return respective factories. Most of the engine facilities are accessed via ftz::Engine::EngineInterface class which is passed to constructor of client and server instances.

Headers are included as follows:

#include <ftz/Engine/someheader.h>

Game libraries should be put into /usr/local/lib/ftz-engine/Games/%GAMENAME% or $XDG_DATA_HOME/ftz-engine/Games/%GAMENAME% directory. Client should be named libClient.so, server should be named libServer.so.

Source code

API reference