From a995d7fe4413594255528e4074bc6c7c23653ef2 Mon Sep 17 00:00:00 2001 From: weber Date: Tue, 1 Aug 2023 22:00:35 -0300 Subject: [PATCH 1/8] Criada a classe Pessoa --- oo/__init__.py | 0 oo/pessoa.py | 2 ++ 2 files changed, 2 insertions(+) create mode 100644 oo/__init__.py create mode 100644 oo/pessoa.py diff --git a/oo/__init__.py b/oo/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/oo/pessoa.py b/oo/pessoa.py new file mode 100644 index 000000000..e1da50e22 --- /dev/null +++ b/oo/pessoa.py @@ -0,0 +1,2 @@ +class Pessoa: + pass \ No newline at end of file From b74d8333f24b80c63d9544c2434e7426c832615e Mon Sep 17 00:00:00 2001 From: weber Date: Mon, 7 Aug 2023 21:26:11 -0300 Subject: [PATCH 2/8] Criado metodo comprimentar --- oo/pessoa.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index e1da50e22..9874e1d40 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,2 +1,8 @@ class Pessoa: - pass \ No newline at end of file + def comprimentar(self): + return f'Olá i{id(self)}' +if __name__ == '__main__': + p = Pessoa() + print(Pessoa.comprimentar(p)) + print(id(p)) + print(p.comprimentar()) \ No newline at end of file From 3e5656f765cd13f8772ca59d83bcf7d04c97b963 Mon Sep 17 00:00:00 2001 From: coder Date: Mon, 4 Sep 2023 12:14:58 -0300 Subject: [PATCH 3/8] criado pacote matematica --- matematica/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 matematica/__init__.py diff --git a/matematica/__init__.py b/matematica/__init__.py new file mode 100644 index 000000000..e69de29bb From 744281a1f452d611fdbdb42bc665a2369001ad98 Mon Sep 17 00:00:00 2001 From: weberdp Date: Thu, 28 Dec 2023 10:00:19 -0300 Subject: [PATCH 4/8] corrigido metodo cumprimentar --- oo/pessoa.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oo/pessoa.py b/oo/pessoa.py index 9874e1d40..eb6697279 100644 --- a/oo/pessoa.py +++ b/oo/pessoa.py @@ -1,8 +1,8 @@ class Pessoa: - def comprimentar(self): + def cumprimentar(self): return f'Olá i{id(self)}' if __name__ == '__main__': p = Pessoa() - print(Pessoa.comprimentar(p)) + print(Pessoa.cumprimentar(p)) print(id(p)) - print(p.comprimentar()) \ No newline at end of file + print(p.cumprimentar()) \ No newline at end of file From 80ee88e386aa7fc48e57c71d35c2e84458eba2da Mon Sep 17 00:00:00 2001 From: weber Date: Wed, 26 Jun 2024 15:52:44 -0300 Subject: [PATCH 5/8] criada a classe pessoa --- oo/pessoa.py | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 oo/pessoa.py diff --git a/oo/pessoa.py b/oo/pessoa.py deleted file mode 100644 index eb6697279..000000000 --- a/oo/pessoa.py +++ /dev/null @@ -1,8 +0,0 @@ -class Pessoa: - def cumprimentar(self): - return f'Olá i{id(self)}' -if __name__ == '__main__': - p = Pessoa() - print(Pessoa.cumprimentar(p)) - print(id(p)) - print(p.cumprimentar()) \ No newline at end of file From ca998a1720dbbe736e99d9741f3bb3c9bc60d3d8 Mon Sep 17 00:00:00 2001 From: weber Date: Wed, 26 Jun 2024 15:53:01 -0300 Subject: [PATCH 6/8] criada a classe pessoa --- placa_grafica.py | 157 ----------------------------------------------- 1 file changed, 157 deletions(-) delete mode 100644 placa_grafica.py diff --git a/placa_grafica.py b/placa_grafica.py deleted file mode 100644 index 77ae67aef..000000000 --- a/placa_grafica.py +++ /dev/null @@ -1,157 +0,0 @@ -# -*- coding: utf-8 -*- -import os -import platform -import time -import sys -from templates import FIM - -try: - import msvcrt -except: - pass -import select - - -eh_windows = platform.system() == 'Windows' -apagar_tela = lambda: os.system('cls') if eh_windows else lambda: os.system('clear') - -# workaround retirado de http://stackoverflow.com/questions/292095/polling-the-keyboard-in-python - - -def ouvir_teclado_fn(): - i, o, e = select.select([sys.stdin], [], [], 0.0001) - for s in i: - if s == sys.stdin: - return True - return False - - -if eh_windows: - ouvir_teclado = msvcrt.kbhit -else: - ouvir_teclado = ouvir_teclado_fn - -LARGURA = 80 -ALTURA = 20 - - -def desenhar_e_esperar(delta_t, fase, passo, tempo, msg): - time.sleep(passo) - apagar_tela() - pontos_cartesianos = fase.calcular_pontos(tempo) - print('%s Tempo: %.2f' % (msg, tempo)) - print(desenhar(*pontos_cartesianos)) - tempo += delta_t - return tempo - - -def _animar(delta_t, fase, passo, tempo, msg): - while not fase.acabou(tempo): - tempo = desenhar_e_esperar(delta_t, fase, passo, tempo, msg) - return tempo - - -def _jogar(delta_t, fase, passo, tempo, msg): - while not fase.acabou(): - tempo = desenhar_e_esperar(delta_t, fase, passo, tempo, msg) - entrada = ouvir_teclado() - if entrada: - while True: - try: - if not eh_windows: - input() - angulo = float(input('Digite o Ângulo de Lançamento: ')) - fase.lancar(angulo, tempo) - break - except: - print('Erro: valor tem que ser númerico!') - return tempo - - -def rebobina(delta_t, fase, passo, tempo, msg): - while tempo > 0: - tempo = desenhar_e_esperar(-delta_t, fase, passo, tempo, msg) - return tempo - - -def animar(fase, passo=0.1, delta_t=0.1): - tempo = 0 - tempo_final = _jogar(delta_t, fase, passo, tempo, 'Play!') - if input('Deseja ver o Replay? (s para sim): ').lower() == 's': - velocidade_rebobina = 10 - rebobina(delta_t, fase, passo / velocidade_rebobina, tempo_final, - 'Rebobinando %s vezes mais rápido!' % velocidade_rebobina) - velocidade_replay = 1 - _animar(delta_t, fase, passo / velocidade_replay, tempo, 'Replay %s vezes mais rápido!' % velocidade_replay) - apagar_tela() - print(fase.status(tempo_final)) - print(FIM) - - -def normalizar_coordenadas(x, y): - return x, ALTURA - y - 1 - - -def esta_dentro_da_tela(x, y): - return 0 < x < (LARGURA - 1) and 0 < y < (ALTURA - 1) - - -def escolher_caracter_limitrofe(x, y): - if x == 0 or x == LARGURA - 1: - return '|' - if y == 0: - return '-' - return 'T' - - -def escolher_caracter(x, y, *pontos_cartesianos): - for ponto in pontos_cartesianos: - x_normalizdo, y_normalizado = normalizar_coordenadas(ponto.x, ponto.y) - if x == x_normalizdo and y == y_normalizado: - return ponto.caracter - return ' ' - - -def desenhar(*pontos_cartesianos): - frame = '' - for y in range(ALTURA): - for x in range(LARGURA): - if esta_dentro_da_tela(x, y): - frame += escolher_caracter(x, y, *pontos_cartesianos) - else: - frame += escolher_caracter_limitrofe(x, y) - frame += os.linesep - return frame - - -def main(): - global Ponto, Fase - - class Ponto(): - def __init__(self, caracter): - self.caracter = caracter - self(0) - - def __call__(self, tempo): - self.y = round(ALTURA * tempo / 5) if tempo < 5 else round(ALTURA * (10 - tempo) / 5) - self.x = round(LARGURA * tempo / 10) - return self - - class Fase(): - def __init__(self): - self.p = Ponto('>') - - def calcular_pontos(self, tempo): - return [self.p(tempo)] - - def acabou(self, tempo): - return tempo > 10 - - def status(self): - return 'Você ganhou' - - animar(Fase()) - - -if __name__ == '__main__': - main() From 10bd2490dab27e8320aaf1ce8c689f16c52be02f Mon Sep 17 00:00:00 2001 From: weber Date: Wed, 26 Jun 2024 15:53:09 -0300 Subject: [PATCH 7/8] criada a classe pessoa --- placa_grafica_tkinter.py | 153 --------------------------------------- 1 file changed, 153 deletions(-) delete mode 100644 placa_grafica_tkinter.py diff --git a/placa_grafica_tkinter.py b/placa_grafica_tkinter.py deleted file mode 100644 index 318542e65..000000000 --- a/placa_grafica_tkinter.py +++ /dev/null @@ -1,153 +0,0 @@ -# coding: utf-8 -import time -from tkinter import PhotoImage, NW, Tk, Canvas -from tkinter.constants import ALL -import math -from os import path -import atores - -from fase import Fase, EM_ANDAMENTO, VITORIA -from atores import PassaroVermelho, PassaroAmarelo, Porco, Obstaculo - -ALTURA_DA_TELA = 600 # px - -root = Tk() - -IMAGES_PATH = path.dirname(__file__) -IMAGES_PATH = path.join(IMAGES_PATH, 'images') -PASSARO_VERMELHO = PhotoImage(file=path.join(IMAGES_PATH, "passaro_vermelho.gif")) -PASSARO_AMARELHO = PhotoImage(file=path.join(IMAGES_PATH, "passaro_amarelo.gif")) -PORCO = PhotoImage(file=path.join(IMAGES_PATH, "porco.gif")) -PORCO_MORTO = PhotoImage(file=path.join(IMAGES_PATH, "porco_morto.gif")) -OBSTACULO = PhotoImage(file=path.join(IMAGES_PATH, "obstaculo.gif")) -TRANSPARENTE = PhotoImage(file=path.join(IMAGES_PATH, "transparente.gif")) -BACKGROUND = PhotoImage(file=path.join(IMAGES_PATH, "background.gif")) -PYTHONBIRDS_LOGO = PhotoImage(file=path.join(IMAGES_PATH, "python-birds-logo.gif")) -MENU = PhotoImage(file=path.join(IMAGES_PATH, "menu.gif")) -VOCE_GANHOU = PhotoImage(file=path.join(IMAGES_PATH, "python-birds-voce-ganhou-popup.gif")) -VOCE_PERDEU = PhotoImage(file=path.join(IMAGES_PATH, "python-birds-voce-perdeu-popup.gif")) - -CARACTER_PARA__IMG_DCT = {'V': PASSARO_VERMELHO, - 'A': PASSARO_AMARELHO, - '@': PORCO, - 'O': OBSTACULO, - '+': PORCO_MORTO, - ' ': TRANSPARENTE} - - -def plotar(camada_de_atores, ponto): - if ponto.caracter != ' ': - x = ponto.x - y = ALTURA_DA_TELA - ponto.y - 120 # para coincidir com o chao da tela - image = CARACTER_PARA__IMG_DCT.get(ponto.caracter, TRANSPARENTE) - camada_de_atores.create_image((x, y), image=image, anchor=NW) - - -def animar(tela, camada_de_atores, fase, passo=0.01, delta_t=0.04): - tempo = 0 - passo = int(1000 * passo) - angulo = 0 - multiplicador_rebobinar = 20 - - def _animar(): - tempo_de_inicio_de_animacao=time.time() - - nonlocal tempo - nonlocal delta_t - nonlocal angulo - tempo += delta_t - if tempo <= 0: - tempo = 0 - delta_t /= -multiplicador_rebobinar - if fase.status() != EM_ANDAMENTO: - camada_de_atores.create_image(162, 55, image=PYTHONBIRDS_LOGO, anchor=NW) - camada_de_atores.create_image(54, 540, image=MENU, anchor=NW) - if fase.status() == VITORIA: - img = VOCE_GANHOU - else: - img = VOCE_PERDEU - camada_de_atores.create_image(192, 211, image=img, anchor=NW) - else: - camada_de_atores.delete(ALL) - camada_de_atores.create_image((0, 0), image=BACKGROUND, anchor=NW) - tamanho_seta = 60 - angulo_rad = math.radians(-angulo) - - camada_de_atores.create_line(52, 493, 52 + tamanho_seta * math.cos(angulo_rad), - 493 + tamanho_seta * math.sin(angulo_rad), width=1.5) - camada_de_atores.create_text(35, 493, text="%d°" % angulo) - for ponto in fase.calcular_pontos(tempo): - plotar(camada_de_atores, ponto) - tempo_gasto_com_animacao= round((time.time() - tempo_de_inicio_de_animacao)*1000) # Trans - tempo_proxima_animacao = passo - tempo_gasto_com_animacao if passo>tempo_gasto_com_animacao else 1 - tela.after(tempo_proxima_animacao, _animar) - - def _ouvir_comandos_lancamento(evento): - nonlocal angulo - if evento.keysym == 'Up': - angulo += 1 - if angulo > 360: - angulo = 1 - elif evento.keysym == 'Down': - angulo -= 1 - if angulo < 0: - angulo = 359 - elif evento.keysym == 'Return' or evento.keysym == 'space': - fase.lancar(angulo, tempo) - - def _replay(event): - return - nonlocal tempo - nonlocal delta_t - if fase.acabou(tempo): - delta_t *= -multiplicador_rebobinar - _animar() - - - def _jogar_novamente(event): - return - nonlocal tempo - nonlocal delta_t - if fase.acabou(tempo): - tempo = delta_t - fase.resetar() - _animar() - - def _finalizar(event): - root.destroy() - - camada_de_atores.pack() - _animar() - tela.bind_all('', _ouvir_comandos_lancamento) - tela.bind_all('1', _replay) - tela.bind_all('2', _jogar_novamente) - tela.bind_all('3', _finalizar) - tela.bind_all('', _finalizar) - - tela.mainloop() - tela.after(passo, _animar) - - -def rodar_fase(fase): - root.title("Python Birds") - root.geometry("800x600") - root.resizable(0, 0) - stage = Canvas(root, width=800, height=ALTURA_DA_TELA) - - multiplicador = 10 - PassaroAmarelo.velocidade_escalar *= multiplicador - PassaroVermelho.velocidade_escalar *= multiplicador - atores.GRAVIDADE = 100 - animar(root, stage, fase) - - -if __name__ == '__main__': - fase = Fase(intervalo_de_colisao=32) - passaros = [PassaroVermelho(30, 30), PassaroAmarelo(30, 30), PassaroAmarelo(30, 30)] - porcos = [Porco(750, 1), Porco(700, 1)] - obstaculos = [Obstaculo(310, 100)] - - fase.adicionar_obstaculo(*obstaculos) - fase.adicionar_passaro(*passaros) - fase.adicionar_porco(*porcos) - rodar_fase(fase) From be5ba034e23999aab71df14529dd03163317f488 Mon Sep 17 00:00:00 2001 From: weber Date: Wed, 26 Jun 2024 16:29:49 -0300 Subject: [PATCH 8/8] criada a classe pessoa --- oo/pessoa.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 oo/pessoa.py diff --git a/oo/pessoa.py b/oo/pessoa.py new file mode 100644 index 000000000..fdea9a5e0 --- /dev/null +++ b/oo/pessoa.py @@ -0,0 +1,2 @@ +class Pessoa(): + pass