| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 97dff1b commit 383bd70
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| 2 | + | ||
| 3 | + from __future__ import unicode_literals | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| 2 | + | ||
| 3 | + from __future__ import unicode_literals | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 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 | |
@@ -11,17 +12,18 @@ | |||
| 11 | 12 | ALTURA_DA_TELA = 600 # px | |
| 12 | 13 | ||
| 13 | 14 | root = 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")) | ||
| 25 | 27 | ||
| 26 | 28 | CARACTER_PARA__IMG_DCT = {'V': PASSARO_VERMELHO, 'A': PASSARO_AMARELHO, '@': PORCO, 'O': OBSTACULO, | |
| 27 | 29 | '+': PORCO_MORTO, ' ': TRANSPARENTE} | |
@@ -48,7 +50,8 @@ def _animar(): | |||
| 48 | 50 | tamanho_seta = 60 | |
| 49 | 51 | angulo_rad = math.radians(-angulo) | |
| 50 | 52 | ||
| 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) | ||
| 52 | 55 | camada_de_atores.create_text(35, 493, text=u"%d°" % angulo) | |
| 53 | 56 | for ponto in fase.calcular_pontos(tempo): | |
| 54 | 57 | plotar(camada_de_atores, ponto) | |
@@ -79,6 +82,7 @@ def _ouvir_comandos_lancamento(evento): | |||
| 79 | 82 | tela.mainloop() | |
| 80 | 83 | tela.after(passo, _animar) | |
| 81 | 84 | ||
| 85 | + | ||
| 82 | 86 | def rodar_fase(fase): | |
| 83 | 87 | root.title("Python Birds") | |
| 84 | 88 | root.geometry("800x600") | |
@@ -92,7 +96,6 @@ def rodar_fase(fase): | |||
| 92 | 96 | animar(root, stage, fase) | |
| 93 | 97 | ||
| 94 | 98 | ||
| 95 | - | ||
| 96 | 99 | if __name__ == '__main__': | |
| 97 | 100 | fase = Fase(intervalo_de_colisao=10) | |
| 98 | 101 | passaros = [PassaroVermelho(30, 30), PassaroAmarelo(30, 30), PassaroAmarelo(30, 30)] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments