diff --git a/extras/doomplayer/src/doom.zig b/extras/doomplayer/src/doom.zig index ac8a306..8140b3e 100644 --- a/extras/doomplayer/src/doom.zig +++ b/extras/doomplayer/src/doom.zig @@ -12,6 +12,8 @@ inputEnabled: bool = false, sensitivity: f32 = 1.0, +entity: core.Entity, + fn log(comptime fmt: []const u8, args: anytype) void { core.engine_log("[Doomplayer] " ++ fmt, args); } @@ -31,10 +33,6 @@ pub fn create(allocator: std.mem.Allocator) !*@This() { self.sensitivity = core.configVar(f32, "doomplayer.sensitivity", 1.0); gDoom = self; - return self; -} - -pub fn setup(self: *@This()) !void { try self.createTextures(); try backlog.platform.context().addSDLProcessFunction(processFunc); c.doom_set_resolution(320, 200); @@ -46,6 +44,9 @@ pub fn setup(self: *@This()) !void { c.doom_set_default_int("mouse_move", 0); // Mouse will not move forward c.doom_init(1, @constCast(@ptrCast(@alignCast(&.{"doom"}))), 8); + + self.entity = try self.createEntity(); + return self; } fn sdlToDoomButton(button: c_uint) c_uint { @@ -407,6 +408,8 @@ pub fn tick(self: *@This(), dt: f64) void { } } +// todo CMRF can be replaced with custom texture install. +// installCustomTexture should be doable through the sgpu renderer. fn bindVideoTextures(p: ?*anyopaque) void { const self: *@This() = @ptrCast(@alignCast(p)); const ctx = rend.context(); diff --git a/projects/sampleGame/main.zig b/projects/sampleGame/main.zig index 496e9b0..aa544aa 100644 --- a/projects/sampleGame/main.zig +++ b/projects/sampleGame/main.zig @@ -89,7 +89,7 @@ pub const FoxObject = struct { const fox = try core.createEntity(); const scene = fox.addComponent(core.Scene).?; - scene.setScale(0.1, 0.1, 0.1); + scene.setScale(0.01, 0.01, 0.01); const mesh = fox.addComponent(rend.MeshComponent).?; mesh.setMesh("m_fox"); mesh.setTexture("t_fox");