8000 Merge remote-tracking branch 'origin/master' · pythonprobr/pythonbirds@79ebf92 · GitHub
[go: up one dir, main page]

Skip to content

Commit 79ebf92

Browse files
author
renzon
committed
Merge remote-tracking branch 'origin/master'
2 parents 3591765 + 7f7fb9c commit 79ebf92

File tree

3 files changed

+68
-4
lines changed

3 files changed

+68
-4
lines changed

fases/escudo_espartano.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# -*- coding: utf-8 -*-
2+
from os import path
3+
import sys
4+
import math
5+
6+
project_dir = path.dirname(__file__)
7+
project_dir = path.join('..')
8+
sys.path.append(project_dir)
9+
10+
from atores import PassaroAmarelo, PassaroVermelho, Obstaculo, Porco
11+
from fase import Fase
12+
from placa_grafica_tkinter import rodar_fase
13+
from random import randint
14+
15+
if __name__ == '__main__':
16+
fase = Fase(intervalo_de_colisao=10)
17+
18+
19+
# Adicionar Pássaros Amarelos
20+
for i in range(80):
21+
fase.adicionar_passaro(PassaroAmarelo(30, 30))
22+
23+
24+
# Obstaculos
25+
theta = 270
26+
h = 12
27+
k = 7
28+
step = 32
29+
r = 50
30+
31+
while theta < 480:
32+
x = 600 + (h + r * math.cos(theta))
33+
y = (k + r * math.sin(theta))
34+
fase.adicionar_obstaculo(Obstaculo(x, y))
35+
theta += 32
36+
37+
# Porcos
38+
for i in range(30, 300, 32):
39+
x = randint(590, 631)
40+
y = randint(0, 21)
41+
fase.adicionar_porco(Porco(x, y))
42+
43+
rodar_fase(fase)

images/menu.gif

2.85 KB
Loading

placa_grafica_tkinter.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ALTURA_DA_TELA = 600 # px
1313

1414
root = Tk()
15+
1516
IMAGES_PATH = path.dirname(__file__)
1617
IMAGES_PATH = path.join(IMAGES_PATH, 'images')
1718
PASSARO_VERMELHO = PhotoImage(file=path.join(IMAGES_PATH, "passaro_vermelho.gif"))
@@ -22,11 +23,16 @@
2223
TRANSPARENTE = PhotoImage(file=path.join(IMAGES_PATH, "transparente.gif"))
2324
BACKGROUND = PhotoImage(file=path.join(IMAGES_PATH, "background.gif"))
2425
PYTHONBIRDS_LOGO = PhotoImage(file=path.join(IMAGES_PATH, "python-birds-logo.gif"))
26+
MENU = PhotoImage(file=path.join(IMAGES_PATH, "menu.gif"))
2527
VOCE_GANHOU = PhotoImage(file=path.join(IMAGES_PATH, "python-birds-voce-ganhou-popup.gif"))
2628
VOCE_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

3238
def 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-
86107
def rodar_fase(fase):
87108
root.title("Python Birds")
88109
root.geometry("800x600")

0 commit comments

Comments
 (0)
0