examples: revert to 0.4 entrypoint / control API design
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
a54d20daa2
commit
80be6b7bca
20 changed files with 105 additions and 56 deletions
|
|
@ -12,6 +12,7 @@ const sysaudio = mach.sysaudio;
|
|||
|
||||
pub const App = @This();
|
||||
|
||||
// TODO: banish global allocator
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
|
||||
pub const name = .app;
|
||||
|
|
@ -21,7 +22,7 @@ pub const systems = .{
|
|||
.init = .{ .handler = init },
|
||||
.after_init = .{ .handler = afterInit },
|
||||
.deinit = .{ .handler = deinit },
|
||||
.update = .{ .handler = update },
|
||||
.tick = .{ .handler = tick },
|
||||
.audio_state_change = .{ .handler = audioStateChange },
|
||||
};
|
||||
|
||||
|
|
@ -33,9 +34,11 @@ sfx: mach.Audio.Opus,
|
|||
|
||||
fn init(
|
||||
entities: *mach.Entities.Mod,
|
||||
core: *mach.Core.Mod,
|
||||
audio: *mach.Audio.Mod,
|
||||
app: *Mod,
|
||||
) !void {
|
||||
core.schedule(.init);
|
||||
audio.schedule(.init);
|
||||
app.schedule(.after_init);
|
||||
|
||||
|
|
@ -61,6 +64,8 @@ fn init(
|
|||
std.debug.print("[typing] Play SFX\n", .{});
|
||||
std.debug.print("[arrow up] increase volume 10%\n", .{});
|
||||
std.debug.print("[arrow down] decrease volume 10%\n", .{});
|
||||
|
||||
core.schedule(.start);
|
||||
}
|
||||
|
||||
fn afterInit(audio: *mach.Audio.Mod, app: *Mod) void {
|
||||
|
|
@ -69,8 +74,9 @@ fn afterInit(audio: *mach.Audio.Mod, app: *Mod) void {
|
|||
audio.state().on_state_change = app.system(.audio_state_change);
|
||||
}
|
||||
|
||||
fn deinit(audio: *mach.Audio.Mod) void {
|
||||
fn deinit(core: *mach.Core.Mod, audio: *mach.Audio.Mod) void {
|
||||
audio.schedule(.deinit);
|
||||
core.schedule(.deinit);
|
||||
}
|
||||
|
||||
fn audioStateChange(
|
||||
|
|
@ -99,7 +105,7 @@ fn audioStateChange(
|
|||
}
|
||||
}
|
||||
|
||||
fn update(
|
||||
fn tick(
|
||||
entities: *mach.Entities.Mod,
|
||||
core: *mach.Core.Mod,
|
||||
audio: *mach.Audio.Mod,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue