Bonjour je suis débutant en Python et je souhaite créer des objets (ici missiles, shurikens) avec des points de coordonnées y randint pour les 2 mais je souhaite que les 2 ne se touchent pas.
Savez vous comment faire svp.

mon code :

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import  pygame
from random import *
from pygame.locals import *
 
blue = (113,177,227) #valeur max =255.
white = (255,255,255)
black = (0, 0, 0)
 
pygame.init()
 
surfaceW = 800
surfaceH = 500
persoW = 50
persoH = 66
shurikenW = 300
shurikenH = 300
missileW = 300
missileH = 150
 
 
surface = pygame.display.set_mode((surfaceW,surfaceH))
pygame.display.set_caption("main")
 
perso = pygame.image.load('perso.png')
 
obstacle = pygame.image.load('shuriken.png').convert()
obstacle.set_colorkey((255,255,255))
 
missile = pygame.image.load('missile.png').convert()
missile.set_colorkey((255, 255, 255))
 
 
def personnage(x,y, image):
    surface.blit(image, (x, y))
 
def shuriken(x,y, image ):
    surface.blit(image, (x, y))
 
def lance_roquette(x, y, image):
    surface.blit(image, (x, y))
 
 
 
def main():
    x_perso = 0
    y_perso = 360
    y_move = 0
    x_move = 0
 
    x_shuriken = surfaceW
    y_shuriken = randint(0, 450)
    shuriken_vitesse = 1
 
    x_missile = surfaceW
    y_missile = randint(50,400)
    missile_vitesse = 0.60
 
 
    game_over = False
 
    while not game_over:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game_over= True
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    y_move = -0.50
                if event.key == pygame.K_DOWN:
                    y_move = 0.50
            if event.type == pygame.KEYUP:
                y_move = 0
 
 
 
        y_perso += y_move
        x_shuriken -= shuriken_vitesse
        x_missile -= missile_vitesse
 
        if x_shuriken  < (-1*shurikenW):
            y_shuriken = randint(0, 450)
            x_shuriken = surfaceW
 
        if x_missile < (-1*missileW):
            y_missile = randint(50, 400)
            x_missile = surfaceW
 
        surface.fill(blue)
 
        shuriken(x_shuriken, y_shuriken, obstacle )
 
        personnage(x_perso, y_perso,perso)
 
        lance_roquette(x_missile, y_missile, missile)
 
        pygame.display.update()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main()
pygame.quit()
quit()