diff --git a/Tools/iff2html/CMakeLists.txt b/Tools/iff2html/CMakeLists.txt index 3772bfd..2a41a8b 100644 --- a/Tools/iff2html/CMakeLists.txt +++ b/Tools/iff2html/CMakeLists.txt @@ -6,7 +6,8 @@ set(IFF2HTML_SOURCES md5.c image.c opngreduc.c - ../../Libraries/FileHandler/bmp/read_bmp.c + ../../library/formats/iff/iff.h + ../../library/formats/bmp/read_bmp.c ) include_directories(${FILEHANDLER_INCLUDE} ${LIBPNG_INCLUDE}) diff --git a/build.zig b/build.zig index cd3bcc5..b06a829 100644 --- a/build.zig +++ b/build.zig @@ -24,6 +24,7 @@ pub fn build(b: *std.Build) void { // C headers exe.linkLibC(); + exe.linkLibCpp(); exe.addIncludePath(.{ .path = "./library/formats" }); exe.addIncludePath(.{ .path = "./library/libvitaboy" }); exe.addIncludePath(.{ .path = "./tools" }); diff --git a/build.zig.zon b/build.zig.zon index ee2f61b..fb5f10a 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,5 +1,5 @@ .{ - .name = "ztso", + .name = "mysimulation", // This is a [Semantic Version](https://semver.org/). // In a future version of Zig it will be used for package deduplication. .version = "0.1.100", diff --git a/src/lot.zig b/src/lot.zig deleted file mode 100644 index 67c9307..0000000 --- a/src/lot.zig +++ /dev/null @@ -1,28 +0,0 @@ -pub const Floor = struct { - level: u8, - x: u8, - y: u8, - value: u8, -}; - -pub const World = struct { - floors: []Floor, - walls: u8, -}; - -pub const Item = struct { - guid: u8, - level: u8, - x: u8, - y: u8, - dir: u8, - group: u8, -}; - -pub const House = struct { - version: f32, - size: u8, - category: u8, - world: World, - items: []Item, -}; diff --git a/src/main.zig b/src/main.zig index 74f648b..1e6c767 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,7 +1,6 @@ const std = @import("std"); const rl = @import("raylib"); - -const MAX_INPUT_CHARS = 9; +const world = @import("world.zig"); const GameScreen = enum { login, @@ -9,13 +8,11 @@ const GameScreen = enum { world, }; -// Still in the proof of concept phase, don't midn the mess +// 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; - // var timePlayed: f32 = 0.0; - rl.initWindow(screen_width, screen_height, "My Simulation"); defer rl.closeWindow(); @@ -23,13 +20,15 @@ pub fn main() anyerror!void { var frame_counter: i32 = 0; var camera = rl.Camera3D{ - .position = rl.Vector3.init(5.0, 4.0, 5.0), - .target = rl.Vector3.init(0, 2.0, 0), + .position = rl.Vector3.init(0.0, 10.0, 10.0), + .target = rl.Vector3.init(0, 0.0, 0), .up = rl.Vector3.init(0, 1.0, 0), .fovy = 60, .projection = rl.CameraProjection.camera_perspective, }; + const planePosition = rl.Vector3.init(0.0, 0.0, 0.0); + // var textBox = rl.Rectangle.init(screen_width / 2.0 - 100, 180, 50); // var mouseOnText = false; // var letterCount = 0; @@ -70,6 +69,7 @@ pub fn main() anyerror!void { defer rl.endDrawing(); switch (current_screen) { + // Mockup loading screen, skips straight to world .login => { // Splash screen rl.drawTexture(splash, 0, 0, rl.Color.white); @@ -78,13 +78,16 @@ pub fn main() anyerror!void { // Loading text rl.drawText("Reticulating splines...", 20, screen_height - 30, 20, rl.Color.white); }, + // Skip this for now .cas => {}, - // + // "World" (i.e. lot view) .world => { rl.clearBackground(rl.Color.ray_white); camera.begin(); defer camera.end(); + + rl.drawPlane(planePosition, rl.Vector2.init(2, 2), rl.Color.green); rl.drawGrid(64, 1.0); }, } diff --git a/src/world.zig b/src/world.zig new file mode 100644 index 0000000..7d2685d --- /dev/null +++ b/src/world.zig @@ -0,0 +1,63 @@ +const std = @import("std"); +const rl = @import("raylib"); +const json = std.json; + +pub const Floor = struct { + level: u8, + x: u8, + y: u8, + value: u8, +}; + +pub const Wall = struct { + level: u8, + x: u8, + y: u8, + value: u8, + tls: u8, + trs: u8, + tlp: u8, + trp: u8, + blp: u8, + brp: u8, +}; + +pub const World = struct { + floors: []Floor, + walls: []Wall, +}; + +pub const Item = struct { + guid: u8, + level: u8, + x: u8, + y: u8, + dir: u8, + group: u8, +}; + +pub const House = struct { + version: f32, + size: u8, + category: u8, + world: World, + items: []Item, +}; + +/// Draws floors from JSON Blueprint files +pub fn draw_floors(json_file: [:0]const u8) void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + + const floorLevel = rl.Vector3.init(0.0, 0.0, 0.0); + + const parsed = try json.parseFromSlice(House, allocator, json_file, .{}); + defer parsed.deinit(); + + const blueprint = parsed.value; + + for (blueprint.world.floors) |flr| { + rl.drawPlane(floorLevel, rl.Vector2.init(flr.x, flr.y), rl.Color.green); + } +}