mixster

mixster

Apr 11th, 2010
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1.     def move_single_axis(self, dx, dy):
  2.         self.rect.x += dx
  3.         self.rect.y += dy
  4.        
  5.         tx, ty = int(player.rect.x / 16), int(player.rect.y / 16)
  6.         rects = [[tx, ty],[tx + 1, ty],[tx, ty + 1],[tx + 1, ty + 1]]
  7.  
  8.         for h in rects:
  9.             if walls[int(h[0])][int(h[1])].tNum == 1:
  10.                 wam = walls[int(h[0])][int(h[1])].rect
  11.                 if self.rect.colliderect(wam):
  12.                     if dx > 0:
  13.                         self.rect.right = wam.left
  14.                     if dx < 0:
  15.                         self.rect.left = wam.right
  16.                     if dy > 0:
  17.                         self.rect.bottom = wam.top
  18.                         global jump
  19.                         jump = 0
  20.                         speed[1] = 0
  21.                     if dy < 0:
  22.                         self.rect.top = wam.bottom
  23.                         speed[1] = 0
  24.                     return
Add Comment
Please, Sign In to add comment