Initial refractoring attempt

Slight refractor attempt by moving some initializing to view module, sadly it crashes.
This commit is contained in:
Tony Bark 2024-05-13 23:25:17 -04:00
parent 017d5ef1a7
commit 6c8e36d99f
2 changed files with 29 additions and 10 deletions

View file

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

24
src/view.zig Normal file
View file

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