function CheckBoxCollision(x1,y1,w1,h1,x2,y2,w2,h2)
return x1 < x2+w2 and x2 < x1+w1 and y1 < y2+h2 and y2 < y1+h1
end
function love.update(dt)
if love.keyboard.isDown("left") then
player1.x = player1.x - (120 * dt)
end
if love.keyboard.isDown("right") then
player1.x = player1.x + (120 * dt)
end
if love.keyboard.isDown("up") then
player1.y = player1.y - (120 * dt)
end
if love.keyboard.isDown("down") then
player1.y = player1.y + (120 * dt)
end
if CheckBoxCollision(player1.x, player1.y, player1.width,
player1.height, box1.x, box1.y, box1.width, box1.height) or
CheckBoxCollision(player1.x, player1.y, player1.width,
player1.height, box2.x, box2.y, box2.width, box2.height) then
player1.collided = true
else
player1.collided = false
end
end