0

I am trying to implement collisions with python, the collisions isn't the problem. I want to call a method inside another method using OOP, but it isn't recognised. Can you do this? How?

def collision_test(self,rect,tiles,x,y): #CREATING A RECT FOR THE GAME MAP(TILES) 
        hit_list = []   
        for tile in tiles:
           if rect.colliderect(tile):
                hit_list.append(tile)
        return hit_list
def move(self,rect,x,y,tiles): #testing collisions
        collision_types = {'top': False, 'bottom': False, 'right': False, 'left': False}
        rect.x += x
        hit_list = collision_test(self,rect,tiles)
        for tile in hit_list:
            if self.move_right == True:
                rect.right = tile.left

Here collision_test isn't recognised.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
CAKE
  • 49
  • 5

1 Answers1

1

You have to call self.collision_test(rect,tiles) instead of collision_test(self,rect,tiles).

However, the signature aren't matching. Your collision_test expects x and y arguments too. That might causes troubles too.

Raida
  • 1,206
  • 5
  • 17