33from tkinter import PhotoImage , NW , Tk , Canvas
44from tkinter .constants import ALL
55import math
6+ from os import path
67import atores
78
89from fase import Fase
1112ALTURA_DA_TELA = 600 # px
1213
1314root = Tk ()
14-
15- PASSARO_VERMELHO = PhotoImage (file = "images/passaro_vermelho.gif" )
16- PASSARO_AMARELHO = PhotoImage (file = "images/passaro_amarelo.gif" )
17- PORCO = PhotoImage (file = "images/porco.gif" )
18- PORCO_MORTO = PhotoImage (file = "images/porco_morto.gif" )
19- OBSTACULO = PhotoImage (file = "images/obstaculo.gif" )
20- TRANSPARENTE = PhotoImage (file = "images/transparente.gif" )
21- BACKGROUND = PhotoImage (file = "images/background.gif" )
22- PYTHONBIRDS_LOGO = PhotoImage (file = "images/python-birds-logo.gif" )
23- VOCE_GANHOU = PhotoImage (file = "images/python-birds-voce-ganhou-popup.gif" )
24- VOCE_PERDEU = PhotoImage (file = "images/python-birds-voce-perdeu-popup.gif" )
15+ IMAGES_PATH = path .dirname (__file__ )
16+ IMAGES_PATH = path .join (IMAGES_PATH , 'images' )
17+ PASSARO_VERMELHO = PhotoImage (file = path .join (IMAGES_PATH , "passaro_vermelho.gif" ))
18+ PASSARO_AMARELHO = PhotoImage (file = path .join (IMAGES_PATH , "passaro_amarelo.gif" ))
19+ PORCO = PhotoImage (file = path .join (IMAGES_PATH , "porco.gif" ))
20+ PORCO_MORTO = PhotoImage (file = path .join (IMAGES_PATH , "porco_morto.gif" ))
21+ OBSTACULO = PhotoImage (file = path .join (IMAGES_PATH , "obstaculo.gif" ))
22+ TRANSPARENTE = PhotoImage (file = path .join (IMAGES_PATH , "transparente.gif" ))
23+ BACKGROUND = PhotoImage (file = path .join (IMAGES_PATH , "background.gif" ))
24+ PYTHONBIRDS_LOGO = PhotoImage (file = path .join (IMAGES_PATH , "python-birds-logo.gif" ))
25+ VOCE_GANHOU = PhotoImage (file = path .join (IMAGES_PATH , "python-birds-voce-ganhou-popup.gif" ))
26+ VOCE_PERDEU = PhotoImage (file = path .join (IMAGES_PATH , "python-birds-voce-perdeu-popup.gif" ))
2527
2628CARACTER_PARA__IMG_DCT = {'V' : PASSARO_VERMELHO , 'A' : PASSARO_AMARELHO , '@' : PORCO , 'O' : OBSTACULO ,
2729 '+' : PORCO_MORTO , ' ' : TRANSPARENTE }
@@ -48,7 +50,8 @@ def _animar():
4850 tamanho_seta = 60
4951 angulo_rad = math .radians (- angulo )
5052
51- camada_de_atores .create_line (52 , 493 , 52 + tamanho_seta * math .cos (angulo_rad ), 493 + tamanho_seta * math .sin (angulo_rad ), width = 1.5 )
53+ camada_de_atores .create_line (52 , 493 , 52 + tamanho_seta * math .cos (angulo_rad ),
54+ 493 + tamanho_seta * math .sin (angulo_rad ), width = 1.5 )
5255 camada_de_atores .create_text (35 , 493 , text = u"%d°" % angulo )
5356 for ponto in fase .calcular_pontos (tempo ):
5457 plotar (camada_de_atores , ponto )
@@ -79,6 +82,7 @@ def _ouvir_comandos_lancamento(evento):
7982 tela .mainloop ()
8083 tela .after (passo , _animar )
8184
85+
8286def rodar_fase (fase ):
8387 root .title ("Python Birds" )
8488 root .geometry ("800x600" )
@@ -92,7 +96,6 @@ def rodar_fase(fase):
9296 animar (root , stage , fase )
9397
9498
95-
9699if __name__ == '__main__' :
97100 fase = Fase (intervalo_de_colisao = 10 )
98101 passaros = [PassaroVermelho (30 , 30 ), PassaroAmarelo (30 , 30 ), PassaroAmarelo (30 , 30 )]
0 commit comments