View difference between Paste ID: 1G5PUYMX and f5A8bn7Y
SHOW: | | - or go back to the newest paste.
1
function concaveGroundTransition(heading, direction)
2
  local bounds = boundingBox()
3
4
  local wallCheckRegion = {
5
    bounds[1] + heading[1] + 0.125,
6
    bounds[2] + heading[2] + 0.125,
7
    bounds[3] + heading[1] - 0.125,
8
    bounds[4] + heading[2] - 0.125
9
  }
10
11-
  if self.groundDirection[1] < 0 then wallCheckRegion[1] = wallCheckRegion[1] + 1.0 end
11+
12-
  if self.groundDirection[1] > 0 then wallCheckRegion[3] = wallCheckRegion[3] - 1.0 end
12+
13-
  if self.groundDirection[2] < 0 then wallCheckRegion[2] = wallCheckRegion[2] + 1.0 end
13+
  if self.groundDirection[1] < 0 then 
14-
  if self.groundDirection[2] > 0 then wallCheckRegion[4] = wallCheckRegion[4] - 1.0 end
14+
    wallCheckRegion[1] = wallCheckRegion[1] + 1.0
15
  elseif self.groundDirection[1] > 0 then 
16
    wallCheckRegion[3] = wallCheckRegion[3] - 1.0 
17
  end
18-
      util.debugLog("hit wall at %s", heading)
18+
19
  if self.groundDirection[2] < 0 then
20
    wallCheckRegion[2] = wallCheckRegion[2] + 1.0
21
   elseif self.groundDirection[2] > 0 then
22
    wallCheckRegion[4] = wallCheckRegion[4] - 1.0 
23-
  return heading
23+
24
25
26
  if world.rectTileCollision(wallCheckRegion, "Dynamic") then
27
    if setGroundDirection(heading) then
28
      heading = headingFromDirection(direction)
29
      world.logInfo("hit wall at %q", heading)
30
      return heading
31
    end
32
  end
33
34
  return nil
35
end