---
title: "luaBox2D: Box2D physics for Lua"
description: "Lua bindings for the Box2D physics engine, so games can be scripted in Lua with real physics."
date: 2018-04-05T10:23:14+02:00
lastmod: 2026-10-16T18:58:52+02:00
url: https://klimek.link/projects/luabox2d/
author: "Marcin Klimek"
source: https://klimek.link/projects/luabox2d/
---

# luaBox2D: Box2D physics for Lua

I wrote **luaBox2D** to expose the **Box2D** 2D physics engine to **Lua**, and it became the physics layer behind the Lua-scripted games in [Cinder Climb](/projects/cc/).

Nearly the whole Box2D API has a Lua counterpart, from worlds, bodies and fixtures through every shape and joint type to contacts, ray casts, queries and filters, so a Lua script reads almost like the C++ "Hello World" from the Box2D manual:

*Diagram: Where luaBox2D sits between a Lua script and Box2D*

```lua
local box2d = require 'LuaBox2D'
local world = box2d.World(box2d.Vec2(0, -10))

local bodyDef = box2d.BodyDef()
bodyDef.type = 'dynamic'
bodyDef.position = box2d.Vec2(0, 4)
local body = world.createBody(bodyDef)
```

The bindings are written in C++ and built with CMake against Lua 5.1, and there are Lua tests for the main classes in the repository.

[Source on GitHub](https://github.com/marcinklimek/luaBox2D).

Source: https://klimek.link/projects/luabox2d/
