Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d83d82

Browse files
resolvendo conflitos
2 parents 24a446c + 383bd70 commit 8d83d82

File tree

7 files changed

+58
-50
lines changed

7 files changed

+58
-50
lines changed

fase.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def acabou(self, tempo):
4040
return not self._existe_porco_ativo(tempo) or not self._existe_passaro_ativo(tempo)
4141

4242
def status(self, tempo):
43+
if not self._existe_porco_ativo(tempo):
44+
return 'Jogo em encerrado. Você ganhou!'
4345
if self._existe_passaro_ativo(tempo):
4446
return 'Jogo em andamento.'
45-
if self._existe_porco_ativo(tempo):
46-
return 'Jogo em encerrado. Você perdeu!'
47-
return 'Jogo em encerrado. Você ganhou!'
47+
return 'Jogo em encerrado. Você perdeu!'
4848

4949
def lancar(self, angulo, tempo):
5050
for passaro in self._passaros:

images/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals

images/fases/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals

images/fases/rodar_fase_exemplo.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals
4+
from atores import PassaroAmarelo, PassaroVermelho, Obstaculo, Porco
5+
from fase import Fase
6+
from placa_grafica_tkinter import rodar_fase
7+
8+
if __name__=='__main__':
9+
fase = Fase(intervalo_de_colisao=10)
10+
11+
12+
# Adicionar Pássaros Vermelhos
13+
for i in range(5):
14+
fase.adicionar_passaro(PassaroVermelho(30, 30))
15+
# Adicionar Pássaros Amarelos
16+
for i in range(30):
17+
fase.adicionar_passaro(PassaroAmarelo(30, 30))
18+
19+
20+
# Obstaculos
21+
for i in range(30, 480, 32):
22+
fase.adicionar_obstaculo(Obstaculo(300, i))
23+
24+
# Porcos
25+
for i in range(30, 300, 32):
26+
fase.adicionar_porco(Porco(600, i))
27+
28+
rodar_fase(fase)

placa_grafica_tkinter.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from tkinter import PhotoImage, NW, Tk, Canvas
44
from tkinter.constants import ALL
55
import math
6+
from os import path
67
import atores
78

89
from fase import Fase
@@ -12,23 +13,21 @@
1213

1314
root = Tk()
1415

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"))
2728

2829
CARACTER_PARA__IMG_DCT = {'V': PASSARO_VERMELHO,
29-
'v': PASSARO_VERMELHO_MORTO,
3030
'A': PASSARO_AMARELHO,
31-
'a': PASSARO_AMARELHO_MORTO,
3231
'@': PORCO,
3332
'O': OBSTACULO,
3433
'+': PORCO_MORTO,
@@ -56,7 +55,8 @@ def _animar():
5655
tamanho_seta = 60
5756
angulo_rad = math.radians(-angulo)
5857

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)
6060
camada_de_atores.create_text(35, 493, text=u"%d°" % angulo)
6161
for ponto in fase.calcular_pontos(tempo):
6262
plotar(camada_de_atores, ponto)
@@ -109,7 +109,6 @@ def rodar_fase(fase):
109109
animar(root, stage, fase)
110110

111111

112-
113112
if __name__ == '__main__':
114113
fase = Fase(intervalo_de_colisao=10)
115114
passaros = [PassaroVermelho(30, 30), PassaroAmarelo(30, 30), PassaroAmarelo(30, 30)]

rodar_fase_exemplo.py

-30
This file was deleted.

testes/fase_testes.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,19 @@ def teste_status(self):
100100
self.assertEqual('Jogo em encerrado. Você ganhou!', fase.status(3),
101101
'Obstáculo não interfere para definir vitória')
102102

103-
fase.adicionar_porco(Porco())
103+
porco = Porco()
104+
fase.adicionar_porco(porco)
104105
self.assertEqual('Jogo em encerrado. Você perdeu!', fase.status(3),
105106
'Com Porco ativo e sem pássaro para lançar, o jogo deveria acabar em derrota')
106107

107108
fase.adicionar_passaro(PassaroAmarelo())
108109
self.assertEqual('Jogo em andamento.', fase.status(3),
109110
'Com Porco ativo e com pássaro para lançar, o jogo não deveria acabar')
110111

112+
porco.colidir(porco, 3)
113+
self.assertEqual('Jogo em encerrado. Você ganhou!', fase.status(3),
114+
'Sem porco ativo, o jogo deveria acabar com vitória')
115+
111116
def teste_lancar_passaro_sem_erro_quando_nao_existe_passaro(self):
112117
passaro_vermelho, passaro_amarelo = PassaroVermelho(1, 1), PassaroAmarelo(1, 1)
113118
fase = Fase()

0 commit comments

Comments
 (0)