diff --git a/src/main.zig b/src/main.zig index 1321505..dd2dc94 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,8 +1,10 @@ +/// Still in the proof of concept phase, don't mind the mess const std = @import("std"); const rl = @import("raylib"); const world = @import("world.zig"); const nso = @import("niotso.zig"); const clap = @import("clap"); +const view = @import("view.zig"); const dbg = std.debug; @@ -57,13 +59,11 @@ const RotationManager = struct { } }; -/// Still in the proof of concept phase, don't mind the mess pub fn main() anyerror!void { const screen_width = 800; const screen_height = 600; - rl.initWindow(screen_width, screen_height, "My Simulation"); - defer rl.closeWindow(); + view.init(true, screen_width, screen_height, "My Simulation"); var current_screen: GameScreen = .login; var frame_counter: i32 = 0; @@ -95,8 +95,6 @@ pub fn main() anyerror!void { .Direction = CardinalDirection.SouthEast, }); - rl.setTargetFPS(60); - const logo = rl.Texture.init("resources/logo.png"); const splash = rl.Texture.init("resources/tsosplash.png"); const chair1 = rl.Texture.init("resources/items/dorm/chair/chair_1.png"); @@ -179,8 +177,7 @@ pub fn main() anyerror!void { // ------------------ // Draw - rl.beginDrawing(); - defer rl.endDrawing(); + view.render(); switch (current_screen) { // Mockup loading screen, skips straight to world @@ -225,10 +222,8 @@ pub fn main() anyerror!void { }, } - // rl.drawGrid(64, 1.0); + rl.drawGrid(64, 1.0); }, } - - rl.drawFPS(10, 10); } } diff --git a/src/view.zig b/src/view.zig new file mode 100644 index 0000000..e670b9c --- /dev/null +++ b/src/view.zig @@ -0,0 +1,24 @@ +const rl = @import("raylib"); + +var is_debug: bool = false; + +pub fn init(dbg: bool, width: i32, height: i32, title: [:0]const u8) void { + if (dbg == true) { + is_debug = dbg; + } + + rl.initWindow(width, height, title); + defer rl.closeWindow(); + + rl.setTargetFPS(60); +} + +/// Setup basic rendering +pub fn render() void { + rl.beginDrawing(); + defer rl.endDrawing(); + + if (is_debug == true) { + rl.drawFPS(10, 10); + } +}