Was just poking Love2D, and noticed it has a 2D physics engine.
Hi there, I’m the physics guy at Two Lives Left (see Crabitron). I’ve started integrating Box2D into Codea and it works pretty well. At the moment I’ve only got circle’s and no contact events. Here’s the example I’m working with at the moment.
body = nil
ground = nil
-- Use this function to perform your initial setup
print("Hello Physics World!")
body = circleBody(WIDTH * 0.5,WIDTH * 0.5,100)
body.restitution = 0.9
body.radius = 50
ground = circleBody(WIDTH * 0.5 + 5, 100, 100)
ground.type = STATIC
-- This function gets called once every frame
-- This sets the background color to black
background(0, 0, 0)
if body then
stroke(255, 0, 0, 255)
line(0, 0, body.radius, 0)
ellipse(0, 0, body.radius * 2, body.radius * 2)
if CurrentTouch.state == BEGAN then
body.y = body.y + 100
if body.y < 0 then
body = nil
stroke(255, 183, 0, 255)
ellipse(ground.x, ground.y, ground.radius * 2, ground.radius * 2)
You basically just create a circleBody with a position and radius. You can then set any other property. We are also looking at having polygonBody as well, which will have an inline editor for editing the vertices, as well as automatic convex decomposition. We will also probably have a compositeBody, which can combine several basic shape bodies.
Let me know what you think.
I think that’s totally cool, is what I think. I never messed with Box2D past the circles/rectangles stuff - no links or chains or joints or such - so what you describe would keep me busy for a while. It sounds very much like you’re on the right track.
I hope the b2world object ref will be accessible so that we could set its gravity interactively.