1212ALTURA_DA_TELA = 600 # px
1313
1414root = Tk ()
15+
1516IMAGES_PATH = path .dirname (__file__ )
1617IMAGES_PATH = path .join (IMAGES_PATH , 'images' )
1718PASSARO_VERMELHO = PhotoImage (file = path .join (IMAGES_PATH , "passaro_vermelho.gif" ))
2223TRANSPARENTE = PhotoImage (file = path .join (IMAGES_PATH , "transparente.gif" ))
2324BACKGROUND = PhotoImage (file = path .join (IMAGES_PATH , "background.gif" ))
2425PYTHONBIRDS_LOGO = PhotoImage (file = path .join (IMAGES_PATH , "python-birds-logo.gif" ))
26+ MENU = PhotoImage (file = path .join (IMAGES_PATH , "menu.gif" ))
2527VOCE_GANHOU = PhotoImage (file = path .join (IMAGES_PATH , "python-birds-voce-ganhou-popup.gif" ))
2628VOCE_PERDEU = PhotoImage (file = path .join (IMAGES_PATH , "python-birds-voce-perdeu-popup.gif" ))
2729
28- CARACTER_PARA__IMG_DCT = {'V' : PASSARO_VERMELHO , 'A' : PASSARO_AMARELHO , '@' : PORCO , 'O' : OBSTACULO ,
29- '+' : PORCO_MORTO , ' ' : TRANSPARENTE }
30+ CARACTER_PARA__IMG_DCT = {'V' : PASSARO_VERMELHO ,
31+ 'A' : PASSARO_AMARELHO ,
32+ '@' : PORCO ,
33+ 'O' : OBSTACULO ,
34+ '+' : PORCO_MORTO ,
35+ ' ' : TRANSPARENTE }
3036
3137
3238def plotar (camada_de_atores , ponto ):
@@ -58,6 +64,7 @@ def _animar():
5864
5965 if fase .acabou (tempo ):
6066 camada_de_atores .create_image (162 , 55 , image = PYTHONBIRDS_LOGO , anchor = NW )
67+ camada_de_atores .create_image (54 , 540 , image = MENU , anchor = NW )
6168 if 'ganhou' in fase .status (tempo ):
6269 img = VOCE_GANHOU
6370 else :
@@ -72,17 +79,31 @@ def _ouvir_comandos_lancamento(evento):
7279 angulo += 1
7380 elif evento .keysym == 'Down' :
7481 angulo -= 1
75- elif evento .keysym == 'Return' :
82+ elif evento .keysym == 'Return' or evento . keysym == 'space' :
7683 fase .lancar (angulo , tempo )
7784
85+ def _replay (event ):
86+ #verificar se a fase ja acabou
87+ pass
88+
89+ def _jogar_novamente (event ):
90+ #verificar se a fase ja acabou
91+ pass
92+
93+ def _finalizar (event ):
94+ root .destroy ()
95+
7896 camada_de_atores .pack ()
7997 _animar ()
8098 tela .bind_all ('<KeyPress>' , _ouvir_comandos_lancamento )
99+ tela .bind_all ('1' , _replay )
100+ tela .bind_all ('2' , _jogar_novamente )
101+ tela .bind_all ('3' , _finalizar )
102+ tela .bind_all ('<Escape>' , _finalizar )
81103
82104 tela .mainloop ()
83105 tela .after (passo , _animar )
84106
85-
86107def rodar_fase (fase ):
87108 root .title ("Python Birds" )
88109 root .geometry ("800x600" )
0 commit comments