This commit is contained in:
Peter Li 2025-05-06 12:00:41 -07:00
parent 442705c786
commit be2a52f323
2 changed files with 8 additions and 5 deletions

View File

@ -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();

View File

@ -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");