Bonjour, j'espère être au bon endroit.
voici:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pygame
 
surf = pygame.display.set_mode((800,600))
run = True
posX = 30
vx = 1
posY = 30
vy = 1
clock=pygame.time.Clock()
while run :
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      run = False
  clock.tick(60)
  surf.fill((0,0,0))
  pygame.draw.circle(surf, (255,0,0), (posX, 300), 30, 2)
  if posX>770 or posX<30 :
    vx=-vx
  posX = posX + vx
  pygame.draw.circle(surf, (255,0,0), (400, posY), 30, 2)
  if posY>570 or posY<30 :
    vy=-vy
  posY = posY + vy
  pygame.display.flip()
pygame.quit()
Je me demandais s'il y avait un moyen de savoir à quels moments les deux cercles se touchent.