Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  12. -- Walls must be higher than one block off the ground
  13. if self.groundDirection[1] < 0 then
  14. wallCheckRegion[1] = wallCheckRegion[1] + 1.0
  15. elseif self.groundDirection[1] > 0 then
  16. wallCheckRegion[3] = wallCheckRegion[3] - 1.0
  17. end
  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. end
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement