Created
May 15, 2012 07:08
-
-
Save fjolnir/2699688 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(200,100)), { | |
dynamo.createBoxShape(vec2(200,100)) | |
}) | |
box.location = vec2(110, 700) | |
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) | |
circle.collisionHandler = function(entity, world, 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 | |
circle:createPinJoint(box, vec2(0, 20), vec2(-20,-20)) | |
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