GPA (General Purpose App)
Find a file
2026-08-01 22:44:49 +01:00
src Major Update | Removed World | Use NYXWorld instead 2026-08-01 22:44:49 +01:00
.gitignore HelloWorld 2026-07-09 22:30:04 +01:00
build.zig HelloWorld 2026-07-09 22:30:04 +01:00
build.zig.zon HelloWorld 2026-07-09 22:30:04 +01:00
README.md Major Update | Removed World | Use NYXWorld instead 2026-08-01 22:44:49 +01:00

NYXApp

Low cortisol General Purpose App

App

// --- APP ---
var app: App = .init(std.testing.allocator);
defer app.deinit();

// --- ADD PLUGINS ---
try app.plugins.addMany(&.{
    window_plugin,
});
try app.plugins.build(&app);

Plugin

pub const window_plugin: Plugin = .{
    .name = "Window",
    .description = "SDL3 Window",
    .build = build,
};

fn build(
    self: *Plugin,
    _: *App,
) !void {
    std.debug.print(
        "[WINDOW_PLUGIN] {s} - {s}\n",
        .{
            self.name,
            self.description,
        },
    );
}

Schedules

addMany

try app.schedules.addMany(stage.init, &.{
    ensureStuff,
    otherSystem,
});

runMany

try app.schedules.runMany(
    &.{
        App.stage.init,
        App.stage.deinit,
    },
    &app,
);

Resources

set

const Window = struct { raw: u32 };
try app.resources.set(Window{ .raw = 0 });

get

if (app.resources.getPtr(Window)) |win| {
    std.debug.print("[WINDOW] {}\n", .{win.raw});
}

getMany

const res = try app.resources.getMany(struct {
    window: *Window,
    renderer: ?*Renderer,
});

if (res.renderer) |ren| {
    std.debug.print("[RENDERER] {}\n", .{ren.raw});
}

Events

send

try app.events.send(
    AppExit{
        .reason = "Why Not?",
    },
);

consume

if (app.events.consume(AppExit)) |app_exit| {
    std.debug.print("[APP_EXIT] {s}\n", .{app_exit.reason});
}

Default Stages

pub const stage = struct {
    // --- LIFETIME ---
    pub const init = struct {};
    pub const deinit = struct {};

    // --- FRAME ---
    pub const begin_frame = struct {};
    pub const end_frame = struct {};

    // --- CORE ---
    pub const inputs = struct {};
    pub const fixed_update = struct {};
    pub const update = struct {};
    pub const draw = struct {};
};