8000 close #12 · pythonprobr/pythonbirds@e2a112a · GitHub
[go: up one dir, main page]

Skip to content

Commit e2a112a

Browse files
author
renzon
committed
close #12
1 parent f4b6eb7 commit e2a112a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

placa_grafica_tkinter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ def plotar(camada_de_atores, ponto):
4343
camada_de_atores.create_image((x, y), image=image, anchor=NW)
4444

4545

46-
def animar(tela, camada_de_atores, fase, passo=0.01, delta_t=0.01):
46+
def animar(tela, camada_de_atores, fase, passo=0.01, delta_t=0.04):
4747
tempo = 0
4848
passo = int(1000 * passo)
4949
angulo = 0
5050
multiplicador_rebobinar = 20
5151

5252
def _animar():
53+
tempo_de_inicio_de_animacao=time.time()
54+
5355
nonlocal tempo
5456
nonlocal delta_t
5557
nonlocal angulo
@@ -76,7 +78,9 @@ def _animar():
7678
camada_de_atores.create_text(35, 493, text="%d" % angulo)
7779
for ponto in fase.calcular_pontos(tempo):
7880
plotar(camada_de_atores, ponto)
79-
tela.after(passo, _animar)
81+
tempo_gasto_com_animacao= round((time.time() - tempo_de_inicio_de_animacao)*1000) # Trans
82+
tempo_proxima_animacao = passo - tempo_gasto_com_animacao if passo>tempo_gasto_com_animacao else 1
83+
tela.after(tempo_proxima_animacao, _animar)
8084

8185
def _ouvir_comandos_lancamento(evento):
8286
nonlocal angulo

0 commit comments

Comments
 (0)
0