So in my pygame game, I have created a list of objects to make things like updating them all and collision checking easier. So when I'm collision checking, I have to check if the current object is the same as the object we are collision checking with. Here is my current code:
def placeMeeting(self, object1, object2):
# Define positioning variables
object1Rect = pygame.Rect(object1.x, object1.y, object1.width, object1.height)
# Weather or not they collided
coll = False
# Loop through all walls to check for possible collision
for i in range(len(self.instances)):
# First check if it's the right object
if (self.instances[i] == object2):
print "yep"
object2Rect = pygame.Rect(self.instances[i].x, self.instances[i].y, self.instances[i].width, self.instances[i].height)
# Check for collision with current wall -- Horizontal
if (object1Rect.colliderect(object2Rect)):
coll = True
# Return the final collision result
return coll
(All objects in the list/array are a child to the su)