У меня есть игра, и я хочу, чтобы игра добавляла одно очко, когда игрок касается ребенка.Я знаю, как добавить счет, но я не знаю, как заставить систему понять, что между ними произошло столкновение.
Это основная часть моего кода:
while Level1:
thing_rect = pygame.Rect(random.randrange(display_width), -60, 40, 40)
thing_speed = 2
while lives == 3:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
# adds the images and movement
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
x_Pl = x_Pl - 40
elif event.key == pygame.K_RIGHT:
x_Pl = x_Pl + 40
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
x_Pl = x_Pl + 0
gameDisplay.blit(Level1_Back, (0,0) )
smallText_2 = pygame.font.Font("LSANS.ttf", 20)
textSurf, textRect = text_objects("Use the arrow keys to move", smallText_2, black)
textRect.center = ( (730+(180/2)), (200+(50/2)) )
gameDisplay.blit(textSurf, textRect)
gameDisplay.blit(lives_3, (10, 10) )
gameDisplay.blit(Character_1, (x_Pl, 275))
thing_rect.y += thing_speed
if thing_rect.y > display_height:
thing_rect.y = 0 - thing_rect.height
thing_rect.x = random.randrange(display_width)
gameDisplay.blit(Baby_1, thing_rect)
pygame.display.update()
Спасибо за всю помощь.(Если вам нужно больше кода, просто скажите мне)