eggy is a game engine for Zig.
You write your game as a Zig package. It compiles its own editor from source, which you can change with plugins or by editing that source.
curl -fsSL https://raw.githubusercontent.com/eggyengine/eggy/main/scripts/get-started.sh | bash
irm https://raw.githubusercontent.com/eggyengine/eggy/main/scripts/get-started.ps1 | iex
The script is used because the editor is compiled with the game.
Your game is Zig code
A project has a game in src/main.zig, whose hooks the engine calls each frame, and a plugin in src/root.zig that brings components, systems and editor panels. Keep both, or delete the one you do not need. The editor sets the project up for you.
zig build run- Opens your game in the editor.
zig build run-runtime- Runs it as players see it, on the desktop or the web.
const eggy = @import("eggy");
pub const Game = struct {
frames: u64 = 0,
/// Runs once per frame, before drawing.
pub fn update(self: *Game, app: *eggy.App) !void {
_ = app;
self.frames += 1;
}
/// Builds the game's HUD.
pub fn gameUi(self: *Game, app: *eggy.App, ui: *eggy.ui.Context) !void {
_ = app;
ui.label("Frames: {d}", .{self.frames});
}
};
const std = @import("std");
const eggy = @import("eggy");
const ecs = eggy.ecs;
/// A component: an entity with one turns a little every frame.
pub const Spin = struct {
speed: f32 = 0.001,
turns: f32 = 0,
};
/// A system: turns every entity with a `Spin`.
fn spin(spinners: ecs.Query(.{*Spin})) !void {
var iter = spinners;
while (iter.next()) |view| {
const turning = view.get(*Spin);
turning.turns += turning.speed;
}
}
pub const Plugin = struct {
pub const components = .{Spin};
pub fn init(gpa: std.mem.Allocator, app: *eggy.App) !Plugin {
_ = gpa;
app.world.addSchedule(ecs.Schedule(.Update, .{spin}));
_ = try app.world.spawn(.{Spin{}});
return .{};
}
};
Built on its own libraries
We made our own libraries. Are they so good you wanna use them separately? Go ahead, be our guest...
-
vitellus
Rendering hardware interface over Vulkan, DirectX 12 and WebGPU.
-
weeoui
Immediate-mode UI with docking panels and screen-reader support. The editor, and this site's look, come from it.
-
humpty
WIP physics engine
-
clutch
Entity component system, inspired by
bevy_ecs.
Working on eggy itself
Clone the repository with its submodules, then run the editor:
git clone --recursive https://github.com/eggyengine/eggy cd eggy zig build run
On Linux, install the GTK3, DBus and libunwind headers first: libgtk-3-dev libdbus-1-dev libunwind-dev on Debian. zig build fetches everything else.
Pull requests written with an agent are welcome, as long as you can explain what yours does without looking at the code.