https://github.com/ostanton/tailsengine
The only (maybe) two-tailed game engine!
https://github.com/ostanton/tailsengine
2d-game-engine cmake cpp cpp20 game-engine retro sfml sfml3
Last synced: 8 months ago
JSON representation
The only (maybe) two-tailed game engine!
- Host: GitHub
- URL: https://github.com/ostanton/tailsengine
- Owner: ostanton
- Created: 2024-06-06T23:18:59.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T23:27:14.000Z (over 1 year ago)
- Last Synced: 2024-10-24T12:27:15.497Z (over 1 year ago)
- Topics: 2d-game-engine, cmake, cpp, cpp20, game-engine, retro, sfml, sfml3
- Language: C++
- Homepage:
- Size: 451 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tails Engine
This is a rather simple, and very incomplete, 2D game "engine". It uses SDL3, and aims to run on all the platforms SDL3 supports.
You can think of it almost like a game-focused wrapper for SDL more than its own thing, as it relies on SDL a lot.
>It is very early in development, with many things being either unimplemented, broken, or mid-refactor. Have a look if you dare, but don't expect much!
- [Dependencies](#dependencies)
- [Compilers](#compilers)
- [Platforms](#platforms)
- [How to use](#how-to-use)
## Dependencies
Dependent libraries (SDL3, etc.) are downloaded automatically via CMake's FetchContent (or Zig's build system if you are using that) if not already available.
- C++20
- [CMake](https://cmake.org/) or [Zig](https://ziglang.org/)
- [SDL3](https://libsdl.org/)
## Compilers
I mainly use MSVC because I develop on Windows, however I do use GCC for PSP builds and Clang for Zig builds.
All three of those compilers should work fine.
## Platforms
Since Tails uses SDL3, it more or less supports all the platforms SDL3 supports. However, these are the platforms I know work:
- Windows
- Linux (Ubuntu and Arch)
- PSP (native & emulator)
## How to use
### CMake
A simple FetchContent in CMake to this repo and then linking it should suffice. Something akin to:
```cmake
cmake_minimum_required(VERSION 3.24)
project(MyGame)
include(FetchContent)
FetchContent_Declare(
Tails
GIT_REPOSITORY https://github.com/ostanton/TailsEngine.git
GIT_TAG master
)
FetchContent_MakeAvailable(Tails)
add_executable(MyGame main.cpp)
target_link_libraries(MyGame PRIVATE ostanton::Tails)
```
### Zig
Requires Zig 0.15.1, and it is still early on and WIP, so don't rely on it, but:
```
zig fetch --save git+https://github.com/ostanton/TailsEngine
```
```zig
// build.zig
const tails_dep = b.dependency("tails", .{
.target = target,
.optimize = optimize,
// etc.
});
exe.root_module.linkLibrary(tails_dep.artifact("tails"));
```
Example `build.zig` file:
```zig
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const tails_dep = b.dependency("tails", .{
.target = target,
.optimize = optimize,
});
const mod = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libcpp = true,
});
mod.linkLibrary(tails_dep.artifact("tails"));
mod.addCSourceFile(.{
.file = b.path("src/main.cpp"),
.flags = &.{
"-std=c++20",
},
.language = .cpp,
});
const exe = b.addExecutable(.{
.name = "my_exe",
.root_module = mod,
});
b.installArtifact(exe);
}
```
### `main.cpp`
A minimal `main.cpp` is like so:
```cpp
#include
#include
int main(int argc, char* argv[])
{
using namespace tails;
app::init(argc, argv, {});
app::run();
app::deinit();
return 0;
}
```
Each of these application functions are more or less just a wrapper around calling various subsystem functions of the same name.
So if you want to insert your own subsystem between default engine subsystems, just disect whatever function you need in main.
For a more in-depth example, see the [example](example/) folder.