示例#1
0
def update_marquee(cap_char, screen):
    i = 0
    if variables.dirn:
        while i < len(list_of_chars):
            if list_of_chars[i].textrect.centerx > variables.screen_max_x + 50:
                list_of_chars.pop(i)
                i = i - 1
            else:
                list_of_chars[i].update_pos()
                list_of_chars[i].update_screen(screen)
            i = i + 1
        if list_of_chars[-1].textrect.centerx > 50:
            if not dirn_change:
                list_of_chars.append(char_text.char_text(gc(cap_char)))
    else:
        while i < len(list_of_chars):
            if list_of_chars[i].textrect.centerx < -50:
                list_of_chars.pop(i)
                i = i - 1
            else:
                list_of_chars[i].update_pos()
                list_of_chars[i].update_screen(screen)
            i = i + 1
        if list_of_chars[-1].textrect.centerx < variables.screen_max_x - 50:
            if not dirn_change:
                list_of_chars.append(char_text.char_text(gc(cap_char)))
示例#2
0
def show_menu():
    global new_game, captured_char, gameplay, list_of_chars, split_mode_on, str_to_disp, game_start
    game_start=True
    screen.fill(screen_bgcolor)
    events = pygame.event.get()
    str_to_disp=''
    split_mode_on=False
    for event in events:
        if event.type == pygame.QUIT:
            exit()
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_SPACE:
                new_game=not new_game
            elif event.key==pygame.K_RETURN:
                if new_game:
                    captured_char=[]
                else:
                    try:
                        fp = open("savefile_char", "rb")
                        captured_char = pickle.load(fp)
                        fp.close()
                    except:
                        captured_char=[]
                        
                    try:
                        fp = open("savefile_split", "rb")
                        split_mode_on = pickle.load(fp)
                        fp.close()
                    except:
                        split_mode_on=False
                    captured_char=['s','a','v','e','l','o','w','>','<']
                gameplay=not gameplay
                list_of_chars=[char_text(gc(captured_char))]
                return()
    titlebasicfont = pygame.font.SysFont(None, (screen_max_y)//5)
    titleText = titlebasicfont.render('Space _ B___ars', True, (0,255,250))
    titleTextrect = titleText.get_rect()
    titleTextrect.centerx = screen_max_x//2
    titleTextrect.centery = screen_max_y//4
    screen.blit(titleText, titleTextrect)
    menubasicfont = pygame.font.SysFont(None, (screen_max_y)//10)
    menuText1 = menubasicfont.render('New Game', True, (101, 115, 126))
    menuText1rect = menuText1.get_rect()
    menuText1rect.centerx = screen_max_x//2
    menuText1rect.centery = screen_max_y//2 + screen_max_y//5
    screen.blit(menuText1,menuText1rect)
    menuText2 = menubasicfont.render('Load Game', True, (101, 115, 126))
    menuText2rect = menuText2.get_rect()
    menuText2rect.centerx = screen_max_x//2
    menuText2rect.centery = screen_max_y//2 + (3*screen_max_y)//10
    screen.blit(menuText2,menuText2rect)
    
    selector_menu = pygame.Surface((screen_max_x//2, screen_max_y//10), pygame.SRCALPHA)   # per-pixel alpha
    selector_menu.fill((255,255,255,50))                         # notice the alpha value in the color
    if new_game:
        screen.blit(selector_menu, (screen_max_x//4,screen_max_y//2 + screen_max_y//7))
    else:
        screen.blit(selector_menu, (screen_max_x//4,screen_max_y//2 + (2*screen_max_y)//8))
    pygame.display.update()
示例#3
0
def show_menu():
    global new_game, captured_char, gameplay, list_of_chars, split_mode_on, str_to_disp, game_start
    game_start = True
    BackGround = Background('./assets/images/background_image.png', [0, 0])
    screen.fill([255, 255, 255])
    screen.blit(BackGround.image, BackGround.rect)

    events = pygame.event.get()
    str_to_disp = ''
    split_mode_on = False
    for event in events:
        if event.type == pygame.QUIT:
            exit()
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_SPACE:
                new_game = not new_game
                pygame.mixer.music.play()

            elif event.key == pygame.K_RETURN:
                if new_game:
                    captured_char = []
                else:
                    try:
                        fp = open("savefile_char", "rb")
                        captured_char = pickle.load(fp)
                        fp.close()
                    except:
                        captured_char = []

                    try:
                        fp = open("savefile_split", "rb")
                        split_mode_on = pickle.load(fp)
                        fp.close()
                    except:
                        split_mode_on = False
                gameplay = not gameplay
                list_of_chars = [char_text.char_text(gc(captured_char))]
                return ()
    titlebasicfont = pygame.font.SysFont(None, (variables.screen_max_y) // 5)
    titleText = titlebasicfont.render('Space _ B___ars', True, (0, 255, 250))
    titleTextrect = titleText.get_rect()
    titleTextrect.centerx = variables.screen_max_x // 2
    titleTextrect.centery = variables.screen_max_y // 4
    screen.blit(titleText, titleTextrect)
    menubasicfont = pygame.font.SysFont(None, (variables.screen_max_y) // 10)
    menuText1 = menubasicfont.render('New Game', True, (101, 115, 126))
    menuText1rect = menuText1.get_rect()
    menuText1rect.centerx = variables.screen_max_x // 2
    menuText1rect.centery = variables.screen_max_y // 2 + variables.screen_max_y // 5
    screen.blit(menuText1, menuText1rect)
    menuText2 = menubasicfont.render('Load Game', True, (101, 115, 126))
    menuText2rect = menuText2.get_rect()
    menuText2rect.centerx = variables.screen_max_x // 2
    menuText2rect.centery = variables.screen_max_y // 2 + (
        3 * variables.screen_max_y) // 10
    screen.blit(menuText2, menuText2rect)

    selector_menu = pygame.Surface(
        (variables.screen_max_x // 2, variables.screen_max_y // 10),
        pygame.SRCALPHA)  # per-pixel alpha
    selector_menu.fill(
        (255, 255, 255, 50))  # notice the alpha value in the color
    if new_game:
        screen.blit(selector_menu,
                    (variables.screen_max_x // 4, variables.screen_max_y // 2 +
                     variables.screen_max_y // 7))
    else:
        screen.blit(selector_menu,
                    (variables.screen_max_x // 4, variables.screen_max_y // 2 +
                     (2 * variables.screen_max_y) // 8))
    pygame.display.update()