From 23744aba3b81fc78dff81bd15614a973151a41bf Mon Sep 17 00:00:00 2001 From: Radioactivity <85001747+voidwyrm-2@users.noreply.github.com> Date: Fri, 25 Jul 2025 13:25:45 -1000 Subject: [PATCH] Changes - Fixed issues with poor font quality by setting the font size manually - Finished a very basic main menu; the scaling issues on MacOS still happen --- src/main.zig | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main.zig b/src/main.zig index 0d10295..de9dafa 100644 --- a/src/main.zig +++ b/src/main.zig @@ -292,8 +292,8 @@ const Game = struct { texture_map.put(.lane, lane) catch unreachable; texture_map.put(.ai, ai) catch unreachable; - const font_title = rl.loadFont("assets/font/DepartureMonoNerdFontMono-Regular.otf") catch unreachable; - const font_normal = rl.loadFont("assets/font/GohuFont14NerdFontMono-Regular.ttf") catch unreachable; + const font_title = rl.loadFontEx("assets/font/DepartureMonoNerdFontMono-Regular.otf", 80, null) catch unreachable; + const font_normal = rl.loadFontEx("assets/font/GohuFont14NerdFontMono-Regular.ttf", 80, null) catch unreachable; return .{ .camera = .{ @@ -331,14 +331,13 @@ const Game = struct { fn process(self: *Game) void { std.debug.print("Delta time: {d}\n", .{rl.getFrameTime()}); + // TODO: find a better method of mutating the original switch (self.screen_state) { - .main => |m| { - var mut_m = m; - mut_m.update(self); + .main => |_| { + self.screen_state.main.update(self); }, - .battle => |b| { - var mut_b = b; - mut_b.update(self); + .battle => |_| { + self.screen_state.battle.update(self); }, } @@ -346,14 +345,13 @@ const Game = struct { } fn render(self: *Game) void { + // TODO: find a better method of mutating the original switch (self.screen_state) { - .main => |m| { - var mut_m = m; - mut_m.render(self); + .main => |_| { + self.screen_state.main.render(self); }, - .battle => |b| { - var mut_b = b; - mut_b.render(self); + .battle => |_| { + self.screen_state.battle.render(self); }, } } @@ -395,9 +393,12 @@ const ScreenMainMenu = struct { rl.clearBackground(bg_color); - rl.drawTextEx(game.font_title, "Test", rl.Vector2.init(20, 20), 40, 4, rl.Color.white); + // what are we actually calling this game? + rl.drawTextEx(game.font_title, "Bug Defenders", rl.Vector2.init(480, 30), 40, 4, rl.Color.white); - if (rlg.button(.{ .x = 100, .y = 100, .width = 400, .height = 200 }, "Play")) { + // TODO: the play button and the title text don't scale with window resizes + // weirdly, textures do, though? + if (rlg.button(.{ .x = 485, .y = 480, .width = 300, .height = 150 }, "Play")) { game.screen_state = .{ .battle = .{} }; } }