0
I was making a copy game of Space Invaders but when I went to do the "shot" of the ship, I came across a following problem :
As seen in Gif, when I press the key, everything on the canvas "freezes" until the shot reaches the end, how do I solve this ? thanks in advance.
Excerpt from the code :
def Update (self):
while True :
self.Move_nave()
self.root.update()
self.root.after(30)
def Shot (self, event):
self.a_0 , self.a_2 = int(self.c.coords (self.bola)[0]), int(self.c.coords (self.bola)[2])
self.a_1, self.a_3 = int (self.c.coords(self.bola)[1]), int (self.c.coords(self.bola)[3])
self.tiro = self.c.create_rectangle(self.a_0 + 10, self.a_1, self.a_2 - 10, self.a_3, fill = 'blue')
for c in range (10):
self.c.move(self.tiro, 0, -10)
self.root.after(40)
self.root.update_idletasks()

The problem has to do with
forwithin the methodShot, that can’t be done that way to upgrade the shot. Instead it has to have a list of existing shots and go updating one by one on each frame. The ideal however is to provide a Minimum, Complete and Verifiable Example problem, so it is easy to show the solution.– Isac
But still, how will I wear two "afters" at the same time ?
– MATA NEGRO
Would have only one
afterfor each update of the various components– Isac
But without the after of shot he will not animate the shot and simply appear when I press the key.
– MATA NEGRO