示例#1
0
def Stage_Clear(screen,player):
#==============================================================================
#     Fonte
#==============================================================================
    stage_clear = constants.Get_Font(constants.SaiyanFont,100)
    Stage_clear = stage_clear.render("Stage Clear",True,constants.WHITE,None)
    Stage_clear_Rect = Stage_clear.get_rect()
    Stage_clear_Rect.center = ((constants.SCREEN_WIDTH/2),(constants.SCREEN_HEIGHT/2))
#==============================================================================
#    Tela 
#==============================================================================
    black_surf = pygame.Surface((constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT), pygame.SRCALPHA)
    black_surf.fill((0, 0, 0, 180))
    screen.blit(black_surf, (0, 0))
    screen.blit(Stage_clear,Stage_clear_Rect)
    for event in pygame.event.get():
            if pygame.joystick.get_count() > 0:
                 if event.type == pygame.JOYBUTTONDOWN:
                     if event.button == 2 or 9:
                        constants.game_clear = True
            else:
                pressed = pygame.key.get_pressed()
                if event.type == pygame.QUIT:
                    pygame.quit() # Fecha a janela se o usuário clicar em fechar
                    quit()
                if event.type == pygame.KEYDOWN:
                    if ((pressed[pygame.K_LALT] and pressed[pygame.K_F4]) or (pressed[pygame.K_RALT] and pressed[pygame.K_F4])):
                        pygame.quit() # Fecha a janela se o usuário pressionar ALT+F4
                        quit() 
                    if pygame.K_RETURN:
                        constants.game_clear = True
示例#2
0
 def player_hud(self, screen):
     
     self.Hp_Max_Porc = (constants.Hp_Max/constants.Hp_Max)*100
     self.Hp_Porc = (self.hp/constants.Hp_Max)*100
     self.Mp_Max_Porc = (constants.Mp_Max/constants.Mp_Max)*100
     self.Mp_Porc = (self.mp/constants.Mp_Max)*100
     Vida = constants.Get_Font("font\8-BIT WONDER.TTF", 10)
     
     Vidas = Vida.render("x"+str(self.Lives), True, constants.WHITE, None)
     Vidas_Rect = Vidas.get_rect()
     Vidas_Rect.x ,Vidas_Rect.y = 190,104 
     
    
     pygame.draw.rect(screen, constants.WHITE,(0,60,60,69))
     pygame.draw.rect(screen, constants.BGREEN,(1,61,58,67))
     screen.blit(self.Face, (1,60))
     pygame.draw.rect(screen, constants.WHITE, (61, 104, 1.5*self.Hp_Max_Porc+2, 12)) 
     pygame.draw.rect(screen, constants.GRAY, (62, 105, 1.5*self.Hp_Max_Porc, 10))
     if self.Hp_Porc >= self.Hp_Max_Porc * 0.75:
         pygame.draw.rect(screen, constants.GREEN, (62, 105, 1.5*self.Hp_Porc, 10))
     elif self.Hp_Porc >= self.Hp_Max_Porc * 0.25 and self.Hp_Porc < self.Hp_Max_Porc * 0.75:
         pygame.draw.rect(screen, constants.YELLOW, (62, 105, 1.5*self.Hp_Porc, 10))
     elif self.Hp_Porc < self.Hp_Max_Porc * 0.25 and self.Hp_Porc > 0:
         pygame.draw.rect(screen, constants.RED, (62, 105, 1.5*self.Hp_Porc, 10))
     elif self.Hp_Porc == 0:
         pygame.draw.rect(screen, constants.GRAY, (62, 105, 1.5*self.Hp_Max_Porc, 10))
     screen.blit(Vidas,Vidas_Rect)
     pygame.draw.rect(screen, constants.WHITE, (61, 117, (1.5*self.Mp_Max_Porc)+2, 12))
     pygame.draw.rect(screen, constants.GRAY, (62, 118, 1.5*self.Mp_Max_Porc, 10))
     pygame.draw.rect(screen, constants.BLUE, (62, 118, 1.5*self.Mp_Porc, 10))
示例#3
0
def Game_Start(Screen,player):
    black_surf = pygame.Surface((constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT), pygame.SRCALPHA)
    black_surf.fill((0, 0, 0,0))
    Screen.blit(black_surf, (0, 0))
    if  45 < player.rect.x :
        if constants.b == 0:
            Sounds.Read_go.play()
            constants.b = 1
        if constants.e <=20:
            Ready = constants.Get_Font(constants.SaiyanFont,constants.f_s)
            ready_txt = Ready.render("Ready",True, constants.WHITE, None)
            ready_txt_rect = ready_txt.get_rect()
            ready_txt_rect.center = (constants.SCREEN_WIDTH / 2, constants.SCREEN_HEIGHT/2-25)
            Screen.blit(ready_txt, ready_txt_rect)
            constants.f_s += 1
            constants.e += 1
        elif 20< constants.e <= 40:
            if constants.a == 0:
                constants.f_s = 72
                constants.a = 1
            go = constants.Get_Font(constants.SaiyanFont,constants.f_s)
            go_txt = go.render("Go", True ,constants.WHITE, None)
            go_txt_rect = go_txt.get_rect()
            go_txt_rect.center =(constants.SCREEN_WIDTH / 2, constants.SCREEN_HEIGHT/2-25)
            Screen.blit(go_txt, go_txt_rect)
            constants.f_s += 1
            constants.e += 1
        else:
            constants.e = 0
            constants.f_s = 72
            constants.b = 0
    
    if player.rect.x <= 200:
        if player.State('move'):
            player.go_right()
    else:
        player.stop()
        constants.game_start = False
示例#4
0
def Pause():
    pygame.joystick.init()
    if pygame.joystick.get_count() > 0:
        joystick = pygame.joystick.Joystick(0)
        joystick.init()

    background = pygame.image.load("Fotos\Start Screen.png").convert()
    start = constants.Get_Font(constants.BitFont, 22)
    press_start = start.render("Pause", True, constants.WHITE, None)

    instart = True

    while instart:

        screen1 = pygame.display.set_mode(
            (constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT))
        screen1.blit(background, (0, 0))
        press_start_rect = press_start.get_rect()
        press_start_rect.center = (constants.SCREEN_WIDTH / 2,
                                   constants.SCREEN_HEIGHT / 2)
        screen1.blit(press_start, press_start_rect)
        pygame.display.update()

        for event in pygame.event.get():
            if pygame.joystick.get_count() > 0:

                if event.type == pygame.QUIT:
                    pygame.quit()
                if event.type == pygame.JOYBUTTONDOWN:
                    if event.button == 9:
                        instart = False
                        constants.Pause = True
            else:
                pressed = pygame.key.get_pressed()
                if event.type == pygame.QUIT:
                    pygame.quit()
                if event.type == pygame.KEYDOWN:
                    if ((pressed[pygame.K_LALT] and pressed[pygame.K_F4])):
                        pygame.quit()

                    elif pressed[pygame.K_RETURN]:
                        instart = False
                        constants.Pause = True
示例#5
0
    def boss_hud(self, screen):
        if self.live:
            self.boss_name = self.nome
            self.Hp_Max_Porc = (self.Hp_Max / self.Hp_Max) * 100
            self.Hp_Porc = (self.hp / self.Hp_Max) * 100

            nome = constants.Get_Font("font\8-BIT WONDER.TTF", 10)

            nome = nome.render(self.boss_name, True, constants.WHITE, None)
            nome_Rect = nome.get_rect()
            nome_Rect.x, nome_Rect.y = 1000, 104

            #            pygame.draw.rect(screen, constants.WHITE,(0,60,60,69))
            #            pygame.draw.rect(screen, constants.BGREEN,(1,61,58,67))
            #            screen.blit(self.Face, (1,60))
            pygame.draw.rect(screen, constants.WHITE,
                             (951, 117, (2 * self.Hp_Max_Porc) + 2, 12))
            pygame.draw.rect(screen, constants.GRAY,
                             (952, 118, 2 * self.Hp_Max_Porc, 10))
            if self.Hp_Porc > 0.75 * self.Hp_Max_Porc:
                pygame.draw.rect(screen, constants.GREEN,
                                 (952, 118, 2 * self.Hp_Max_Porc, 10))
                pygame.draw.rect(screen, constants.BLUE,
                                 (952, 118, 2 * self.Hp_Porc, 10))
            if 0.5 * self.Hp_Max_Porc < self.Hp_Porc <= .75 * self.Hp_Max_Porc:
                pygame.draw.rect(screen, constants.YELLOW,
                                 (952, 118, 2 * self.Hp_Max_Porc, 10))
                pygame.draw.rect(screen, constants.GREEN,
                                 (952, 118, 2 * self.Hp_Porc, 10))
            if 0.25 * self.Hp_Max_Porc < self.Hp_Porc <= .5 * self.Hp_Max_Porc:
                pygame.draw.rect(screen, constants.RED,
                                 (952, 118, 2 * self.Hp_Max_Porc, 10))
                pygame.draw.rect(screen, constants.YELLOW,
                                 (952, 118, 2 * self.Hp_Porc, 10))
            if 0.25 * self.Hp_Max_Porc >= self.Hp_Porc:
                pygame.draw.rect(screen, constants.RED,
                                 (952, 118, 2 * self.Hp_Porc, 10))
示例#6
0
def Start_Screen():

    pygame.joystick.init()
    if pygame.joystick.get_count() > 0:
        joystick = pygame.joystick.Joystick(0)
        joystick.init()

    pygame.mixer.music.load("Music\StartScreean.ogg")
    pygame.mixer.music.set_volume(0.3)
    pygame.mixer.music.play(-1)

    background = pygame.image.load("Fotos\Start Screen.png").convert()
    Title = constants.Get_Font(constants.SaiyanFont, 72)
    bit = constants.Get_Font(constants.BitFont, 22)
    game_title = Title.render("Satan World Hero", True, constants.WHITE, None)

    if pygame.joystick.get_count() > 0:
        press_start = bit.render("Press START", False, constants.WHITE)
    else:
        press_start = bit.render("Press ENTER", False, constants.WHITE)

    instart = True

    while instart:

        screen1 = pygame.display.set_mode(
            (constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT))
        screen1.blit(background, (0, 0))
        game_title_rect = game_title.get_rect()
        game_title_rect.center = (constants.SCREEN_WIDTH / 2,
                                  constants.SCREEN_HEIGHT - 600)
        screen1.blit(game_title, game_title_rect)
        press_start_rect = press_start.get_rect()
        press_start_rect.center = (constants.SCREEN_WIDTH / 2,
                                   constants.SCREEN_HEIGHT - 150)
        screen1.blit(press_start, press_start_rect)
        pygame.display.update()

        for event in pygame.event.get():
            if pygame.joystick.get_count() > 0:

                if event.type == pygame.QUIT:
                    pygame.quit()
                if event.type == pygame.JOYBUTTONDOWN:
                    if event.button == 9:
                        pygame.mixer.music.stop()
                        instart = False
                        constants.game_start = True
                    else:
                        #ERRROU
                        Sounds.Errou.play()
                        pygame.display.update()
                        pygame.event.wait()
            else:
                pressed = pygame.key.get_pressed()
                if event.type == pygame.QUIT:
                    pygame.quit()
                if event.type == pygame.KEYDOWN:
                    if ((pressed[pygame.K_LALT] and pressed[pygame.K_F4])):
                        pygame.quit()

                    elif pressed[pygame.K_RETURN]:
                        pygame.mixer.music.stop()
                        instart = False
                        constants.game_start = True
                    else:
                        #ERRROU
                        Sounds.Errou.play()
                        pygame.display.update()
                        pygame.event.wait()
示例#7
0
def Game_Clear(Screen,player,cp):
    
    background = pygame.image.load("Fotos\Start Screen.png").convert()
    if constants.teste == 0:
        pygame.mixer.music.load("Music\GameClear.ogg")
        pygame.mixer.music.set_volume(0.3)
        pygame.mixer.music.play(-1)
        constants.teste = 1
    
    Bla= constants.Get_Font(constants.BitFont,72)
    Bla_Bla = Bla.render("Satan World Hero", True, constants.WHITE, None)
    Bla_Bla_Rect = Bla_Bla.get_rect()
    
    black_surf = pygame.Surface((constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT), pygame.SRCALPHA)
    black_surf.fill((0, 0, 0, 0))
    Screen.blit(black_surf, (0, 0))
    if constants.y >= constants.SCREEN_HEIGHT/2 :
        Bla_Bla_Rect.center = (constants.SCREEN_WIDTH / 2, constants.y)
        Screen.blit(background, (0,0))
        Screen.blit( Bla_Bla,Bla_Bla_Rect)
        constants.y -=5
    else:
       Bla_Bla_Rect.center = (constants.SCREEN_WIDTH / 2, constants.SCREEN_HEIGHT/2)
       Screen.blit(background, (0,0))
       Screen.blit( Bla_Bla,Bla_Bla_Rect)
       
       for event in pygame.event.get():
            if pygame.joystick.get_count() > 0:
                 if event.type == pygame.JOYBUTTONDOWN:
                     if event.button == 2 or 9:
                        levels.Start_Screen()
                        constants.regrecive = 11
                        player.live = True
                        player.hp = constants.Hp_Max
                        player.rect.x -= cp - 200
                        player.Muda_Rota = 20
                        player.rect.y = constants.SCREEN_HEIGHT - player.rect.height - player.Muda_Rota 
                        player.dmg = False
                        player.jump = False
                        constants.reset = True
                        constants.game_clear = False
                        
            else:
                pressed = pygame.key.get_pressed()
                if event.type == pygame.QUIT:
                    pygame.quit() # Fecha a janela se o usuário clicar em fechar
                    quit()
                if event.type == pygame.KEYDOWN:
                    if ((pressed[pygame.K_LALT] and pressed[pygame.K_F4]) or (pressed[pygame.K_RALT] and pressed[pygame.K_F4])):
                        pygame.quit() # Fecha a janela se o usuário pressionar ALT+F4
                        quit() 
                    if pygame.K_RETURN:
                        levels.Start_Screen()
                        constants.regrecive = 11
                        player.live = True
                        player.hp = constants.Hp_Max
                        player.rect.x -= cp - 200
                        player.Muda_Rota = 20
                        player.rect.y = constants.SCREEN_HEIGHT - player.rect.height - player.Muda_Rota 
                        player.dmg = False
                        player.jump = False
                        constants.reset = True
                        constants.game_clear = False
示例#8
0
def dead_screen(screen,player, cp):
    if constants.regrecive >= 0:
    #==============================================================================
        #Carre as Fontes    
    #==============================================================================
        pre_game_over = constants.Get_Font(constants.SaiyanFont,72)        
        Continue = constants.Get_Font(constants.BitFont, 22)
        Cont = constants.Get_Font(constants.BitFont,200)
        you_died_txt = pre_game_over.render("Meu Estomago Doi", True, constants.WHITE, None)
        continue_txt = Continue.render("Continue?", True, constants.WHITE, None)
    #==============================================================================
        #Carrega Es informaçoes:
    #==============================================================================
        if constants.regrecive <=10:
            black_surf = pygame.Surface((constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT), pygame.SRCALPHA)
            black_surf.fill((0, 0, 0, 180))
            screen.blit(black_surf, (0, 0))
            you_died_rect = you_died_txt.get_rect()
            you_died_rect.center = ((constants.SCREEN_WIDTH/2),(constants.SCREEN_HEIGHT/5-100))
            screen.blit(you_died_txt, you_died_rect)    
            continue_rect = you_died_txt.get_rect()
            continue_rect.center = ((100+constants.SCREEN_WIDTH/2),(constants.SCREEN_HEIGHT/5))
            screen.blit(continue_txt, continue_rect)    
            cont_txt = Cont.render(str(constants.regrecive),True,constants.WHITE,None)
            cont_txt_rect = cont_txt.get_rect()
            cont_txt_rect.center = ((constants.SCREEN_WIDTH/2),(constants.SCREEN_HEIGHT/2))
            screen.blit (cont_txt,cont_txt_rect)
        if constants.n == 0:
            Sounds.contagem()
            constants.n = 1
        if constants.delays > 40:
            constants.n = 0
            constants.delays = 0
            constants.regrecive -= 1            
        else:
            constants.delays += 1 
    
        for event in pygame.event.get():
            if pygame.joystick.get_count() > 0:
                if event.type == pygame.JOYBUTTONDOWN:
                    if event.button == 2 or event.button == 9:
                        constants.regrecive = 11
                        player.live = True
                        player.Lives = 2
                        player.hp = constants.Hp_Max
                        player.rect.x -= cp - 200
                        player.Muda_Rota = 20
                        player.rect.y = constants.SCREEN_HEIGHT - player.rect.height - player.Muda_Rota 
                        player.dmg = False
                        player.jump = False
                        constants.reset = True
                    elif event.button == 0:
                        constants.regrecive -= 1
               
            else:
                pressed = pygame.key.get_pressed()
                if event.type == pygame.QUIT:
                    pygame.quit() # Fecha a janela se o usuário clicar em fechar
                    quit()
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_RETURN:
                        constants.regrecive = 11
                        player.live = True
                        player.hp = constants.Hp_Max
                        player.rect.x -= cp - 200
                        player.Muda_Rota = 20
                        player.rect.y = constants.SCREEN_HEIGHT - player.rect.height - player.Muda_Rota 
                        player.dmg = False
                        player.jump = False
                        constants.reset = True
                    if ((pressed[pygame.K_LALT] and pressed[pygame.K_F4]) or (pressed[pygame.K_RALT] and pressed[pygame.K_F4])):
                        pygame.quit() # Fecha a janela se o usuário pressionar ALT+F4
                        quit()    
    else:
        if constants.s == 0:
            Sounds.Game_Over.play(0)
            constants.s = 1
        black_surf = pygame.Surface((constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT), pygame.SRCALPHA)
        black_surf.fill((0, 0, 0, 255))
        screen.blit(black_surf, (0, 0))
        game_over = constants.Get_Font(constants.SaiyanFont,90)
        Game_over = game_over.render("Game Over",True,constants.WHITE,None)
        Game_over_Rect = Game_over.get_rect()
        Game_over_Rect.center = ((constants.SCREEN_WIDTH/2),(constants.SCREEN_HEIGHT/2))
        screen.blit(Game_over, Game_over_Rect)
        for event in pygame.event.get():
            if pygame.joystick.get_count() > 0:
                 if event.type == pygame.JOYBUTTONDOWN:
                     if event.button == 2 or 9:
                        levels.Start_Screen()
                        constants.regrecive = 11
                        player.live = True
                        player.hp = constants.Hp_Max
                        player.rect.x -= cp - 200
                        player.Muda_Rota = 20
                        player.rect.y = constants.SCREEN_HEIGHT - player.rect.height - player.Muda_Rota 
                        player.dmg = False
                        player.jump = False
                        constants.reset = True
                        
            else:
                pressed = pygame.key.get_pressed()
                if event.type == pygame.QUIT:
                    pygame.quit() # Fecha a janela se o usuário clicar em fechar
                    quit()
                if event.type == pygame.KEYDOWN:
                    if ((pressed[pygame.K_LALT] and pressed[pygame.K_F4]) or (pressed[pygame.K_RALT] and pressed[pygame.K_F4])):
                        pygame.quit() # Fecha a janela se o usuário pressionar ALT+F4
                        quit() 
                    if pygame.K_RETURN:
                        levels.Start_Screen()
                        constants.regrecive = 11
                        player.live = True
                        player.hp = constants.Hp_Max
                        player.rect.x -= cp - 600
                        player.Muda_Rota = 20
                        player.rect.y = constants.SCREEN_HEIGHT - player.rect.height - player.Muda_Rota 
                        player.dmg = False
                        player.jump = False
                        constants.reset = True
                        constants.d = 0