News for hackers. Stuff that matters.
Re:LÖVE: a framework to make 2D games in Lua by dgb23 on Wednesday September 13, 2023 @07:51AM (#37495495)
> It's also a ton of fun until you segfault 3 mins into gameplay and you have no idea why. But then you can only blame yourself!

Raylib has a ton of language bindings. I've been using it with Zig, the integration was seamless and have not encountered these types of bugs yet.

Re:LÖVE: a framework to make 2D games in Lua by stratts on Wednesday September 13, 2023 @10:49AM (#37497489)
You don't even necessarily need bindings to use Raylib in Zig. It uses Zig's build system so you can just clone Raylib's repo, add a couple of lines to build.zig, and it's ready to go with autocompletion and everything.

Both Raylib and Zig include all dependencies too, so I was able to build a single 700kb .exe from Linux, copy that to my Windows machine, and it just worked immediately without any issues. Pretty amazing.

Re:LÖVE: a framework to make 2D games in Lua by rishav_sharan on Wednesday September 13, 2023 @01:18PM (#37499124)
Would you have any tutorial on how to do this? I am unable to get zig .11 to work with the latest raylib without binding libs. I am not sure what all changes I need to make to build.zig
Re:LÖVE: a framework to make 2D games in Lua by stratts on Wednesday September 13, 2023 @07:46PM (#37503132)
This is what works for me, assuming an clean project created using 'zig init-exe':

At the top of your build.zig, import the raylib build.zig inside raylib's /src folder (exact path will depend where you've cloned raylib)

  const raySdk = @import("raylib/src/build.zig");
Use the imported addRaylib() function to build raylib, then link to the exe and add include path

  var raylib = raySdk.addRaylib(b, target, optimize, .{});
  exe.addIncludePath(.{ .path = "raylib/src" });
  exe.linkLibrary(raylib);
After that, you should be fine to just use @cImport to use raylib within your project

  const ray = @cImport({
    @cInclude("raylib.h");
  });

  pub fn main() void {
    ray.InitWindow(800, 450, "raylib [core] example - basic window");
    ...
Re:LÖVE: a framework to make 2D games in Lua by rishav_sharan on Thursday September 14, 2023 @05:18AM (#37506662)
Thank you. It worked perfectly for me. I was doing most of these but I was messing up the include path. your code samples helped me fix the issues in my build file. Have a great day!