Nov-12-2019, 01:51 AM
Hello,
This is a piece of my current project. It is in my "class Player()". It's pretty standard, but not working. The "walls" group is defined globally at the top, and when tested has sprites in it, yet my player sprite just moves right through walls and I don't get any errors.
This is a piece of my current project. It is in my "class Player()". It's pretty standard, but not working. The "walls" group is defined globally at the top, and when tested has sprites in it, yet my player sprite just moves right through walls and I don't get any errors.
def move(self, dx=0, dy=0): if not self.collide_with_walls(dx, dy): self.rect.x += dx * tile_size self.rect.y += dy * tile_size def collide_with_walls(self, dx=0, dy=0): for wall in walls: if wall.rect.x==self.rect.x + dx and wall.rect.y == self.rect.y + dy: return True return False