Created
May 16, 2012 11:40
-
-
Save fjolnir/2709732 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local box = dynamo.createEntity(dynamo.world, nil, 1, dynamo.world.momentForBox(1, vec2(32*sprite.scale,32*sprite.scale)), { | |
dynamo.createBoxShape(vec2(32*sprite.scale,32*sprite.scale)) | |
}) | |
box.location = vec2(110, 700) | |
function box:updateHandler() | |
sprite.angle = self:angle() | |
sprite.location.xy = self:location() | |
end | |
local circle = dynamo.createEntity(dynamo.world, nil, 1, dynamo.world.momentForCircle(1, 0, 70, vec2_zero), { | |
dynamo.createCircleShape(vec2(0, 0), 70) | |
}) | |
circle.elasticity = 1 | |
circle.location = vec2(200, 500) | |
function circle:collisionHandler(collisionInfo) | |
if collisionInfo.b == box then | |
local pt = collisionInfo.contactPoints.points[0].point | |
print("box and circle collided", pt.x, pt.y) | |
else | |
print("circle collided") | |
end | |
end | |
local joint = circle:createPinJoint(box, vec2(0, 60), vec2(-20,-20)) | |
joint = nil | |
dynamo.world:addEntity(box) | |
dynamo.world:addEntity(circle) | |
dynamo.world.staticEntity:addShape(dynamo.createSegmentShape(vec2(0,200), vec2(400, 0))) | |
dynamo.world.staticEntity:addShape(dynamo.createSegmentShape(vec2(400,0), vec2(800, 200))) | |
dynamo.world.staticEntity:addShape(dynamo.createSegmentShape(vec2(0,0), vec2(0, 980))) | |
dynamo.world.staticEntity:addShape(dynamo.createSegmentShape(vec2(0,0), vec2(640, 0))) | |
dynamo.world.staticEntity:addShape(dynamo.createSegmentShape(vec2(0,980), vec2(640, 980))) | |
dynamo.world.staticEntity:addShape(dynamo.createSegmentShape(vec2(640,0), vec2(640, 980))) | |
dynamo.renderer:pushRenderable( | |
dynamo.renderable(function(renderer, renderable, timeSinceLastFrame, interpolation) | |
dynamo.world:draw(false) | |
end) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment