Hi! In my thread: “Less Lag In Building Game” I made my own custom physics engine, wich works ok if you are not trying to do what I’m doing now, looping only 60 blocks around do. I’m not really sure what the problem is, because when ever I try to debug it, nothing happens!
I do this whenever a new block is placed, to find where it belongs
table.sort(blocksy)
table.sort(blocksx)
And this is in the draw loop
for i=math.floor(char.x)/25 - 30, math.floor(char.x)/25 + 30 do --I divide it by twenty-five because each block is twenty-five by twenty-five
if blocksx[i] ~= nil then
if math.abs(char.x - blocksx[i])<25/2 and
math.abs(char.y-blocksy[i] - 25/2)< 1 + charH/2 then char.y = char.y + 0.1 --20 use to be 12
end
end
end
for i=math.floor(char.x)/25 - 30, math.floor(char.x)/25 + 30 do
if blocksy[i] ~= nil then
if math.abs(char.x-blocksx[i])<25/2 and math.abs(char.y-blocksy[i])<25/2 + charH/2 - 1
then
char.x = char.x - 0.1
end
end
end
Thanks,
Prynok
EDIT: Also, I think the problem might be in sorting the y value or the x, because they they loose their “friend.”