|
3 | 3 | from tkinter import PhotoImage, NW, Tk, Canvas
|
4 | 4 | from tkinter.constants import ALL
|
5 | 5 | import math
|
| 6 | +from os import path |
6 | 7 | import atores
|
7 | 8 |
|
8 | 9 | from fase import Fase
|
|
12 | 13 |
|
13 | 14 | root = Tk()
|
14 | 15 |
|
15 |
| -PASSARO_VERMELHO = PhotoImage(file="images/passaro_vermelho.gif") |
16 |
| -PASSARO_VERMELHO_MORTO = PhotoImage(file="images/passaro_vermelho_morto.gif") |
17 |
| -PASSARO_AMARELHO = PhotoImage(file="images/passaro_amarelo.gif") |
18 |
| -PASSARO_AMARELHO_MORTO = PhotoImage(file="images/passaro_amarelo_morto.gif") |
19 |
| -PORCO = PhotoImage(file="images/porco.gif") |
20 |
| -PORCO_MORTO = PhotoImage(file="images/porco_morto.gif") |
21 |
| -OBSTACULO = PhotoImage(file="images/obstaculo.gif") |
22 |
| -TRANSPARENTE = PhotoImage(file="images/transparente.gif") |
23 |
| -BACKGROUND = PhotoImage(file="images/background.gif") |
24 |
| -PYTHONBIRDS_LOGO = PhotoImage(file="images/python-birds-logo.gif") |
25 |
| -VOCE_GANHOU = PhotoImage(file="images/python-birds-voce-ganhou-popup.gif") |
26 |
| -VOCE_PERDEU = PhotoImage(file="images/python-birds-voce-perdeu-popup.gif") |
| 16 | +IMAGES_PATH = path.dirname(__file__) |
| 17 | +IMAGES_PATH = path.join(IMAGES_PATH, 'images') |
| 18 | +PASSARO_VERMELHO = PhotoImage(file=path.join(IMAGES_PATH, "passaro_vermelho.gif")) |
| 19 | +PASSARO_AMARELHO = PhotoImage(file=path.join(IMAGES_PATH, "passaro_amarelo.gif")) |
| 20 | +PORCO = PhotoImage(file=path.join(IMAGES_PATH, "porco.gif")) |
| 21 | +PORCO_MORTO = PhotoImage(file=path.join(IMAGES_PATH, "porco_morto.gif")) |
| 22 | +OBSTACULO = PhotoImage(file=path.join(IMAGES_PATH, "obstaculo.gif")) |
| 23 | +TRANSPARENTE = PhotoImage(file=path.join(IMAGES_PATH, "transparente.gif")) |
| 24 | +BACKGROUND = PhotoImage(file=path.join(IMAGES_PATH, "background.gif")) |
| 25 | +PYTHONBIRDS_LOGO = PhotoImage(file=path.join(IMAGES_PATH, "python-birds-logo.gif")) |
| 26 | +VOCE_GANHOU = PhotoImage(file=path.join(IMAGES_PATH, "python-birds-voce-ganhou-popup.gif")) |
| 27 | +VOCE_PERDEU = PhotoImage(file=path.join(IMAGES_PATH, "python-birds-voce-perdeu-popup.gif")) |
27 | 28 |
|
28 | 29 | CARACTER_PARA__IMG_DCT = {'V': PASSARO_VERMELHO,
|
29 |
| - 'v': PASSARO_VERMELHO_MORTO, |
30 | 30 | 'A': PASSARO_AMARELHO,
|
31 |
| - 'a': PASSARO_AMARELHO_MORTO, |
32 | 31 | '@': PORCO,
|
33 | 32 | 'O': OBSTACULO,
|
34 | 33 | '+': PORCO_MORTO,
|
@@ -56,7 +55,8 @@ def _animar():
|
56 | 55 | tamanho_seta = 60
|
57 | 56 | angulo_rad = math.radians(-angulo)
|
58 | 57 |
|
59 |
| - camada_de_atores.create_line(52, 493, 52 + tamanho_seta*math.cos(angulo_rad), 493 + tamanho_seta*math.sin(angulo_rad), width=1.5) |
| 58 | + camada_de_atores.create_line(52, 493, 52 + tamanho_seta * math.cos(angulo_rad), |
| 59 | + 493 + tamanho_seta * math.sin(angulo_rad), width=1.5) |
60 | 60 | camada_de_atores.create_text(35, 493, text=u"%d°" % angulo)
|
61 | 61 | for ponto in fase.calcular_pontos(tempo):
|
62 | 62 | plotar(camada_de_atores, ponto)
|
@@ -109,7 +109,6 @@ def rodar_fase(fase):
|
109 | 109 | animar(root, stage, fase)
|
110 | 110 |
|
111 | 111 |
|
112 |
| - |
113 | 112 | if __name__ == '__main__':
|
114 | 113 | fase = Fase(intervalo_de_colisao=10)
|
115 | 114 | passaros = [PassaroVermelho(30, 30), PassaroAmarelo(30, 30), PassaroAmarelo(30, 30)]
|
|
0 commit comments