@ -29,19 +29,18 @@ class Balle():
self . y = uny
self . cote = 5
self . c = uncanvas
self . ball = self . c . create_rectangle ( self . x , self . y , self . x + self . cote , self . y + self . cote , fill = " #ff0000 " )
def deplace ( self , unx , uny ) :
self . x = unx
self . y = uny
self . c . coords ( self . ball , self . x , self . y , self . x + self . cote , self . y + self . cote )
def dessineballe ( self ) :
self . ball = self . c . create_rectangle ( self . x , self . y , self . x + self . cote , self . y + self . cote , fill = " #ff0000 " )
def Tmilieu ( self , direction ) :
if direction == True :
self . x = self . x + 2
self . c . coords ( self . ball , self . x , self . y , self . x + self . cote , self . y + self . cote )
else :
self . x = self . x - 2
self . c . coords ( self . ball , self . x , self . y , self . x + self . cote , self . y + self . cote )
def Tmilieu ( self , avance ) :
self . deplace ( self . x + avance , self . y )
def TdiagH ( self , direction ) :
if direction == True :
@ -67,19 +66,17 @@ class Tir_p(Thread):
self . p = unpistolet
self . p . CreerBalle ( )
self . p . b . dessineballe ( )
print ( " c " )
#balle créer
def run ( self ) :
if self . p . direction == True :
self . direction_tir = self . p . direction
if self . direction_tir == True :
while self . p . b . x + 2 < 1900 :
self . p . b . Tmilieu ( self . p . direction )
sleep ( 0.002 )
self . p . b . Tmilieu ( 2 )
sleep ( 0.01 )
else :
while self . p . b . x - 2 > 0 :
self . p . b . Tmilieu ( self . p . direction )
sleep ( 0.002 )
self . p . b . Tmilieu ( - 2 )
sleep ( 0.001 )
self . c . delete ( self . p . b . ball )
self . c . delete ( self . p . b )