Help Me
Posted: Thu Jan 21, 2016 4:18 am
why sometimes this together and sometimes not?
GooD
Bug?
GooD
Bug?
Code: Select all
function love.load ()
-- body...
love.physics.setMeter(30)
world = love.physics.newWorld(0, 0, true)
objeto = {}
objeto.block1 = {}
objeto.block1.x = love.graphics.getWidth()/2
objeto.block1.y = love.graphics.getHeight()/2
objeto.block1.body = love.physics.newBody(world, objeto.block1.x, objeto.block1.y,"dynamic")
objeto.block1.shape = love.physics.newRectangleShape(0, 0,30,30)
objeto.block1.fixture = love.physics.newFixture(objeto.block1.body, objeto.block1.shape,0)
objeto.block2 = {}
objeto.block2.x =150
objeto.block2.y = 150
objeto.block2.body = love.physics.newBody(world, objeto.block2.x, objeto.block2.y)
objeto.block2.shape = love.physics.newRectangleShape(0, 0,30,200)
objeto.block2.fixture = love.physics.newFixture(objeto.block2.body, objeto.block2.shape)
end
function love.update (dt)
-- body...
world:update(dt)
if love.keyboard.isDown("right") then
objeto.block1.body:setLinearVelocity(200,0)
elseif love.keyboard.isDown("left") then
objeto.block1.body:setLinearVelocity(-200,0)
elseif love.keyboard.isDown("up") then
objeto.block1.body:setLinearVelocity(0,-200)
elseif love.keyboard.isDown("down") then
objeto.block1.body:setLinearVelocity(0,200)
else
objeto.block1.body:setLinearVelocity(0,0)
end
end
function love.draw ()
-- body...
love.graphics.setColor(50, 50, 50)
love.graphics.polygon("fill", objeto.block1.body:getWorldPoints(objeto.block1.shape:getPoints()))
love.graphics.setColor(50, 50, 50)
love.graphics.polygon("fill", objeto.block2.body:getWorldPoints(objeto.block2.shape:getPoints()))
end