Example #1
0
def high_score(screen1):
    global menu_font
    global screen
    screen =screen1
    menu_font = pygame.font.Font(None, 30)
    options = [Option("PLAY NOW", (100, 305)), Option("MENU", (290, 305))]
    running=True
    text_font = pygame.font.Font(None, 30)
    
    while(running):
        
        #pygame.display.flip()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running=False
                sys.exit()
            pygame.event.pump()
        screen.fill((0, 0, 0))
        for option in options:
            if option.rect.collidepoint(pygame.mouse.get_pos()):
                option.hovered = True               
                if(option.text=="PLAY NOW"):
                    if(pygame.mouse.get_pressed()[0]):
                        running=False
                        birdy.start_game(screen,520,340)
                elif (option.text=="MENU"):
                    if(pygame.mouse.get_pressed()[0]):
                        running=False                        
                        pygame_menu.start(screen)
            else:
                option.hovered = False
            option.draw()
        label=text_font.render("Top   8   Scores:", True,(255,255,255))
        screen.blit(label, (200, 0))
        label=text_font.render("Sl. No.", True,(255,255,255))
        screen.blit(label, (120, 30))
        label=text_font.render("|    Levels Cleared", True,(255,255,255))
        screen.blit(label, (250, 30))
        f=open("score.txt",'r').read()
        f1=f.split("\t")       
        a=[]
        for i in range(0,len(f1)):            
            if(f1!=" "):
                try:
                    a.append(int(f1[i].replace("\n","")))
                except:
                    pass
        a.sort(reverse=True)        
        disp=30
        label=text_font.render("--------------------------------------------------", True,(255,255,255))
        screen.blit(label, (100, 40))
        for i in range(0,8):
            if(i>=len(a)):
                break           
            label=text_font.render(str(i+1), True,(255,255,255))
            screen.blit(label, (120, 30+((i+1)*disp)))
            label=text_font.render("|    "+str(a[i]), True,(255,255,255))
            screen.blit(label, (250, 30+((i+1)*disp)))
            
        pygame.display.update()
Example #2
0
def start(screen1):
    global screen
    screen=screen1
    global menu_font
    menu_font = pygame.font.Font(None, 30)
    #options = [Option("NEW GAME", (140, 115)), Option("HIGH SCORE", (140, 165)),
    #           Option("CONTROLS", (140, 215))]
    options = [Option("NEW GAME", (40, 300)), Option("HIGH SCORE", (200, 300)),
               Option("CONTROLS", (400, 300))]
    running =True
    ball = pygame.image.load("game.bmp")
    ball = pygame.transform.scale(ball, (460, 240))
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:   
                running=False
                sys.exit()
        pygame.event.pump()
        screen.fill((0, 0, 0))
        screen.blit(ball,[40,40,480,300])
        
        for option in options:
            if option.rect.collidepoint(pygame.mouse.get_pos()):
                option.hovered = True                
                if(option.text=="NEW GAME"):
                    if(pygame.mouse.get_pressed()[0]):
                        running=False
                        print"1"
                        #controls.controls(screen)
                        start_game(screen,520,340)
                elif (option.text=="HIGH SCORE"):
                    if(pygame.mouse.get_pressed()[0]):
                        running=False
                        #print"2"
                        high_score.high_score(screen)
                elif (option.text=="CONTROLS"):
                    if(pygame.mouse.get_pressed()[0]):
                        running=False
                        print"3"
                        controls.controls(screen)
            else:
                option.hovered = False
            option.draw()
        pygame.display.update()
Example #3
0
def controls(screen1):
    global menu_font
    global screen
    screen =screen1
    menu_font = pygame.font.Font(None, 30)
    options = [Option("PLAY NOW", (100, 305)), Option("MENU", (290, 305))]
    running=True
    text_font = pygame.font.Font(None, 40)
    
    while(running):
        
        #pygame.display.flip()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running=False
                sys.exit()
            pygame.event.pump()
        screen.fill((0, 0, 0))
        for option in options:
            if option.rect.collidepoint(pygame.mouse.get_pos()):
                option.hovered = True              
                if(option.text=="PLAY NOW"):
                    if(pygame.mouse.get_pressed()[0]):
                        running=False
                        birdy.start_game(screen,520,340)
                elif (option.text=="MENU"):
                    if(pygame.mouse.get_pressed()[0]):
                        running=False                        
                        pygame_menu.start(screen)
            else:
                option.hovered = False
            option.draw()
        label=text_font.render("Use Space or Up Arrow key to ", True,(255,255,255))
        screen.blit(label, (30, 90))
        label=text_font.render("navigate bird against obstacles", True,(255,255,255))
        screen.blit(label, (30, 130))
        
        pygame.display.update()