Esempio n. 1
0
class Jogo:
    def __init__(self):
        # Pygame
        self.__pygame = pygame
        self.__pygame.init()
        self.__pygame.font.init()
        self.__pygame.mixer.init()
        self.__FPS = 30
        self.__FramePerSec = pygame.time.Clock()
        self.__pygame.display.set_caption("coRUNavirus")
        self.__tela = Tela()
        self.__jogador = Jogador([pygame.image.load("Materials/p1.png").convert_alpha(self.__tela.display),
                                 pygame.image.load("Materials/p2.png").convert_alpha(self.__tela.display),
                                 pygame.image.load("Materials/p1.png").convert_alpha(self.__tela.display),
                                 pygame.image.load("Materials/p3.png").convert_alpha(self.__tela.display)])
        self.__obstaculo_controller = ObstaculoController(self.__jogador)
        self.__efeito_controller = EfeitoController(self.__jogador)
        self.__estados = {"inicial": EstadoInicial(self.__jogador),
                          "jogando": EstadoJogando(self.__jogador, self.__obstaculo_controller, self.__efeito_controller),
                          "pausa": EstadoPausa(self.__jogador, self.__obstaculo_controller, self.__efeito_controller),
                          "derrota": EstadoDerrota(self.__jogador, self.__obstaculo_controller, self.__efeito_controller),
                          "recorde": EstadoRecorde(),
                          "regras": EstadoRegras(),
                          "som": EstadoSom(),
                          "developers": EstadoDevelopers()}

    def start(self):
        estado = "inicial"
        while True:
            proximo_estado = self.__estados[estado].start()
            estado = proximo_estado
            self.__tela.update()
            self.__FramePerSec.tick(self.__FPS)
Esempio n. 2
0
 def __init__(self, window):
     self.window = window
     self.tela = Tela(window)
     self.collision = Collision()
     self.setParadoD()
     self.personagem = self.parado_d
     globais.POS_Y = (globais.HEIGHT - globais.HEIGHT_S -
                      self.parado_d.height)
     self.setPosicaoInicial()
     self.teclado = Keyboard()
     self.pontuacao = Pontuacao(window)
Esempio n. 3
0
class Gerenciadora:
  def __init__(self):
    self.tela = Tela()
    self.placar = Placar()
    self.inicia_partida()

  def inicia_partida(self):
    time.sleep(0.5)
    self.paletas = [
      Paleta([30, 125], [pygame.K_w, pygame.K_s]),
      Paleta([560, 125], [pygame.K_UP, pygame.K_DOWN])
    ]
    self.bola = Bola()

  def roda_loop(self):
    while True:
      cliques = self.monitora_cliques()

      if pygame.QUIT in cliques:
        break

      if self.placar.total_partidas() < 5:
        self.movimenta_objetos()

        if self.placar.atualiza(self.paletas, self.bola):
          self.inicia_partida()
        
        self.tela.renderiza(self.paletas, self.bola, self.placar)
      else:
        if pygame.MOUSEBUTTONUP in cliques:
          # Verificar coordenadas do mouse:
          # pygame.mouse.get_pos()
          self.placar = Placar()

      pygame.time.Clock().tick(60)

  def monitora_cliques(self):
    cliques = []

    for evento in pygame.event.get():
      if evento.type == pygame.QUIT:
        cliques.append(pygame.QUIT)
      
      if evento.type == pygame.MOUSEBUTTONUP:
        cliques.append(pygame.MOUSEBUTTONUP)

    return cliques

  def movimenta_objetos(self):
    teclas = pygame.key.get_pressed()
    for paleta in self.paletas:
      paleta.movimenta(teclas)
    
    self.bola.movimenta()
Esempio n. 4
0
 def __init__(self, window):
     self.window = window
     self.tela = Tela(window)
     self.collision = Collision()
     self.setHumanoE()
     self.setHumanoD()
     self.setAtaqueHumanoD()
     self.setAtaqueHumanoE()
     self.humano = self.humano_e
     self.humanoVetor = []
     self.setPosicaoInicial()
     self.posicoes = Posicoes(window)
     self.random = random.SystemRandom()
    def game_loop(self):

        pygame.init()
        tela_loop_do_jogo = Tela(620, 360, "CarniceHero", "planoFundo.jpg")

        relogio_jogo = Relogio(60)

        fechar_jogo = False
        pause = False
        in_loop = True
        while in_loop:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    fechar_jogo = True
                    in_loop = False
                elif event.type == pygame.KEYDOWN:
                    if event.key == 13:
                        pause = True
                        print("pause")
                #    if event.key == pygame.K_s:
                #    if event.key == pygame.K_d:
                #    if event.key == pygame.K_k:
                #    if event.key == pygame.K_l:

            tela_loop_do_jogo.tela.blit(tela_loop_do_jogo.imagemFundo, (0, 0))
            relogio_jogo.relogio.tick(relogio_jogo.fps)
            pygame.display.update()

        if fechar_jogo:
            return "fechar_jogo"
Esempio n. 6
0
 def __init__(self, sprite: pygame.sprite.Sprite, posicao: tuple,
              fundo: Fundo, cor_normal: tuple, cor_mouse: tuple,
              eventos: object):
     super().__init__("", fundo, cor_normal, cor_mouse, eventos)
     self.__sprite = sprite
     self.__tela = Tela()
     self.__posicao = posicao
Esempio n. 7
0
    def __init__(self, param, cor):
        
        #Parametros = (left, top, width, height)
        self.__param = param
        self.__cor = cor
        self.__tela = Tela()

        self.__rect = pygame.Rect(*self.__param)
Esempio n. 8
0
    def __init__(self, texto, font, tamanho, cor, posicao):

        self.__texto = texto
        self.__font = font
        self.__tamanho = tamanho
        self.__cor = cor
        self.__tela = Tela()
        self.__posicao = posicao

        self.__fonteCompleta = pygame.font.Font(self.__font, self.__tamanho)
Esempio n. 9
0
 def __init__(self, posicao, jogador):
     self.__tela = Tela()
     super().__init__(posicao, [
         pygame.image.load("Materials/vacina.png").convert_alpha(
             self.__tela.display)
     ])
     self.__jogador = jogador
     self.img_atual = self.anim[0]
     self.rect = self.img_atual.get_rect()
     self.pos_inicial()
     self.__ativo = False
Esempio n. 10
0
 def __init__(self, posicao):
     self.__tela = Tela()
     super().__init__(posicao, [
         pygame.image.load("Materials/alcool gel.png").convert_alpha(
             self.__tela.display)
     ])
     self.__pontuacao_controller = PontuacaoController()
     self.img_atual = self.anim[0]
     self.rect = self.img_atual.get_rect()
     self.pos_inicial()
     self.__ativo = False
Esempio n. 11
0
 def __init__(self, jogador):
     self.__tela = Tela()
     self.__jogador = jogador
     self.__timer_max = 30
     self.__timer = 0
     self.__velocidade_controller = VelocidadeController()
     self.__som_controller = SomController()
     self.__limite_vel = 10
     self.__pista1 = pygame.sprite.Group()
     self.__pista2 = pygame.sprite.Group()
     self.__pista3 = pygame.sprite.Group()
     self.__pistas = [self.__pista1, self.__pista2, self.__pista3]
Esempio n. 12
0
 def __init__(self, posicao: list, anim: list):
     super().__init__()
     self.__posicao = posicao
     self.__tela = Tela()
     self.__anim = anim
     self.__velocidade_controller = VelocidadeController()
     #Vão ser implementados nas subclasses
     self.__img_atual = None
     self.__spriteNum = 0
     self.__spriteNumMax = 0
     self.__spriteTimer = 0
     self.__spriteTimerMax = 0
 def __init__(self):
     self.__pontuacao = PontuacaoController()
     self.__tela = Tela()
     
     # Fase 1
     self.__bg_1 = pygame.image.load("Materials/AnimatedStreet.png").convert(self.__tela.display)
     self.__linha_img = pygame.image.load("Materials/AnimatedStreet_Element.png").convert(self.__tela.display)
     self.__linha1 = BGElement([115, -53], [self.__linha_img])
     self.__linha2 = BGElement([230, -53], [self.__linha_img])
     self.__linha3 = BGElement([115, 292], [self.__linha_img])
     self.__linha4 = BGElement([230, 292], [self.__linha_img])
     self.__fase1 = Fase(self.__bg_1, [self.__linha1, self.__linha2, self.__linha3, self.__linha4])
     
     self.__fases = [self.__fase1]
     self.__fase = 0
     self.__fase_atual = self.__fases[self.__fase]
    def __init__(self):
        self.__pontos = 0
        self.__tela = Tela()
        self.__WHITE = (255, 255, 255)
        self.__GREEN = (0, 100, 0)
        self.__texto = Texto("", "Materials/Early GameBoy.ttf", 25,
                             self.__WHITE, [370, 10])

        self.__timer = 0
        self.__timerMax = 30
        self.__timerAtual = self.__timerMax
        self.__velocidade_controller = VelocidadeController()
        self.__len_pontuacao = 1
        self.__fundo = Fundo([360, 10, 35, 30], self.__GREEN)

        self.__multiplicador = 1
        self.__multiplicador_ativo = False
        self.__timer_multiplicador = 0
        self.__timer_multiplicador_max = 300
Esempio n. 15
0
 def __init__(self,
              jogador=None,
              obstaculo_controller=None,
              efeito_controller=None):
     self.__jogador = jogador
     self.__tela = Tela()
     self.__pontuacao = PontuacaoController()
     self.__som_controller = SomController()
     self.__velocidade_controller = VelocidadeController()
     self.__obstaculo_controller = obstaculo_controller
     self.__efeito_controller = efeito_controller
     self.__fases_controller = FasesController()
     self.__recordes_controller = RecordesController()
     self.__GREEN = (0, 100, 0)
     self.__DARK_GREEN = (0, 80, 0)
     self.__WHITE = (255, 255, 255)
     self.__BLACK = (0, 0, 0)
     self.__GREY = (100, 100, 100)
     self.__DARK_GREY = (70, 70, 70)
     self.__YELLOW = (220, 220, 0)
     self.__SILVER = (160, 160, 160)
     self.__BRONZE = (150, 100, 0)
     self.__musica = False
    def game_creditos(self):

        pygame.init()
        tela_creditos = Tela(620, 360, "CarniceHero", "creditos.jpg")
        audio_menu_navigate = Audio("menu_navigate_0.wav", 1)

        relogio_jogo = Relogio(60)

        fechar_jogo = False
        creditos = True
        voltar = False
        while creditos:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    fechar_jogo = True
                    creditos = False

                elif event.type == pygame.KEYDOWN:
                    audio_menu_navigate.audio.play()
                    if event.key == pygame.K_BACKSPACE:
                        voltar = True
                        creditos = False

            tela_creditos.tela.blit(tela_creditos.imagemFundo, (0, 0))

            relogio_jogo.relogio.tick(relogio_jogo.fps)
            pygame.display.update()

        if fechar_jogo:
            return "fechar_jogo"
        elif voltar:
            return "voltar"


# tela = Creditos()
# print(tela.game_creditos())
Esempio n. 17
0
 def __init__(self, window):
     self.window = window
     self.teclado = Keyboard()
     self.tela = Tela(window)
Esempio n. 18
0
from sikuli.Sikuli import *
from java.awt import Robot

from tela import Tela
from personagem import Personagem

class Menu:
    def __init__(self,prof = False):
        self.prof = prof

    def escolher(self):
        self.prof = select("Escolha uma profissao", options = ("Alquimista","Fazendeiro","Lenhador","Mineiro","Pescador"))
        confirma = popAsk("Voce selecionou:"+self.prof+"?")
        if confirma == True:
            if self.prof == "Alquimista":
                popup("Alquimista")
            elif self.prof == "Fazendeiro":
                popup("Fazendeiro")
            elif self.prof == "Lenhador":
                popup("Lenhador")
            elif self.prof == "Mineiro":
                popup("Mineiro")
            elif self.prof == "Pescador":
                popup("Pescador")
        else:
            Menu().escolher()

tela = new Tela()
personagem = Personagem(debug = True, tela = tela)
personagem.viagem.go_to(position = [-22,39])
Esempio n. 19
0
class Posicoes(object):
    def __init__(self, window):
        self.window = window
        self.tela = Tela(window)
        self.collision = Collision()
        self.setParadoD()
        self.personagem = self.parado_d
        globais.POS_Y = (globais.HEIGHT - globais.HEIGHT_S -
                         self.parado_d.height)
        self.setPosicaoInicial()
        self.teclado = Keyboard()
        self.pontuacao = Pontuacao(window)

    def setPosicaoInicial(self):
        self.personagem.set_position(globais.POS_X, globais.POS_Y)
        self.personagem.draw()

    def setPosicao(self):
        self.personagem.set_position(globais.POS_X, globais.POS_Y)
        self.personagem.draw()

    def setParadoD(self):
        self.parado_d = Sprite("img/parado_d2.png")
        self.personagem = self.parado_d

    def setParadoE(self):
        self.parado_e = Sprite("img/parado_e2.png")
        self.personagem = self.parado_e

    def setAndandoD(self):
        self.andando_d = Animation("img/personagem_d2.png", 5, loop=True)
        self.andando_d.set_sequence_time(0, 5, 300, loop=True)
        self.personagem = self.andando_d

    def setAndandoE(self):
        self.andando_e = Animation("img/personagem_e2.png", 5, loop=True)
        self.andando_e.set_sequence_time(0, 5, 300, loop=True)
        self.personagem = self.andando_e

    def setPuloD(self):
        self.pulo_d = Animation("img/pulo_d2.png", 4, loop=True)
        self.pulo_d.set_sequence_time(0, 4, 500, loop=True)
        self.personagem = self.pulo_d

    def setPuloE(self):
        self.pulo_e = Animation("img/pulo_e2.png", 4, loop=True)
        self.pulo_e.set_sequence_time(0, 4, 500, loop=True)
        self.personagem = self.pulo_e

    def setAtaqueD(self):
        self.ataque_d = Animation("img/ataque_d2.png", 7, loop=True)
        self.ataque_d.set_sequence_time(0, 7, 100, loop=True)
        self.personagem = self.ataque_d

    def setAtaqueE(self):
        self.ataque_e = Animation("img/ataque_e2.png", 7, loop=True)
        self.ataque_e.set_sequence_time(0, 7, 100, loop=True)
        self.personagem = self.ataque_e

    def setAbaixadoD(self):
        self.abaixado_d = Sprite("img/abaixado_d.png")
        self.personagem = self.abaixado_d

    def setAbaixadoE(self):
        self.abaixado_e = Sprite("img/abaixado_e.png")
        self.personagem = self.abaixado_e

    def setKunaiD(self):
        self.personagem_kunai_d = Animation("img/kunai_d2.png", 3, loop=True)
        self.personagem_kunai_d.set_sequence_time(0, 3, 300, loop=True)
        self.personagem = self.personagem_kunai_d

    def setKunaiE(self):
        self.personagem_kunai_e = Animation("img/kunai_e2.png", 3, loop=True)
        self.personagem_kunai_e.set_sequence_time(0, 3, 300, loop=True)
        self.personagem = self.personagem_kunai_e

    def setUpdate(self):
        if (globais.STATUS_PERSONAGEM == 0):
            self.setParadoD()
        elif (globais.STATUS_PERSONAGEM == 1):
            self.setParadoE()
        elif (globais.STATUS_PERSONAGEM == 2):
            self.setAndandoD()
        elif (globais.STATUS_PERSONAGEM == 3):
            self.setAndandoE()
        elif (globais.STATUS_PERSONAGEM == 4):
            self.setPuloD()
        elif (globais.STATUS_PERSONAGEM == 5):
            self.setPuloE()
        elif (globais.STATUS_PERSONAGEM == 6):
            self.setAtaqueD()
        elif (globais.STATUS_PERSONAGEM == 7):
            self.setAtaqueE()
        elif (globais.STATUS_PERSONAGEM == 8):
            self.setAbaixadoD()
        elif (globais.STATUS_PERSONAGEM == 9):
            self.setAbaixadoE()
        elif (globais.STATUS_PERSONAGEM == 10):
            self.setKunaiD()
        elif (globais.STATUS_PERSONAGEM == 11):
            self.setKunaiE()
        globais.WIDTH_P = self.personagem.width
        globais.HEIGHT_P = self.personagem.height

    def getUpdate(self):
        if (globais.POS_X < 0):
            globais.POS_X = 0
        altura = globais.HEIGHT - (3 * self.parado_d.height)
        if (globais.STATUS_PERSONAGEM == 0):
            self.setParadoD()
            self.setPosicao()
            globais.ESTADO_ANTERIOR = 0
        elif (globais.STATUS_PERSONAGEM == 1):
            self.setParadoE()
            self.setPosicao()
            globais.ESTADO_ANTERIOR = 1
        elif (globais.STATUS_PERSONAGEM == 2):
            globais.POS_X += globais.VEL_PERSONAGEM * self.window.delta_time()
            self.setPosicao()
            if (self.teclado.key_pressed("UP")):
                globais.STATUS_PERSONAGEM = 4
            if (self.teclado.key_pressed("SPACE")):
                globais.STATUS_PERSONAGEM = 6
            self.personagem.update()
            globais.ESTADO_ANTERIOR = 0
        elif (globais.STATUS_PERSONAGEM == 3):
            globais.POS_X -= globais.VEL_PERSONAGEM * self.window.delta_time()
            self.setPosicao()
            if (self.teclado.key_pressed("UP")):
                globais.STATUS_PERSONAGEM = 5
            if (self.teclado.key_pressed("SPACE")):
                globais.STATUS_PERSONAGEM = 7
            self.personagem.update()
            globais.ESTADO_ANTERIOR = 1
        elif (globais.STATUS_PERSONAGEM == 4):
            self.setPosicao()
            if (globais.POS_Y > altura
                    and self.personagem.get_curr_frame() == 0):
                self.personagem.set_curr_frame(0)
                globais.POS_Y -= globais.PULO_PERSONAGEM * self.window.delta_time(
                )
                if (self.teclado.key_pressed("RIGHT")):
                    globais.POS_X += globais.PULO_PERSONAGEM * self.window.delta_time(
                    )
            elif (globais.POS_Y == altura):
                self.personagem.set_curr_frame(1)
                globais.POS_X += 2
            elif (globais.POS_Y <
                  globais.HEIGHT - globais.HEIGHT_S - self.personagem.height):
                self.personagem.set_curr_frame(2)
                globais.POS_Y += globais.PULO_PERSONAGEM * self.window.delta_time(
                )
                if (self.teclado.key_pressed("RIGHT")):
                    globais.POS_X += (globais.PULO_PERSONAGEM *
                                      self.window.delta_time()) / 2
                if (globais.POS_Y - 109 >= globais.HEIGHT - 350):
                    globais.STATUS_PERSONAGEM = 1
            globais.ESTADO_ANTERIOR = 0
        elif (globais.STATUS_PERSONAGEM == 5):
            self.setPosicao()
            if (globais.POS_Y > altura
                    and self.personagem.get_curr_frame() == 0):
                self.personagem.set_curr_frame(0)
                globais.POS_Y -= globais.PULO_PERSONAGEM * self.window.delta_time(
                )
                if (self.teclado.key_pressed("LEFT")):
                    globais.POS_X -= globais.PULO_PERSONAGEM * self.window.delta_time(
                    )
            elif (globais.POS_Y == altura):
                self.personagem.set_curr_frame(1)
                globais.POS_X += 2
            elif (globais.POS_Y <
                  globais.HEIGHT - globais.HEIGHT_S - self.personagem.height):
                self.personagem.set_curr_frame(2)
                globais.POS_Y += globais.PULO_PERSONAGEM * self.window.delta_time(
                )
                if (self.teclado.key_pressed("LEFT")):
                    globais.POS_X -= (globais.PULO_PERSONAGEM *
                                      self.window.delta_time()) / 2
                if (globais.POS_Y - 109 >= globais.HEIGHT - 350):
                    globais.STATUS_PERSONAGEM = 0
            globais.ESTADO_ANTERIOR = 1
        elif (globais.STATUS_PERSONAGEM == 6):
            self.setPosicao()
            self.personagem.update()
            globais.ESTADO_ANTERIOR = 0
        elif (globais.STATUS_PERSONAGEM == 7):
            self.setPosicao()
            self.personagem.update()
            globais.ESTADO_ANTERIOR = 1
        elif (globais.STATUS_PERSONAGEM == 8):
            globais.POS_Y = globais.HEIGHT - self.tela.getSolo(
            ).height - self.abaixado_d.height
            self.setPosicao()
            if (self.teclado.key_pressed("DOWN") == False):
                (globais.POS_Y) = (globais.HEIGHT - globais.HEIGHT_S)
                globais.STATUS_PERSONAGEM = 0
            globais.ESTADO_ANTERIOR = 0
        elif (globais.STATUS_PERSONAGEM == 9):
            globais.POS_Y = globais.HEIGHT - self.tela.getSolo(
            ).height - self.abaixado_e.height
            self.setPosicao()
            if (self.teclado.key_pressed("DOWN") == False):
                globais.POS_Y = (globais.HEIGHT - globais.HEIGHT_S)
                globais.STATUS_PERSONAGEM = 1
        elif (globais.STATUS_PERSONAGEM == 10):
            self.setPosicao()
            self.personagem.update()
            globais.ESTADO_ANTERIOR = 0
        elif (globais.STATUS_PERSONAGEM == 11):
            self.setPosicao()
            self.personagem.update()
            globais.ESTADO_ANTERIOR = 1

    def parar(self):
        if ((self.personagem.get_curr_frame()
             == (self.personagem.get_final_frame() - 1))
                and (globais.ESTADO_ANTERIOR == 0)):
            globais.STATUS_PERSONAGEM = 0
            return False
        elif ((self.personagem.get_curr_frame()
               == (self.personagem.get_final_frame() - 1))
              and (globais.ESTADO_ANTERIOR == 1)):
            globais.STATUS_PERSONAGEM = 1
            return False
        else:
            return True

    def setGravidade(self):
        if (globais.POS_Y < self.window.height):
            if ((self.collision.collided(self.personagem,
                                         self.tela.getSolo())) == False):
                globais.POS_Y += globais.GRAVIDADE * self.window.delta_time()

    def getPersonagem(self):
        return self.personagem

    def setReturn(self):
        if (self.teclado.key_pressed("ESC") or (globais.VIDA_PERSONAGEM == 0)):
            self.pontuacao.setArquivoPontuacao()
            globais.GAME_STATE = 0
        self.window.delay(10)
Esempio n. 20
0
    def game_menu(self):

        pygame.init()
        tela_menu_iniciar = Tela(620, 360, "CarniceHero", "menu_iniciar.jpg")
        tela_menu_dificuldade = Tela(620, 360, "CarniceHero",
                                     "menu_dificuldade.jpg")
        tela_menu_creditos = Tela(620, 360, "CarniceHero", "menu_creditos.jpg")
        audio_menu_navigate = Audio("menu_navigate_0.wav", 1)

        relogio_jogo = Relogio(60)

        fechar_jogo = False
        tela_menu = "menu_iniciar"
        menu = True
        while menu:
            for event in pygame.event.get():

                if event.type == pygame.QUIT:
                    fechar_jogo = True
                    menu = False

                elif event.type == pygame.KEYDOWN:
                    audio_menu_navigate.audio.play()
                    if event.key == 13:  # 13 == botao ENTER:
                        menu = False

                    elif tela_menu == "menu_iniciar":
                        if event.key == pygame.K_DOWN:
                            tela_menu = "menu_dificuldade"
                        elif event.key == pygame.K_UP:
                            tela_menu = "menu_creditos"

                    elif tela_menu == "menu_dificuldade":
                        if event.key == pygame.K_DOWN:
                            tela_menu = "menu_creditos"
                        elif event.key == pygame.K_UP:
                            tela_menu = "menu_iniciar"

                    elif tela_menu == "menu_creditos":
                        if event.key == pygame.K_DOWN:
                            tela_menu = "menu_iniciar"
                        elif event.key == pygame.K_UP:
                            tela_menu = "menu_dificuldade"

            if tela_menu == "menu_iniciar":
                tela_menu_iniciar.tela.blit(tela_menu_iniciar.imagemFundo,
                                            (0, 0))
            elif tela_menu == "menu_dificuldade":
                tela_menu_dificuldade.tela.blit(
                    tela_menu_dificuldade.imagemFundo, (0, 0))
            elif tela_menu == "menu_creditos":
                tela_menu_creditos.tela.blit(tela_menu_creditos.imagemFundo,
                                             (0, 0))

            relogio_jogo.relogio.tick(relogio_jogo.fps)
            pygame.display.update()

        if fechar_jogo:
            return "fechar_jogo"
        else:
            return tela_menu


# tela_menu = Menu()
# print(tela_menu.game_menu())
Esempio n. 21
0
def main(stdscr):

    posicoes = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]

    controle = Controle(stdscr=stdscr)
    tela = Tela(stdscr=stdscr, posicoes=posicoes)
    jogadores = Jogadores(controle=controle, posicoes=posicoes)
    tela.reiniciar_tela()
    dado = Dado()

    jogador_x = 0
    jogador_o = 0

    while True:

        controle.espaco_do_tabuleiro()

        if jogadores.fim_de_partida is False:
            if controle.entrada == "\n":
                jogadores.jogar()

            if jogadores.fim_de_partida is True:
                ganhador = jogadores.vencedor
                if ganhador == "X":
                    jogador_x += 1
                if ganhador == "O":
                    jogador_o += 1

        if controle.entrada == "y":
            for i in range(3):
                for j in range(3):
                    posicoes[i][j] = " "

            controle.pos_y = 0
            controle.pos_x = 0
            jogadores.vencedor = None
            jogadores.fim_de_partida = False
            tela.reiniciar_tela()

        if controle.entrada == 'h':
            tela.ajuda()
        else:
            tela.tabuleiro(controle)
            tela.placar(jogador_x, jogador_o)
            if jogadores.fim_de_partida is True:
                tela.fim_de_jogo(jogadores.vencedor)
            controle.cursor()
Esempio n. 22
0
from tela import Tela

m_tela = Tela(480, 480, 20, 20)
m_tela.setup()
m_tela.run()
Esempio n. 23
0
def main(stdscr):
    posicoes = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]

    controle = Controle(stdscr=stdscr)
    tela = Tela(stdscr=stdscr, posicoes=posicoes)
    jogadores = Jogadores(controle=controle, posicoes=posicoes)
    tela.reiniciar_tela()

    jogador_x = 0
    jogador_o = 0

    while True:
        controle.espaco_do_tabuleiro()
        if jogadores.fim_de_partida is False:
            if controle.entrada == "\n":
                jogadores.jogar()

            if jogadores.fim_de_partida is True:
                ganhador = jogadores.vencedor
                if ganhador == "x":
                    jogador_x += 1
                if ganhador == "o":
                    jogador_o += 1

        if controle.entrada == "y":
            """
            # Gera o bug de referência
            posicoes = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]
            controle.pos_y = 0
            controle.pos_x = 0
            jogadores.vencedor = None
            jogadores.fim_de_partida = False
            tela.reiniciar_tela()
            """

            #Adequado para poupar memória ao
            #longo da execução prolongada do programa
            for i in range(3):
                for j in range(3):
                    posicoes[i][j] = " "

            controle.pos_y = 0
            controle.pos_x = 0
            jogadores.vencedor = None
            jogadores.fim_de_partida = False
            tela.reiniciar_tela()
            """
            #Cria novos objetos do jogo a cada reinicialização da partida
            #Ao longo do tempo poderá gerar muito lixo na memória
            posicoes = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]
            controle = Controle(stdscr=stdscr)
            tela = Tela(stdscr=stdscr, posicoes=posicoes)
            jogadores = Jogadores(controle=controle, posicoes=posicoes)
            tela.reiniciar_tela()
            """

        if controle.entrada == 'h':
            tela.ajuda()
        else:
            tela.tabuleiro(controle)
            tela.placar(jogador_x, jogador_o)
            if jogadores.fim_de_partida is True:
                tela.fim_de_jogo(jogadores.vencedor)
            controle.cursor()
Esempio n. 24
0
class Humano(object):
    def __init__(self, window):
        self.window = window
        self.tela = Tela(window)
        self.collision = Collision()
        self.setHumanoE()
        self.setHumanoD()
        self.setAtaqueHumanoD()
        self.setAtaqueHumanoE()
        self.humano = self.humano_e
        self.humanoVetor = []
        self.setPosicaoInicial()
        self.posicoes = Posicoes(window)
        self.random = random.SystemRandom()

    def setPosicaoInicial(self):
        globais.HUMANO_POS_X = globais.WIDTH - 200
        globais.HUMANO_POS_Y = (globais.HEIGHT - globais.HEIGHT_S -
                                self.humano.height)
        self.humano.set_position(globais.HUMANO_POS_X, globais.HUMANO_POS_Y)
        self.humanoVetor.append(self.humano)

    def setPosicao(self):
        globais.HUMANO_POS_X += globais.VEL_INIMIGO_H * self.window.delta_time(
        )
        self.humanoVetor[0].set_position(globais.HUMANO_POS_X,
                                         globais.HUMANO_POS_Y)
        self.humanoVetor[0].update()
        self.humanoVetor[0].draw()

    def setHumanoD(self):
        self.humano_d = Animation("img/inimigo_d2.png", 6, loop=True)
        self.humano_d.set_sequence_time(0, 6, 600, loop=True)

    def setHumanoE(self):
        self.humano_e = Animation("img/inimigo_e2.png", 6, loop=True)
        self.humano_e.set_sequence_time(0, 6, 600, loop=True)

    def setAtaqueHumanoD(self):
        self.ataque_humano_d = Animation("img/Inimigo_atk_d.png", 4, loop=True)
        self.ataque_humano_d.set_sequence_time(0, 4, 200, loop=True)

    def setAtaqueHumanoE(self):
        self.ataque_humano_e = Animation("img/Inimigo_atk_e.png", 4, loop=True)
        self.ataque_humano_e.set_sequence_time(0, 4, 200, loop=True)

    def setAtaque(self):
        if ((self.humanoVetor[0].x + self.humanoVetor[0].width <
             globais.POS_X - 30) and
            (self.humanoVetor[0].x + self.humanoVetor[0].width < globais.POS_X)
                and (self.humanoVetor[0] == self.humano_d) and
            (self.humanoVetor[0].y <= globais.POS_Y + globais.HEIGHT_P)):
            return True
        elif ((self.humanoVetor[0].x < globais.POS_X + globais.WIDTH_P + 30)
              and (self.humanoVetor[0].x > globais.POS_X + globais.WIDTH_P)
              and (self.humanoVetor[0] == self.humano_e)
              and (self.humanoVetor[0].y <= globais.POS_Y + globais.HEIGHT_P)):
            return True
        return False

    def setGravidade(self):
        if (globais.POS_Y < self.window.height):
            if ((self.collision.collided(self.humano,
                                         self.tela.getSolo())) == False):
                globais.POS_Y += globais.GRAVIDADE * self.window.delta_time()

    def setInverter(self):
        if (self.setAtaque() == False):
            if (self.humanoVetor[0].x + self.humanoVetor[0].width + 50 <
                    globais.POS_X):
                globais.VEL_INIMIGO_H = 100
                self.humanoVetor[0] = self.humano_d
            elif (self.humanoVetor[0].x >
                  globais.POS_X + globais.WIDTH_P + 50):
                globais.VEL_INIMIGO_H = -100
                self.humanoVetor[0] = self.humano_e
        elif (self.setAtaque() == True):
            if (globais.VEL_INIMIGO_H == -100):
                self.humanoVetor[0] = self.ataque_humano_e
            elif (globais.VEL_INIMIGO_H == 100):
                self.humanoVetor[0] = self.ataque_humano_d

    def colisao(self):
        self.personagem = self.posicoes.getPersonagem()
        if (self.collision.collided(self.personagem,
                                    self.humanoVetor[0]) == True):
            if (self.collision.collided(self.personagem, self.humanoVetor[0])
                    and (self.humano == self.ataque_humano_d
                         or self.humano == self.ataque_humano_e)):
                self.posicoes.setPosicaoInicial()
                globais.VIDA_P -= 1
            elif (self.collision.collided(self.personagem, self.humanoVetor[0])
                  and (globais.STATUS_PERSONAGEM == 6
                       or globais.STATUS_PERSONAGEM == 7)):
                self.humanoVetor.pop(0)
                self.setPosicaoInicial()
                globais.PONTUACAO += 10
Esempio n. 25
0
 def __init__(self):
   self.tela = Tela()
   self.placar = Placar()
   self.inicia_partida()
Esempio n. 26
0
 def __init__(self):
     self.window = Window(globais.WIDTH, globais.HEIGHT)
     self.mouse = Mouse()
     self.teclado = Keyboard()
     self.tela = Tela(window)
Esempio n. 27
0
# -*- coding: utf-8 -*-
from PPlay.window import *
from posicoes import Posicoes
from tela import Tela
import globais
from inimigos import Humano
from PPlay.keyboard import Keyboard
from menu import Menu
from highscore import Pontuacao
from dificuldades import Dificuldade

janela = Window(globais.WIDTH,globais.HEIGHT)

tela = Tela(janela)
tela.setFundo()

teclado = Keyboard()

dificuldade = Dificuldade()
dificuldade.setDificuldade()

humano = Humano(janela)

menu = Menu(janela)

posicoes = Posicoes(janela)

pontuacao = Pontuacao(janela)

while True:
    tela.setTela()
    def game_dificuldade(self):

        pygame.init()
        tela_dificuldade_normal = Tela(620, 360, "CarniceHero",
                                       "dificuldade_normal.jpg")
        tela_dificuldade_dificil = Tela(620, 360, "CarniceHero",
                                        "dificuldade_dificil.jpg")
        audio_menu_navigate = Audio("menu_navigate_0.wav", 1)

        relogio_jogo = Relogio(60)

        fechar_jogo = False
        voltar = False
        tela_dificuldade = "dificuldade_normal"
        dificuldade = True
        while dificuldade:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    fechar_jogo = True
                    dificuldade = False

                elif event.type == pygame.KEYDOWN:
                    audio_menu_navigate.audio.play()
                    if tela_dificuldade == "dificuldade_normal":
                        if event.key == pygame.K_DOWN:
                            tela_dificuldade = "dificuldade_dificil"
                        elif event.key == pygame.K_UP:
                            tela_dificuldade = "dificuldade_dificil"

                    elif tela_dificuldade == "dificuldade_dificil":
                        if event.key == pygame.K_DOWN:
                            tela_dificuldade = "dificuldade_normal"
                        elif event.key == pygame.K_UP:
                            tela_dificuldade = "dificuldade_normal"

                    if event.key == 13:  # 13 == botao ENTER:
                        dificuldade = False
                    elif event.key == pygame.K_BACKSPACE:
                        voltar = True
                        dificuldade = False

            if tela_dificuldade == "dificuldade_normal":
                tela_dificuldade_normal.tela.blit(
                    tela_dificuldade_normal.imagemFundo, (0, 0))
            elif tela_dificuldade == "dificuldade_dificil":
                tela_dificuldade_dificil.tela.blit(
                    tela_dificuldade_dificil.imagemFundo, (0, 0))

            relogio_jogo.relogio.tick(relogio_jogo.fps)
            pygame.display.update()

        if fechar_jogo:
            return "fechar_jogo"
        elif voltar:
            return "voltar"
        else:
            return tela_dificuldade


# dificuldade = Dificuldade()
# print(dificuldade.game_dificuldade())
Esempio n. 29
0
    def __init__(self, bg: object, elements: list):

        self.__bg = bg
        self.__elements = elements
        self.__tela = Tela()
Esempio n. 30
0
from tela import Tela

app = Tela()
app.run()