VampireSurvivors/src/main.zig

44 lines
1.2 KiB
Zig

const std = @import("std");
const App = @import("app");
const plugin = @import("plugin/root.zig");
const resource = @import("resource/root.zig");
pub fn main(init: std.process.Init) !void {
// --- APP ---
var app: App = .init(init.gpa);
defer app.deinit();
// --- ADD DEFAULT PLUGIN & BUILD ---
try app.plugins.add(plugin.default);
try app.plugins.build(.{ .app = &app });
// --- LIFETIME ---
try app.schedules.run(App.stage.init, .{ .app = &app });
defer app.schedules.run(App.stage.deinit, .{ .app = &app }) catch unreachable;
// errdefer {
// app.schedules.run(App.stage.deinit, .{ .app = &app }) catch unreachable;
// }
try app.schedules.run(App.stage.post_init, .{ .app = &app });
// --- MAIN GAME LOOP ---
while (true) {
// --- BREAK ON EXIT ---
if (app.events.consume(App.event.AppExit)) |_| {
break;
}
// --- FRAME ---
try app.schedules.runMany(&.{
App.stage.begin_frame,
App.stage.inputs,
App.stage.update,
App.stage.draw,
App.stage.end_frame,
}, .{
.app = &app,
});
}
}