Backlog/projects/sampleGame/main.zig

60 lines
1.7 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 {
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();
const results = try rend.gltfLoader.loadIndexedMeshForPoolingGltf(self.allocator, core.MakeName("test"), null, "gltf-samples/Fox/glTF/Fox.gltf");
defer results.deinit(self.allocator);
core.engine_log("loaded fox, vertices: {d}", .{results.new.vertices.len});
core.engine_log("loaded fox, indices: {d}", .{results.new.indices.len});
}
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 rend = backlog.rend;
const script = core.script;