NYXA/README.md

124 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

# NYXApp
Low cortisol **General Purpose App**
# App
```zig
// --- 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
```zig
pub const window_plugin: Plugin = .{
.name = "Window",
.description = "SDL3 Window",
2026-07-10 22:27:43 +01:00
.build = build,
};
fn build(
self: *Plugin,
_: *App,
) !void {
std.debug.print(
"[WINDOW_PLUGIN] {s} - {s}\n",
.{
self.name,
self.description,
},
);
2026-07-10 22:27:43 +01:00
}
```
# Schedules
**addMany**
```zig
try app.schedules.addMany(stage.init, &.{
ensureStuff,
otherSystem,
});
```
**runMany**
```zig
try app.schedules.runMany(
&.{
App.stage.init,
App.stage.deinit,
},
&app,
);
```
# Resources
**set**
```zig
const Window = struct { raw: u32 };
try app.resources.set(Window{ .raw = 0 });
```
**get**
```zig
if (app.resources.getPtr(Window)) |win| {
std.debug.print("[WINDOW] {}\n", .{win.raw});
}
```
**getMany**
```zig
const res = try app.resources.getMany(struct {
window: *Window,
renderer: ?*Renderer,
});
if (res.renderer) |ren| {
std.debug.print("[RENDERER] {}\n", .{ren.raw});
}
```
# Events
**send**
```zig
try app.events.send(
AppExit{
.reason = "Why Not?",
},
);
```
**consume**
```zig
if (app.events.consume(AppExit)) |app_exit| {
std.debug.print("[APP_EXIT] {s}\n", .{app_exit.reason});
2026-07-10 22:27:43 +01:00
}
```
# Default Stages
```zig
2026-07-10 22:27:43 +01:00
pub const stage = struct {
// --- LIFETIME ---
2026-07-10 22:27:43 +01:00
pub const init = struct {};
pub const deinit = struct {};
// --- FRAME ---
pub const begin_frame = struct {};
pub const end_frame = struct {};
2026-07-26 13:18:39 +00:00
// --- CORE ---
2026-07-10 22:27:43 +01:00
pub const inputs = struct {};
pub const fixed_update = struct {};
pub const update = struct {};
pub const draw = struct {};
};
```