Exemple #1
0
def show_the_end(screen):
    the_end_image = cg_image_controller.get(sfg.EndGame.THE_END_IMAGE_KEY).subsurface(
        sfg.EndGame.THE_END_IMAGE_RECT).convert()
    the_end_image_rect = the_end_image.get_rect()
    the_end_image_rect.center = sfg.Screen.SIZE[0] * 0.5, sfg.Screen.SIZE[1] * 0.4

    the_end_word = sfg.EndGame.THE_END_WORD
    the_end_word_rect = the_end_word.get_rect()
    the_end_word_rect.center = sfg.Screen.SIZE[0] * 0.5, sfg.Screen.SIZE[1] * 0.8

    mask_alpha = 255
    fade_in_delta = 256 / (sfg.EndGame.ENDING_FADEIN_TIME - sfg.EndGame.THE_END_SHOW_DELAY_TIME)
    delay_time = 0
    mask = sfg.Screen.DEFAULT_SURFACE
    clock = pygame.time.Clock()
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True

        screen.fill(pygame.Color("black"))
        screen.blit(the_end_image, the_end_image_rect)
        screen.blit(the_end_word, the_end_word_rect)

        time_passed = clock.tick(sfg.FPS)
        passed_seconds = time_passed * 0.001
        mask_alpha = int(max(mask_alpha - passed_seconds * fade_in_delta, 0))
        mask.fill(pygame.Color(0, 0, 0, mask_alpha))
        screen.blit(mask, (0, 0))

        pygame.display.flip()
        if mask_alpha == 0:
            delay_time += passed_seconds
            if delay_time > sfg.EndGame.THE_END_SHOW_DELAY_TIME:
                return
Exemple #2
0
def loading_chapter_picture(screen):
    img = cg_image_controller.get(sfg.Chapter.LOADING_PICTURE_IMAGE_KEY).subsurface(
        sfg.Chapter.LOADING_PICTURE_RECT).convert()
    img_rect = img.get_rect()
    img_rect.center = sfg.Screen.SIZE[0] * 0.5, sfg.Screen.SIZE[1] * 0.45

    alpha = 0
    delta = 256 / sfg.Chapter.LOADING_PICTURE_FADE_IN_TIME
    clock = pygame.time.Clock()
    while alpha < 255:
        for event in pygame.event.get():
            # no event handle, avoiding "mouse stuck"
            pass

        screen.fill(pygame.Color("black"))
        time_passed = clock.tick(sfg.FPS)
        passed_seconds = time_passed * 0.001
        alpha = int(min(alpha + passed_seconds * delta, 255))
        img.set_alpha(alpha)
        screen.blit(img, img_rect)
        screen.blit(sfg.Chapter.LOADING_WORD, sfg.Chapter.LOADING_WORD_BLIT_POS)
        pygame.display.flip()
Exemple #3
0
def start_game(screen):
    bg_box.play(sfg.Music.START_GAME_KEY)

    pic = cg_image_controller.get(sfg.StartGame.PICTURE_IMAGE_KEY).convert()
    pic_rect = pic.get_rect()

    screen_centerx = sfg.Screen.SIZE[0] * 0.5
    pic_rect.centerx = screen_centerx
    pic_rect.top = sfg.StartGame.PICTURE_BLIT_Y

    clock = pygame.time.Clock()
    pic_alpha = 0 # picture fades in, alpha changes from 0 to 255
    fade_in_delta = 256 / sfg.StartGame.PICTURE_FADE_IN_TIME

    # check whether autosave data exists
    autosave = util.load_auto_save()
    if autosave is not None:
        for opt in sfg.Menu.START_GAME["options"]:
            if opt["mark"] == "load":
                opt["display"] = True

    menu = Menu(sfg.Menu.START_GAME)
    while True:
        screen.fill(pygame.Color("black"))

        time_passed = clock.tick(sfg.FPS)
        passed_seconds = time_passed * 0.001
        if pic_alpha < 255:
            pic_alpha = int(min(pic_alpha + passed_seconds * fade_in_delta, 255))
        pic.set_alpha(pic_alpha)
        screen.blit(pic, pic_rect)

        for event in pygame.event.get():
            if pic_alpha < 255:
                continue
                # no events will be handled until the renne's picure is fully displayed
            if event.type == pygame.QUIT: 
                return {"status": cfg.GameControl.QUIT}
            if event.type == KEYDOWN:
                if event.key == K_RETURN:
                    mark = menu.get_current_mark()
                    if mark == "load":
                        return {"status": cfg.GameControl.CONTINUE, "save": autosave}
                    elif mark == "start":
                        return {"status": cfg.GameControl.NEXT}
                    elif mark == "dead_mode":
                        return {"status": cfg.GameControl.DEAD_MODE}
                    elif mark == "quit":
                        return {"status": cfg.GameControl.QUIT}
                elif event.key == K_ESCAPE:
                    return {"status": cfg.GameControl.QUIT}

                menu.update(event.key)

        if pic_alpha == 255:
            menu.draw(screen)
            
        if sfg.CONFIG["hero"] == "joshua":
            joshua_info = sfg.Font.MSYH_16.render(u"Joshua½ÇÉ«¿ªÆô", True, pygame.Color("white"))
            screen.blit(joshua_info, (10, 10))

        pygame.display.flip()