Bonjour
En ce moment je cherche a gérer des collisions entre deux boules.
J'ai fini par trouver un moyen tout seul,n'ayant pas trouvé sur internet
Mais quelqu'un a-t-il une autre technique?Code:
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 from Tkinter import * from math import * fen=Tk() fen.title("boules") fon=Canvas(fen,height=400,width=400,bg="white") fon.pack() fen.geometry("400x400") fon.create_oval(150,150,250,250,fill="black") vr,vo=3.0,(input("angle")/90.0)*pi y,x=0,-200.0 ro=fon.create_oval(x+150,y+150,x+200,y+200,fill="red") def running(): global x,y,vr,vo fon.coords(ro,x+150,y+150,x+250,y+250) x+=vr*cos(vo) y+=vr*sin(vo) if x>200 or x<-200: vo=pi-vo if y>200 or y<-200: vo=-vo if x**2+y**2<10000: #calcul du nouvel angle vo=2*(atan2(y,x)+(pi/2.0))-vo fen.after(5,running) running() fen.mainloop()