Super Cool NetMythos Engine (Name Not Final)
This is a hobbyist game engine thing. I'm also using it for visualizations. Right now it is only meant to support WASM with WebGL but maybe at some point I will port it to build desktop apps.
Anyways, for the time being it's a hodgepodge.
If you want to use it, you'll need your main exe file to have a
pub fn init() void {}
and a pub fn update() void
. You'll also need to
import the engine and do something like comptime { _ = engine }
to make sure
the initial exports are compiled in correctly.
You'll also want to use a build.zig file that looks something like this:
const std = @import("std");
pub fn build(b: *std.Build) void {
// The engine only supports wasm right now so if you set a whitelist here,
// you won't have to remember to specify your target each time you compile.
const wasm_target: std.Target.Query = .{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
};
const target = b.standardTargetOptions(.{
.whitelist = &.{wasm_target},
.default_target = wasm_target,
});
const optimize = b.standardOptimizeOption(.{});
// Import the dependency via your build.zig.zon
const engine = b.dependency("engine", .{});
const exe = b.addExecutable(.{
// IMPORTANT! Right now the shell expects a file named game.wasm in the bin directory.
// I will make it flexible eventually. But right now if you change this line,
// Your project won't work right.
.name = "game",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
// WASM doesn't use a normal entry point. The HTML/JS shell code is going
// to handle calling our functions.
exe.entry = .disabled;
exe.root_module.addImport("engine", engine.module("engine"));
// Here we install a pre-written HTML/JS shell. After building, if you
// run a webserver with your zig-out dir as the root, you should see your
// program.
const shell_files = engine.namedWriteFiles("shell");
const install_shell = b.addInstallDirectory(.{
.source_dir = .{ .generated = &shell_files.generated_directory },
.install_dir = .prefix,
.install_subdir = "",
});
b.getInstallStep().dependOn(&install_shell.step);
b.installArtifact(exe);
}