Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Local collisons

edited December 2013 in General Posts: 577

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


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



EDIT: Also, I think the problem might be in sorting the y value or the x, because they they loose their "friend."


  • IgnatzIgnatz Mod
    Posts: 5,396

    It's hard to make sense of your code because you don't indent it and a couple of lines are faulty.

    You don't seem to have enough end statements either.

  • Posts: 577

    Sorry, I think I fixed it!

Sign In or Register to comment.