From e9b23f5954502a7827d92351ed0990ce4095a56a Mon Sep 17 00:00:00 2001 From: "philippot.m" <> Date: Sat, 29 Mar 2025 13:10:07 +0100 Subject: [PATCH] Classe pistolet --- pistolet.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pistolet.py diff --git a/pistolet.py b/pistolet.py new file mode 100644 index 0000000..75a275c --- /dev/null +++ b/pistolet.py @@ -0,0 +1,22 @@ +from threading import Thread +from time import sleep +from Jeuxdetir(nom provisoire) import * +class Pistolet(Thread): + def __init__ (self,unx,uny,uncanvas): + Thread.__init__(self) + self.x=unx + self.y=uny + self.c=uncanvas + self.cote=5 + self.r=self.c.create_rectangle(self.x,self.y,self.x+self.cote,self.y+self.cote,fill="#ff0000") + def run(self): + while self.x>0 and self.x<1900 : + if direction==True: + self.x=self.x+1 + sleep(0.001) + self.c.coords(self.r,self.x,self.y,self.x+self.cote,self.y+self.cote) + else: + self.x=self.x-1 + sleep(0.001) + self.c.coords(self.r,self.x,self.y,self.x+self.cote,self.y+self.cote) + self.c.delete(self.r) \ No newline at end of file