54 lines
1.3 KiB
Zig
54 lines
1.3 KiB
Zig
allocator: std.mem.Allocator,
|
|
|
|
pub var NeonObjectTable: core.EngineObjectVTable = core.EngineObjectVTable.from(@This());
|
|
|
|
pub fn init(allocator: std.mem.Allocator) !*@This() {
|
|
const self = try allocator.create(@This());
|
|
self.* = .{
|
|
.allocator = allocator,
|
|
};
|
|
return self;
|
|
}
|
|
|
|
pub fn prepare_game(self: *@This()) !void {
|
|
_ = self;
|
|
try core.fs().addContentPath("sampleGame");
|
|
try script.loadTypes("scripts");
|
|
try script.runScriptFile("scripts/prepare.lua");
|
|
|
|
const exitInput = try core.ActionBinding.create(core.MakeName("exit"));
|
|
exitInput.addKey(.escape, .keyDown);
|
|
_ = exitInput.data.addListener(null, onExit);
|
|
exitInput.activate();
|
|
}
|
|
|
|
pub fn onExit(ctx: ?*anyopaque, action: core.ActionEvent) void {
|
|
_ = ctx;
|
|
_ = action;
|
|
|
|
core.exitNow();
|
|
}
|
|
|
|
pub fn tick(self: *@This(), _: f64) void {
|
|
_ = self;
|
|
std.time.sleep(6000 * 1000); // just gonna put this here...
|
|
}
|
|
|
|
pub fn deinit(self: *@This()) void {
|
|
self.allocator.destroy(self);
|
|
}
|
|
|
|
pub fn main() anyerror!void {
|
|
try backlog.initializeAndRunStandardProgram(@This(), .{
|
|
.name = "Hello World",
|
|
.enabledModules = .{
|
|
.physics = true,
|
|
},
|
|
});
|
|
}
|
|
|
|
const std = @import("std");
|
|
const backlog = @import("Backlog");
|
|
const core = backlog.core;
|
|
const script = core.script;
|