I'm very new to this, so can anyone tell me what I am missing?
Thanks
(code below)
Code: Select all
function love.load()
world = love.physics.newWorld(650, 650) --create a world for the bodies to exist in with width and height of 2,000
world:setGravity(0, 700) --the x component of the gravity will be 0, and the y component of the gravity will be 700
world:setMeter(64) --the height of a meter in this world will be 64px
bodies = {} --create tables for the bodies and shapes so that the garbage collector doesn't delete them
shapes = {}
joints = {}
max_balls = 40
for i=0,max_balls,1 do
bodies[i] = love.physics.newBody(world, 20+(i*20), 20, 1, 0) --remember, the body anchors from the center of the shape
shapes[i] = love.physics.newCircleShape(bodies[i], 0, 0, 5) --the ball has a shape of 20
if i > 0 then
joints[i] = love.physics.newDistanceJoint( bodies[(i-1)], bodies[(i)], 20+((i-1)*20), 20, 20+((i)*20), 20 )
end
end
joints[0] = love.physics.newMouseJoint( bodies[0], 20, 20 ) -- We set the first joint as a set point
--initial graphics setup
love.graphics.setBackgroundColor(104, 136, 248) --set the background color to a nice blue
love.graphics.setMode(650, 650, false, true, 0) --set the window dimensions to 650 by 650
end
function love.update(dt)
world:update(dt) --this puts the world into motion
end
function love.draw()
for i=0,max_balls,1 do
love.graphics.circle("fill", bodies[i]:getX(), bodies[i]:getY(), shapes[i]:getRadius(), 5)
end
end