O
O
OccamaRazor2017-04-19 07:16:22
Python
OccamaRazor, 2017-04-19 07:16:22

Moving objects in Pygame?

When moving an object into the area of ​​another, the second disappears under the first, as it falls into the area of ​​the first. How to separate objects so that they do not disappear under each other?

class Character(pygame.sprite.Sprite):
    def __init__(self,rect):
        self.rect = pygame.Rect(rect)
        self.click = False
        self.image = pygame.image.load("alienBeige.png")

x = 99
for i in range(9):
    Player = Child((x,0,60,60))
    brr.append(Player)
    x += 99

go = True
while go:
    for event in pygame.event.get():
        for p in brr:
            if event.type == pygame.MOUSEBUTTONDOWN:
                if p.rect.collidepoint(event.pos):
                    p.click = True
                    print("Player",event.pos)
            elif event.type == pygame.MOUSEBUTTONUP:
                p.click = False
                print("Old coordinate",event.pos)
            elif event.type == pygame.QUIT:
                go = False

Video : https://youtu.be/YG_FaajMav0

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question