Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prime31/zig-gamekit
Companion repo for zig-renderkit for making 2D games
https://github.com/prime31/zig-gamekit
Last synced: 22 days ago
JSON representation
Companion repo for zig-renderkit for making 2D games
- Host: GitHub
- URL: https://github.com/prime31/zig-gamekit
- Owner: prime31
- License: mit
- Created: 2020-11-12T19:02:04.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-04-28T02:02:35.000Z (over 1 year ago)
- Last Synced: 2024-11-13T22:35:27.272Z (29 days ago)
- Language: Zig
- Size: 1020 KB
- Stars: 124
- Watchers: 4
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - prime31/zig-gamekit - renderkit for making 2D games. (Game Field / Zigged Project)
- awesome-zig - zig-gamekit🗒️Companion repo for zig-renderkit for making 2D games
README
# Zig GameKit
Companion repo and example implementation for [zig-renderkit](https://github.com/prime31/zig-renderkit). `GameKit` provides an example implementation of a game framework built on top of `RenderKit`. It includes the core render loop, window (via SDL), input, Dear ImGui and timing support. You can use it as a base to make a 2D game as-is or create your own 2D framework based on it.`GameKit` provides the following wrappers around `RenderKit`'s API showing how it can be abstracted away in a real world project: `Texture`, `Shader` and `OffscreenPass`. Building on top of those types, `GameKit` then provides `Mesh` and `DynamicMesh` which manage buffers and bindings for you. Finally, the high level types utilize `DynamicMesh` and cover pretty much all that any 2D game would require: `Batcher` (quad/sprite batch) and `TriangleBatcher`.
Some basic utilities and a small math lib with just the types required for the renderer (`Vec2`, `Vec3`, `Color`, `3x2 Matrix`, `Quad`) are also included.
## Dependencies
GameKit has just one external dependency: SDL. You can install SDL with the package manager of your choice.### Usage
- clone the repository recursively: `git clone --recursive https://github.com/prime31/zig-gamekit`
- `zig build help` to see what examples are availble
- `zig build EXAMPLE_NAME` to run an example### Minimal GameKit Project File
```zig
var texture: Texture = undefined;pub fn main() !void {
try gamekit.run(.{ .init = init, .render = render });
}fn init() !void {
texture = Texture.initFromFile(std.heap.HeapAllocator, "texture.png", .nearest) catch unreachable;
}fn render() !void {
gamekit.gfx.beginPass(.{ .color = Color.lime });
gamekit.gfx.draw.tex(texture, .{ .x = 50, .y = 50 });
gamekit.gfx.endPass();
}
```