From e9d7d736ebf5bdf013c57dba59531b9c411581a1 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Tue, 18 Feb 2025 08:02:51 -0500 Subject: [PATCH] Restarted Zig project with the new build architecture - Renamed old src directory as backup-src --- {src => backup-src}/api/auth.zig | 0 {src => backup-src}/common/map.zig | 0 {src => backup-src}/common/render.zig | 0 {src => backup-src}/config.zig | 0 {src => backup-src}/io/filehandler.zig | 0 {src => backup-src}/io/oiff.zig | 0 backup-src/main.zig | 234 ++++++++++++++++++++++++ {src => backup-src}/niotso.zig | 0 backup-src/root.zig | 10 ++ {src => backup-src}/simantics/.gitkeep | 0 {src => backup-src}/version.txt | 0 {src => backup-src}/vitaboy.zig | 0 {src => backup-src}/world.zig | 0 build.zig | 60 +++---- build.zig.zon | 33 ++-- src/main.zig | 236 ++----------------------- src/root.zig | 10 ++ 17 files changed, 316 insertions(+), 267 deletions(-) rename {src => backup-src}/api/auth.zig (100%) rename {src => backup-src}/common/map.zig (100%) rename {src => backup-src}/common/render.zig (100%) rename {src => backup-src}/config.zig (100%) rename {src => backup-src}/io/filehandler.zig (100%) rename {src => backup-src}/io/oiff.zig (100%) create mode 100644 backup-src/main.zig rename {src => backup-src}/niotso.zig (100%) create mode 100644 backup-src/root.zig rename {src => backup-src}/simantics/.gitkeep (100%) rename {src => backup-src}/version.txt (100%) rename {src => backup-src}/vitaboy.zig (100%) rename {src => backup-src}/world.zig (100%) create mode 100644 src/root.zig diff --git a/src/api/auth.zig b/backup-src/api/auth.zig similarity index 100% rename from src/api/auth.zig rename to backup-src/api/auth.zig diff --git a/src/common/map.zig b/backup-src/common/map.zig similarity index 100% rename from src/common/map.zig rename to backup-src/common/map.zig diff --git a/src/common/render.zig b/backup-src/common/render.zig similarity index 100% rename from src/common/render.zig rename to backup-src/common/render.zig diff --git a/src/config.zig b/backup-src/config.zig similarity index 100% rename from src/config.zig rename to backup-src/config.zig diff --git a/src/io/filehandler.zig b/backup-src/io/filehandler.zig similarity index 100% rename from src/io/filehandler.zig rename to backup-src/io/filehandler.zig diff --git a/src/io/oiff.zig b/backup-src/io/oiff.zig similarity index 100% rename from src/io/oiff.zig rename to backup-src/io/oiff.zig diff --git a/backup-src/main.zig b/backup-src/main.zig new file mode 100644 index 0000000..1321505 --- /dev/null +++ b/backup-src/main.zig @@ -0,0 +1,234 @@ +const std = @import("std"); +const rl = @import("raylib"); +const world = @import("world.zig"); +const nso = @import("niotso.zig"); +const clap = @import("clap"); + +const dbg = std.debug; + +const GameScreen = enum { + login, + cas, // Create-A-Sim + map, // city screen + lot, // world view +}; + +//We start that NorthWest so it is easy to determine the flip +const CardinalDirection = enum { + NorthWest, // 0, sprite 1 + NorthEast, // 1, sprite 1 flip + SouthEast, // 2, sprite 2 + SouthWest, // 3, sprite 2 flip +}; + +const Rotations = enum { + left, // 0 + right, // 1 +}; + +const RotationManager = struct { + Direction: CardinalDirection, + + pub fn init(self: RotationManager) RotationManager { + return self; + } + + pub fn rotate(self: *RotationManager, rotation: Rotations) void { + //rotate the direction by 90 degrees + var direction_index = @as(i8, @intFromEnum(self.Direction)); + switch (rotation) { + .left => { + direction_index = direction_index - 1; + }, + .right => { + direction_index = direction_index + 1; + }, + } + // Circle around if out of bounds + if (direction_index < 0) { + self.Direction = CardinalDirection.SouthWest; + } else if (direction_index > 3) { + self.Direction = CardinalDirection.NorthWest; + } else { + self.Direction = @as(CardinalDirection, @enumFromInt(direction_index)); + } + //Result + dbg.print("Orientation: {any}\n", .{self.Direction}); + } +}; + +/// 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(); + + var current_screen: GameScreen = .login; + var frame_counter: i32 = 0; + + // NOTE: jip + // I don't think we can get away with using the built-in camera + // We need pixel perfect isometric camera + var lot_camera = rl.Camera3D{ + .position = rl.Vector3.init(-90.0, 20.0, 90.0), + .target = rl.Vector3.init(0, 0.0, 0), + .up = rl.Vector3.init(0, 1.0, 0), + .fovy = 10, + .projection = rl.CameraProjection.camera_orthographic, + }; + + var city_camera = rl.Camera3D{ + .position = rl.Vector3.init(18.0, 21.0, 18), + .target = rl.Vector3.init(0, 0, 0), + .up = rl.Vector3.init(0, 1.0, 0), + .fovy = 45, + .projection = rl.CameraProjection.camera_perspective, + }; + + const floorLevel = rl.Vector3.init(0.0, 0.0, 0.0); + const itemStatic = rl.Vector3.init(0.0, 1.0, 0.0); + const itemStaticSize = rl.Vector2.init(2.0, 2.0); + + var rotation_manager = RotationManager.init(.{ + .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"); + const chair1_rect = rl.Rectangle.init(0, 0, @as(f32, @floatFromInt(-chair1.width)), @as(f32, @floatFromInt(chair1.height))); + const chair2 = rl.Texture.init("resources/items/dorm/chair/chair_2.png"); + const chair2_rect = rl.Rectangle.init(0, 0, @as(f32, @floatFromInt(-chair2.width)), @as(f32, @floatFromInt(chair2.height))); + const city = rl.loadImage("resources/cities/city_0100/elevation.png"); + // const city_texture = rl.Texture.init("resources/cities/city_0100/vertexcolor.png"); + // TODO: figure out a better way to unload all images and textures. + defer { + rl.unloadTexture(splash); + rl.unloadTexture(logo); + rl.unloadTexture(chair1); + rl.unloadTexture(chair2); + rl.unloadImage(city); + } + + const mesh = rl.genMeshHeightmap(city, rl.Vector3.init(16, 8, 16)); + const model = rl.loadModelFromMesh(mesh); + + // model.materials[0].maps[rl.MATERIAL_MAP_DIFFUSE].texture = city_texture; + + while (!rl.windowShouldClose()) { + + // Update + // ------------------ + switch (current_screen) { + // Skip straight to lot view until city server is complete + .login => { + frame_counter += 1; + + if (frame_counter > 120) current_screen = .lot; + }, + // TODO: Write CAS (Create-A-Sim) screen + .cas => {}, + .map => {}, + .lot => { + const zoom_increment = 5; + // rotate with keyboard + if (rl.isKeyPressed(rl.KeyboardKey.key_s)) { + if (lot_camera.fovy == 10) { + lot_camera.fovy += zoom_increment; + } + + dbg.print("Zoom level: {d}\n", .{ + lot_camera.fovy, + }); + } else if (rl.isKeyPressed(rl.KeyboardKey.key_w)) { + if (lot_camera.fovy == 15) { + lot_camera.fovy -= zoom_increment; + } + + dbg.print("Zoom level: {d}\n", .{ + lot_camera.fovy, + }); + } + // roate with scrollwheel + const mouse_wheel_y = std.math.clamp(-rl.getMouseWheelMove(), -1, 1) * zoom_increment; + if (mouse_wheel_y != 0) { + const zoom_min = 10; + const zoom_max = 25; + lot_camera.fovy = std.math.clamp(lot_camera.fovy + mouse_wheel_y, zoom_min, zoom_max); + dbg.print("Zoom level: {d}\n", .{ + lot_camera.fovy, + }); + } + if (rl.isKeyPressed(rl.KeyboardKey.key_a)) { + lot_camera.position = rl.Vector3.init(-90.0, 20.0, 90.0); + rotation_manager.rotate(Rotations.left); + dbg.print("rotate left\n", .{}); + } else if (rl.isKeyPressed(rl.KeyboardKey.key_d)) { + lot_camera.position = rl.Vector3.init(90.0, 20.0, 90.0); + rotation_manager.rotate(Rotations.right); + dbg.print("rotate right\n", .{}); + } + + // camera.update(rl.CameraMode.camera_custom); + }, + } + // ------------------ + + // Draw + rl.beginDrawing(); + defer rl.endDrawing(); + + switch (current_screen) { + // Mockup loading screen, skips straight to world + .login => { + // Splash screen + rl.drawTexture(splash, 0, 0, rl.Color.white); + rl.drawTexture(logo, screen_width / 2.0 - 240, 30, rl.Color.white); + + // Loading text + rl.drawText("Reticulating splines...", 20, screen_height - 30, 20, rl.Color.white); + }, + // Skip this for now + .cas => {}, + .map => { + rl.clearBackground(rl.Color.sky_blue); + + city_camera.begin(); + defer city_camera.end(); + + rl.drawModel(model, floorLevel, 1.0, rl.Color.green); + }, + // Low view (i.e. world) + .lot => { + rl.clearBackground(rl.Color.sky_blue); + + lot_camera.begin(); + defer lot_camera.end(); + + rl.drawPlane(floorLevel, rl.Vector2.init(64, 64), rl.Color.dark_green); + switch (rotation_manager.Direction) { + .NorthWest => { + rl.drawBillboardRec(lot_camera, chair1, chair1_rect, itemStatic, itemStaticSize, rl.Color.white); + }, + .NorthEast => { + rl.drawBillboard(lot_camera, chair1, itemStatic, 2.0, rl.Color.white); + }, + .SouthEast => { + rl.drawBillboard(lot_camera, chair2, itemStatic, 2.0, rl.Color.white); + }, + .SouthWest => { + rl.drawBillboardRec(lot_camera, chair2, chair2_rect, itemStatic, itemStaticSize, rl.Color.white); + }, + } + + // rl.drawGrid(64, 1.0); + }, + } + + rl.drawFPS(10, 10); + } +} diff --git a/src/niotso.zig b/backup-src/niotso.zig similarity index 100% rename from src/niotso.zig rename to backup-src/niotso.zig diff --git a/backup-src/root.zig b/backup-src/root.zig new file mode 100644 index 0000000..ecfeade --- /dev/null +++ b/backup-src/root.zig @@ -0,0 +1,10 @@ +const std = @import("std"); +const testing = std.testing; + +export fn add(a: i32, b: i32) i32 { + return a + b; +} + +test "basic add functionality" { + try testing.expect(add(3, 7) == 10); +} diff --git a/src/simantics/.gitkeep b/backup-src/simantics/.gitkeep similarity index 100% rename from src/simantics/.gitkeep rename to backup-src/simantics/.gitkeep diff --git a/src/version.txt b/backup-src/version.txt similarity index 100% rename from src/version.txt rename to backup-src/version.txt diff --git a/src/vitaboy.zig b/backup-src/vitaboy.zig similarity index 100% rename from src/vitaboy.zig rename to backup-src/vitaboy.zig diff --git a/src/world.zig b/backup-src/world.zig similarity index 100% rename from src/world.zig rename to backup-src/world.zig diff --git a/build.zig b/build.zig index ee649f0..a3f31fe 100644 --- a/build.zig +++ b/build.zig @@ -15,17 +15,26 @@ pub fn build(b: *std.Build) void { // set a preferred release mode, allowing the user to decide how to optimize. const optimize = b.standardOptimizeOption(.{}); - const exe = b.addExecutable(.{ - .name = "mysim", - .root_source_file = b.path("src/main.zig"), + const lib = b.addStaticLibrary(.{ + .name = "mysimulation", + // In this case the main source file is merely a path, however, in more + // complicated build scripts, this could be a generated file. + .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, }); - // C headers - exe.linkLibC(); - exe.linkLibCpp(); - exe.addIncludePath(.{ .path = "./library" }); + // This declares intent for the library to be installed into the standard + // location when the user invokes the "install" step (the default step when + // running `zig build`). + b.installArtifact(lib); + + const exe = b.addExecutable(.{ + .name = "mysimulation", + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); // Modules const raylib_dep = b.dependency("raylib-zig", .{ @@ -34,25 +43,12 @@ pub fn build(b: *std.Build) void { }); const raylib = raylib_dep.module("raylib"); // main raylib module - const raylib_math = raylib_dep.module("raylib-math"); // raymath module - // const raylib_gui = raylib_dep.module("raylib-gui"); // raylib gui - const rlgl = raylib_dep.module("rlgl"); // rlgl module + const raygui = raylib_dep.module("raygui"); // raygui module const raylib_artifact = raylib_dep.artifact("raylib"); // raylib C library exe.linkLibrary(raylib_artifact); exe.root_module.addImport("raylib", raylib); - exe.root_module.addImport("raylib-math", raylib_math); - // exe.root_module.addImport("raylib-gui", raylib_gui); - exe.root_module.addImport("rlgl", rlgl); - - const clap_dep = b.dependency("clap", .{ - .target = target, - .optimize = optimize, - }); - - const clap = clap_dep.module("clap"); // main clap module - - exe.root_module.addImport("clap", clap); + exe.root_module.addImport("raygui", raygui); // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default @@ -82,26 +78,28 @@ pub fn build(b: *std.Build) void { const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); + // Creates a step for unit testing. This only builds the test executable + // but does not run it. + const lib_unit_tests = b.addTest(.{ + .root_source_file = b.path("src/root.zig"), + .target = target, + .optimize = optimize, + }); + + const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); + const exe_unit_tests = b.addTest(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); - exe_unit_tests.linkLibC(); - exe_unit_tests.linkLibCpp(); - exe_unit_tests.addIncludePath(.{ .path = "./library" }); - - exe_unit_tests.root_module.addImport("raylib", raylib); - exe_unit_tests.root_module.addImport("raylib-math", raylib_math); - // exe.root_module.addImport("raylib-gui", raylib_gui); - exe_unit_tests.root_module.addImport("rlgl", rlgl); - const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); // Similar to creating the run step earlier, this exposes a `test` step to // the `zig build --help` menu, providing a way for the user to request // running the unit tests. const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&run_lib_unit_tests.step); test_step.dependOn(&run_exe_unit_tests.step); } diff --git a/build.zig.zon b/build.zig.zon index a18b585..632db5a 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,13 +1,21 @@ .{ - .name = "mysim", + // This is the default name used by packages depending on this one. For + // example, when a user runs `zig fetch --save `, this field is used + // as the key in the `dependencies` table. Although the user can choose a + // different name, most users will stick with this provided value. + // + // It is redundant to include "zig" in this name because it is already + // within the Zig package namespace. + .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.101", + .version = "0.0.0", // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - .minimum_zig_version = "0.11.0", + //.minimum_zig_version = "0.11.0", // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. @@ -16,24 +24,15 @@ // internet connectivity. .dependencies = .{ .@"raylib-zig" = .{ - .url = "https://github.com/tonytins/raylib-zig/archive/refs/tags/v5.1.104-dev.tar.gz", - .hash = "12209530dc7475f8095a729a46082093578911b74d1cfde28802954fe23de1be411c", - }, - .clap = .{ - .url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.8.0.tar.gz", - .hash = "1220949d4e88864579067b6d4cdad6476c6176f27e782782c2c39b7f2c4817a10efb", + .url = "git+https://github.com/Not-Nik/raylib-zig?ref=devel#4d452b2bcd0157199d07c70d79d4f84e6f8bd659", + .hash = "1220c531f8d0bfbc18944b6084916c520834a951520a8c033fc576fef8b240ee0fc2", }, }, .paths = .{ - // This makes *all* files, recursively, included in this package. It is generally - // better to explicitly list the files and directories instead, to insure that - // fetching from tarballs, file system paths, and version control all result - // in the same contents hash. - "", + "build.zig", + "build.zig.zon", + "src", // For example... - //"build.zig", - //"build.zig.zon", - //"src", //"LICENSE", //"README.md", }, diff --git a/src/main.zig b/src/main.zig index 1321505..3774ddf 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,234 +1,32 @@ -const std = @import("std"); const rl = @import("raylib"); -const world = @import("world.zig"); -const nso = @import("niotso.zig"); -const clap = @import("clap"); -const dbg = std.debug; - -const GameScreen = enum { - login, - cas, // Create-A-Sim - map, // city screen - lot, // world view -}; - -//We start that NorthWest so it is easy to determine the flip -const CardinalDirection = enum { - NorthWest, // 0, sprite 1 - NorthEast, // 1, sprite 1 flip - SouthEast, // 2, sprite 2 - SouthWest, // 3, sprite 2 flip -}; - -const Rotations = enum { - left, // 0 - right, // 1 -}; - -const RotationManager = struct { - Direction: CardinalDirection, - - pub fn init(self: RotationManager) RotationManager { - return self; - } - - pub fn rotate(self: *RotationManager, rotation: Rotations) void { - //rotate the direction by 90 degrees - var direction_index = @as(i8, @intFromEnum(self.Direction)); - switch (rotation) { - .left => { - direction_index = direction_index - 1; - }, - .right => { - direction_index = direction_index + 1; - }, - } - // Circle around if out of bounds - if (direction_index < 0) { - self.Direction = CardinalDirection.SouthWest; - } else if (direction_index > 3) { - self.Direction = CardinalDirection.NorthWest; - } else { - self.Direction = @as(CardinalDirection, @enumFromInt(direction_index)); - } - //Result - dbg.print("Orientation: {any}\n", .{self.Direction}); - } -}; - -/// 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; + // Initialization + //-------------------------------------------------------------------------------------- + const screenWidth = 800; + const screenHeight = 450; - rl.initWindow(screen_width, screen_height, "My Simulation"); - defer rl.closeWindow(); + rl.initWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window"); + defer rl.closeWindow(); // Close window and OpenGL context - var current_screen: GameScreen = .login; - var frame_counter: i32 = 0; - - // NOTE: jip - // I don't think we can get away with using the built-in camera - // We need pixel perfect isometric camera - var lot_camera = rl.Camera3D{ - .position = rl.Vector3.init(-90.0, 20.0, 90.0), - .target = rl.Vector3.init(0, 0.0, 0), - .up = rl.Vector3.init(0, 1.0, 0), - .fovy = 10, - .projection = rl.CameraProjection.camera_orthographic, - }; - - var city_camera = rl.Camera3D{ - .position = rl.Vector3.init(18.0, 21.0, 18), - .target = rl.Vector3.init(0, 0, 0), - .up = rl.Vector3.init(0, 1.0, 0), - .fovy = 45, - .projection = rl.CameraProjection.camera_perspective, - }; - - const floorLevel = rl.Vector3.init(0.0, 0.0, 0.0); - const itemStatic = rl.Vector3.init(0.0, 1.0, 0.0); - const itemStaticSize = rl.Vector2.init(2.0, 2.0); - - var rotation_manager = RotationManager.init(.{ - .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"); - const chair1_rect = rl.Rectangle.init(0, 0, @as(f32, @floatFromInt(-chair1.width)), @as(f32, @floatFromInt(chair1.height))); - const chair2 = rl.Texture.init("resources/items/dorm/chair/chair_2.png"); - const chair2_rect = rl.Rectangle.init(0, 0, @as(f32, @floatFromInt(-chair2.width)), @as(f32, @floatFromInt(chair2.height))); - const city = rl.loadImage("resources/cities/city_0100/elevation.png"); - // const city_texture = rl.Texture.init("resources/cities/city_0100/vertexcolor.png"); - // TODO: figure out a better way to unload all images and textures. - defer { - rl.unloadTexture(splash); - rl.unloadTexture(logo); - rl.unloadTexture(chair1); - rl.unloadTexture(chair2); - rl.unloadImage(city); - } - - const mesh = rl.genMeshHeightmap(city, rl.Vector3.init(16, 8, 16)); - const model = rl.loadModelFromMesh(mesh); - - // model.materials[0].maps[rl.MATERIAL_MAP_DIFFUSE].texture = city_texture; - - while (!rl.windowShouldClose()) { + rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + // Main game loop + while (!rl.windowShouldClose()) { // Detect window close button or ESC key // Update - // ------------------ - switch (current_screen) { - // Skip straight to lot view until city server is complete - .login => { - frame_counter += 1; - - if (frame_counter > 120) current_screen = .lot; - }, - // TODO: Write CAS (Create-A-Sim) screen - .cas => {}, - .map => {}, - .lot => { - const zoom_increment = 5; - // rotate with keyboard - if (rl.isKeyPressed(rl.KeyboardKey.key_s)) { - if (lot_camera.fovy == 10) { - lot_camera.fovy += zoom_increment; - } - - dbg.print("Zoom level: {d}\n", .{ - lot_camera.fovy, - }); - } else if (rl.isKeyPressed(rl.KeyboardKey.key_w)) { - if (lot_camera.fovy == 15) { - lot_camera.fovy -= zoom_increment; - } - - dbg.print("Zoom level: {d}\n", .{ - lot_camera.fovy, - }); - } - // roate with scrollwheel - const mouse_wheel_y = std.math.clamp(-rl.getMouseWheelMove(), -1, 1) * zoom_increment; - if (mouse_wheel_y != 0) { - const zoom_min = 10; - const zoom_max = 25; - lot_camera.fovy = std.math.clamp(lot_camera.fovy + mouse_wheel_y, zoom_min, zoom_max); - dbg.print("Zoom level: {d}\n", .{ - lot_camera.fovy, - }); - } - if (rl.isKeyPressed(rl.KeyboardKey.key_a)) { - lot_camera.position = rl.Vector3.init(-90.0, 20.0, 90.0); - rotation_manager.rotate(Rotations.left); - dbg.print("rotate left\n", .{}); - } else if (rl.isKeyPressed(rl.KeyboardKey.key_d)) { - lot_camera.position = rl.Vector3.init(90.0, 20.0, 90.0); - rotation_manager.rotate(Rotations.right); - dbg.print("rotate right\n", .{}); - } - - // camera.update(rl.CameraMode.camera_custom); - }, - } - // ------------------ + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- // Draw + //---------------------------------------------------------------------------------- rl.beginDrawing(); defer rl.endDrawing(); - switch (current_screen) { - // Mockup loading screen, skips straight to world - .login => { - // Splash screen - rl.drawTexture(splash, 0, 0, rl.Color.white); - rl.drawTexture(logo, screen_width / 2.0 - 240, 30, rl.Color.white); + rl.clearBackground(rl.Color.white); - // Loading text - rl.drawText("Reticulating splines...", 20, screen_height - 30, 20, rl.Color.white); - }, - // Skip this for now - .cas => {}, - .map => { - rl.clearBackground(rl.Color.sky_blue); - - city_camera.begin(); - defer city_camera.end(); - - rl.drawModel(model, floorLevel, 1.0, rl.Color.green); - }, - // Low view (i.e. world) - .lot => { - rl.clearBackground(rl.Color.sky_blue); - - lot_camera.begin(); - defer lot_camera.end(); - - rl.drawPlane(floorLevel, rl.Vector2.init(64, 64), rl.Color.dark_green); - switch (rotation_manager.Direction) { - .NorthWest => { - rl.drawBillboardRec(lot_camera, chair1, chair1_rect, itemStatic, itemStaticSize, rl.Color.white); - }, - .NorthEast => { - rl.drawBillboard(lot_camera, chair1, itemStatic, 2.0, rl.Color.white); - }, - .SouthEast => { - rl.drawBillboard(lot_camera, chair2, itemStatic, 2.0, rl.Color.white); - }, - .SouthWest => { - rl.drawBillboardRec(lot_camera, chair2, chair2_rect, itemStatic, itemStaticSize, rl.Color.white); - }, - } - - // rl.drawGrid(64, 1.0); - }, - } - - rl.drawFPS(10, 10); + rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray); + //---------------------------------------------------------------------------------- } } diff --git a/src/root.zig b/src/root.zig new file mode 100644 index 0000000..ecfeade --- /dev/null +++ b/src/root.zig @@ -0,0 +1,10 @@ +const std = @import("std"); +const testing = std.testing; + +export fn add(a: i32, b: i32) i32 { + return a + b; +} + +test "basic add functionality" { + try testing.expect(add(3, 7) == 10); +}