this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add raylib

+46 -58
+13
build.zig
··· 57 57 // 58 58 // If neither case applies to you, feel free to delete the declaration you 59 59 // don't need and to put everything under a single module. 60 + const raylib_dep = b.dependency("raylib_zig", .{ 61 + .target = target, 62 + .optimize = optimize, 63 + }); 64 + 65 + const raylib = raylib_dep.module("raylib"); // main raylib module 66 + const raygui = raylib_dep.module("raygui"); // raygui module 67 + const raylib_artifact = raylib_dep.artifact("raylib"); // raylib C library 68 + 60 69 const exe = b.addExecutable(.{ 61 70 .name = "zig_civ", 62 71 .root_module = b.createModule(.{ ··· 79 88 // can be extremely useful in case of collisions (which can happen 80 89 // importing modules from different packages). 81 90 .{ .name = "zig_civ", .module = mod }, 91 + .{ .name = "raylib", .module = raylib }, 92 + .{ .name = "raygui", .module = raygui }, 82 93 }, 83 94 }), 84 95 }); 96 + 97 + exe.linkLibrary(raylib_artifact); 85 98 86 99 // This declares intent for the executable to be installed into the 87 100 // install prefix when running `zig build` (i.e. when executing the default
+4 -37
build.zig.zon
··· 32 32 // Once all dependencies are fetched, `zig build` no longer requires 33 33 // internet connectivity. 34 34 .dependencies = .{ 35 - // See `zig fetch --save <url>` for a command-line interface for adding dependencies. 36 - //.example = .{ 37 - // // When updating this field to a new URL, be sure to delete the corresponding 38 - // // `hash`, otherwise you are communicating that you expect to find the old hash at 39 - // // the new URL. If the contents of a URL change this will result in a hash mismatch 40 - // // which will prevent zig from using it. 41 - // .url = "https://example.com/foo.tar.gz", 42 - // 43 - // // This is computed from the file contents of the directory of files that is 44 - // // obtained after fetching `url` and applying the inclusion rules given by 45 - // // `paths`. 46 - // // 47 - // // This field is the source of truth; packages do not come from a `url`; they 48 - // // come from a `hash`. `url` is just one of many possible mirrors for how to 49 - // // obtain a package matching this `hash`. 50 - // // 51 - // // Uses the [multihash](https://multiformats.io/multihash/) format. 52 - // .hash = "...", 53 - // 54 - // // When this is provided, the package is found in a directory relative to the 55 - // // build root. In this case the package's hash is irrelevant and therefore not 56 - // // computed. This field and `url` are mutually exclusive. 57 - // .path = "foo", 58 - // 59 - // // When this is set to `true`, a package is declared to be lazily 60 - // // fetched. This makes the dependency only get fetched if it is 61 - // // actually used. 62 - // .lazy = false, 63 - //}, 35 + .raylib_zig = .{ 36 + .url = "git+https://github.com/raylib-zig/raylib-zig?ref=devel#a4d18b2d1cf8fdddec68b5b084535fca0475f466", 37 + .hash = "raylib_zig-5.6.0-dev-KE8REL5MBQAf3p497t52Xw9P7ojndIkVOWPXnLiLLw2P", 38 + }, 64 39 }, 65 - // Specifies the set of files and directories that are included in this package. 66 - // Only files and directories listed here are included in the `hash` that 67 - // is computed for this package. Only files listed here will remain on disk 68 - // when using the zig package manager. As a rule of thumb, one should list 69 - // files required for compilation plus any license(s). 70 - // Paths are relative to the build root. Use the empty string (`""`) to refer to 71 - // the build root itself. 72 - // A directory listed here means that all files within, recursively, are included. 73 40 .paths = .{ 74 41 "build.zig", 75 42 "build.zig.zon",
+29 -21
src/main.zig
··· 1 1 const std = @import("std"); 2 2 const zig_civ = @import("zig_civ"); 3 3 4 - pub fn main() !void { 5 - // Prints to stderr, ignoring potential errors. 6 - std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); 7 - try zig_civ.bufferedPrint(); 8 - } 4 + const rl = @import("raylib"); 9 5 10 - test "simple test" { 11 - const gpa = std.testing.allocator; 12 - var list: std.ArrayList(i32) = .empty; 13 - defer list.deinit(gpa); // Try commenting this out and see if zig detects the memory leak! 14 - try list.append(gpa, 42); 15 - try std.testing.expectEqual(@as(i32, 42), list.pop()); 16 - } 6 + pub fn main() anyerror!void { 7 + // Initialization 8 + //-------------------------------------------------------------------------------------- 9 + const screenWidth = 800; 10 + const screenHeight = 450; 17 11 18 - test "fuzz example" { 19 - const Context = struct { 20 - fn testOne(context: @This(), input: []const u8) anyerror!void { 21 - _ = context; 22 - // Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case! 23 - try std.testing.expect(!std.mem.eql(u8, "canyoufindme", input)); 24 - } 25 - }; 26 - try std.testing.fuzz(Context{}, Context.testOne, .{}); 12 + rl.initWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window"); 13 + defer rl.closeWindow(); // Close window and OpenGL context 14 + 15 + rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second 16 + //-------------------------------------------------------------------------------------- 17 + 18 + // Main game loop 19 + while (!rl.windowShouldClose()) { // Detect window close button or ESC key 20 + // Update 21 + //---------------------------------------------------------------------------------- 22 + // TODO: Update your variables here 23 + //---------------------------------------------------------------------------------- 24 + 25 + // Draw 26 + //---------------------------------------------------------------------------------- 27 + rl.beginDrawing(); 28 + defer rl.endDrawing(); 29 + 30 + rl.clearBackground(.white); 31 + 32 + rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray); 33 + //---------------------------------------------------------------------------------- 34 + } 27 35 }