Code: Select all
function physics(table)
for i,obj in ipairs(table) do
if obj.solid then
for i,newobj in ipairs(table) do
if (obj.y + obj.height + obj.yspeed) > newobj.y and (obj.x > newobj.x or (obj.x + obj.width) < (newobj.x + newobj.width)) then
obj.isGrounded = true
else
obj.isGrounded = false
end
end
if not(obj.isGrounded) then
obj.yspeed = obj.yspeed + gravity
end
end
end
end
end