Guest User

Untitled

a guest
Jul 24th, 2024
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. function player:revertCollision(overlapX, overlapY)
  2.     if overlapX ~= 0 then
  3.         if self.velocityX > 0 then
  4.             self.x = self.x - overlapX
  5.         elseif self.velocityX < 0 then
  6.             self.x = self.x + overlapX
  7.         end
  8.         self.velocityX = 0
  9.     end
  10.  
  11.     if overlapY ~= 0 then
  12.         if self.velocityY > 0 then
  13.             self.y = self.y - overlapY
  14.         elseif self.velocityY < 0 then
  15.             self.y = self.y + overlapY
  16.         end
  17.         self.velocityY = 0
  18.     end
  19.  
  20.     self.boundingRectangle.x = self.x
  21.     self.boundingRectangle.y = self.y
  22. end
Advertisement
Add Comment
Please, Sign In to add comment