Skip to content
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
allyourcodebasePublic archive

About

Box2D packaged for the Zig build system

Resources

Stars

15 stars

Watchers

2 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Box2D

This is the Box2D physics engine packaged for the Zig build system. The upstream repo has a build.zig, so now this repo has been archived.

Usage

Add the dependency to your build.zig.zon:

zig fetch --save git+https://github.com/allyourcodebase/box2d#main

Use the dependency in your build.zig:

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const box2d = b.dependency("box2d", .{
        .target = target,
        .optimize = optimize,
    });

    const exe = b.addExecutable(.{
        // ...
    });
    exe.addIncludePath(box2d.path("."));
    exe.linkLibrary(box2d.artifact("box2d"));

    // ...
}

Import and use the C library:

const c = @cImport({
    @cInclude("box2d/box2d.h");
});

pub fn main() void {
    const world_def = c.b2DefaultWorldDef();
    const world = c.b2CreateWorld(&world_def);
    // ...
}

Examples

This build script can also run the official examples. From this repository run:

zig build -Dtest run

About

Box2D packaged for the Zig build system

Resources

Stars

15 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages