-- Pushes an object out of the slope it hit.function hit_slope(dir, tile_x, tile_y, mom, slope, was_onfloor) -- Not done yet: X collisions, cieling slopes. --if (not dir) or (slope < 4) or (mom < 0) then if(not dir) or (mom < 0) then return false end local x = math.floor(obj.x/FRACUNIT - tile_x*TILE) local nx = math.floor(tile_x*TILE - obj.x/FRACUNIT) + TILE local y = math.floor(obj.y/FRACUNIT + obj.collision.h - tile_y*TILE) local ny = math.floor(tile_y*TILE - obj.y/FRACUNIT) + TILE if (x < 0) or (x > TILE) or (y < 0) or (y > TILE) then -- No collision. return false end if (slope == 0) then if (x < math.floor(y/2)) and (not was_onfloor) then return false end obj.x = (tile_x*TILE - math.floor(y/2) + obj.collision.w)*FRACUNIT elseif (slope == 1) then if (x < math.floor(y/2 + TILE/2)) and (not was_onfloor) then return false end obj.x = (tile_x*TILE - math.floor(y/2 + TILE/2) + obj.collision.w)*FRACUNIT elseif (slope == 2) then if (x < math.floor(ny/2 + TILE/2)) and (not was_onfloor) then return false end obj.x = (tile_x*TILE - math.floor(ny/2 + TILE/2) + obj.collision.w)*FRACUNIT elseif (slope == 3) then if (x < math.floor(ny/2)) and (not was_onfloor) then return false end obj.x = (tile_x*TILE - math.floor(ny/2) + obj.collision.w)*FRACUNIT --Floor slopes now. elseif (slope == 4) then if (y < math.floor(x/2)) and (not was_onfloor) then return false end obj.y = (tile_y*TILE + math.floor(x/2) - obj.collision.h)*FRACUNIT elseif (slope == 5) then if (y < math.floor(x/2 + TILE/2)) and (not was_onfloor) then return false end obj.y = (tile_y*TILE + math.floor(x/2 + TILE/2) - obj.collision.h)*FRACUNIT elseif (slope == 6) then if (y < math.floor(nx/2 + TILE/2)) and (not was_onfloor) then return false end obj.y = (tile_y*TILE + math.floor(nx/2 + TILE/2) - obj.collision.h)*FRACUNIT elseif (slope == 7) then if (y < math.floor(nx/2)) and (not was_onfloor) then return false end obj.y = (tile_y*TILE + math.floor(nx/2) - obj.collision.h)*FRACUNIT end obj.momy = 0 obj.onfloor = 2 return trueend