示例#1
0
def display_title():
    """
    Unused.
    """
    titleImage = pygame.image.load(TITLE_IMAGE_FILE)
    universal.get_screen().blit(titleImage)
    universal.get_screen().flip()
    """
示例#2
0
 def start_episode(self, *startingSceneArgs):
      global postTitleCardFunction, postTitleCardFuncArgs
      universal.get_screen().fill(universal.DARK_GREY)
      music.play_music(self.titleTheme)
      universal.state.player.clear_marks()
      self.init()
      universal.display_text('Episode ' + str(self.num) + ':\n' + self.name, universal.get_world_view(), universal.get_world_view().midleft, isTitle=True)
      universal.acknowledge(self.initialize_episode, *startingSceneArgs)
示例#3
0
def request_difficulty():
    universal.say_title('Character Creation')
    universal.get_screen().blit(universal.get_background(), universal.get_world_view().topleft)
    universal.say('Before we get started, we need to pick a difficulty level:\n\n')
    universal.say('HAND: Enemies choose their actions purely at random.\n\n')
    universal.say('STRAP: Enemies choose their actions based on their own statistics, and the skills of their allies. They choose their target at random.\n\n')
    universal.say('CANE: Enemies choose their actions based on their statistics, the skills of their allies and previous rounds. They choose their target based on the effects of previous rounds.')
    universal.set_commands(['(H)and', '(S)trap', '(C)ane', '(Esc)Quit', '<==Back'])
    universal.set_command_interpreter(request_difficulty_interpreter)
示例#4
0
def title_screen(episode=None):
    global firstEpisode, loadingGame
    textSurface = None
    titleImage = None
    try:
        titleImage = pygame.image.load(TITLE_IMAGES[0]).convert()
        titleImage = pygame.transform.scale(titleImage, (pygame.display.Info().current_w, pygame.display.Info().current_h))
    except IOError:
        textSurface = textrect.render_textrect(get_title(), #+ (":" if get_subtitle() != "" else ""), 
                universal.font, universal.worldView, LIGHT_GREY, DARK_GREY, 1)
    except IndexError:
        textSurface = textrect.render_textrect(get_title(), #+ (":" if get_subtitle() != "" else ""), 
                universal.font, universal.worldView, LIGHT_GREY, DARK_GREY, 1)
    titleImages = []
    if os.path.exists(os.path.join(os.getcwd(), 'save')) and '.init.sav' in os.listdir(os.path.join(os.getcwd(), 'save')):
        #townmode.clear_rooms()
        townmode.previousMode = None
        townmode.load_game('.init.sav', preserveLoadName=False)
    else:
        townmode.save_game('.init.sav', preserveSaveName=False)
    assert(episode is not None or firstEpisode is not None)
    if episode is not None:
        firstEpisode = episode
    screen = universal.get_screen()
    worldView = universal.get_world_view()
    background = universal.get_background()
    screen.fill(universal.DARK_GREY)
    font = pygame.font.SysFont(universal.FONT_LIST, 50)
    wvMidLeft = worldView.midleft
    if loadingGame:
        for i in range(1, len(TITLE_IMAGES)):
            try:
                titleImages.append(pygame.image.load(TITLE_IMAGES[i]))
                titleImages[-1] = pygame.transform.scale(titleImages[-1], (pygame.display.Info().current_w, pygame.display.Info().current_h))
            except IOError:
                continue
        opening_crawl()
        loadingGame = False
    music.play_music(music.THEME)
    universal.set_commands(['(S)tart', '(L)oad', '(A)cknowledgments', '(Esc)Quit'])
    universal.set_command_interpreter(title_screen_interpreter)
    if not skip:
        pygame.time.delay(125)
        for i in range(0, len(titleImages)):
            screen.blit(titleImages[i], worldView.topleft)
            pygame.time.delay(25)
            pygame.display.flip()
    if titleImage is not None:
        screen.blit(titleImage, worldView.topleft)
    else:
        screen.blit(textSurface, worldView.centerleft)
    pygame.display.flip()
    while 1:
        universal.textToDisplay = ''
        universal.titleText = ''
        for event in pygame.event.get():
            if event.type == KEYUP:
                return [universal.get_command_view()]
示例#5
0
def display_acknowledgments():
    universal.say_title('Acknowledgments')
    universal.get_screen().blit(universal.get_background(), universal.get_world_view().topleft)
    universal.say(format_text([['Code, Story, Concept: Andrew Russell'], 
        ['Editor: Emily the Eccentric Emu'],
        ['Support Writers: Emily the Eccentric Emu, Bonemouth the Boxfish, Ken the Kookaburra, Skyblaster the Sardine, Monkeytoster the Mongoose'],
        ['Beta Testers: Uninventive the Umbrellabird, Johny741 the Jackal, Bonemouth the Boxfish, Flash the Flamingo Emily the Eccentric Emu, Ken the Kookaburra, Skyblaster the Sardine, Monkeytoster the Mongoose'],
        ['Number Cruncher: Flash the Flamingo'],
        ['Images:'],
        ['  title screen image: Rak'],
        #['  Episode 1 titlecard: Lys'],
        #['Sound Effects: Filippo Vicarelli. Downloaded from his website: noiseforfun.com'],
        #['Dungeon step: Click Switch'],
        ['All music are free tracks posted by the authors on their websites. None of them are' +
            'involved in Pandemonium Cycle: The Potion Wars'],
        ['Music 1: Filippo Vicarelli: playonloop.com.'], 
        ['  Victory Theme: Waving Grass'],
        ['Music 2: Aaron Krogh https://soundcloud.com/aaron-anderson-11']
        ['  Title Theme: Megaboss Up Tempo'],
        ['  Episode 1 Titlecard: Pre Boss Battle Tension'],
        ["  Vengador's Theme: Heated Battle"],
        ['  Avaricum Theme: Wintry Town'],
        ['  Battle Theme: This Is Not A Drill'],
        ['  Tense Theme: Pre Boss Battle Tension'],
        ['  Defeated Theme: Heresy (also known as Splinter in the Mind)'],
        ["  Peter's Theme: Rose Petals"],
        ["  Edita's Theme: Lost"],
        ["  Maria's Theme : Never Forget"],
        ["  Carrie's Theme: My Friend"],
        ["  Catalin's Theme: Insidia"],
        ["  Roland's Theme: Desert Battle"],
        ["  Elise's Theme: Reflections in Tranquility"],
        ['Coded in Python using the Pygame engine: pygame.org'],
        ]
        ))
    acknowledge(title_screen, None)
示例#6
0
def load_game():
    universal.say_title('Load Game')
    universal.get_screen().blit(universal.get_background(), universal.get_world_view().topleft)
    townmode.load(title_screen)
示例#7
0
def begin_game(episode):
    global displayedText
    global commands
    global screen
    global font
    import os
    if '.init.sav' in os.listdir('save'):
        os.remove(os.path.join('save', '.init.sav'))
# Initialise screen
    #commandText = textrect.render_textrect(' '.join(commands), font, commandView, LIGHT_GREY, DARK_GREY, 1)
    #commandTextPos = commandText.get_rect()
    #commandTextPos.centerx, commandTextPos.centery = commandView.center;
    # Blit everything to the screen
    defaultFont = pygame.font.SysFont(universal.FONT_LIST, universal.DEFAULT_SIZE)
    titleFont = pygame.font.SysFont(universal.FONT_LIST_TITLE, universal.TITLE_SIZE)
    universal.init_game()
    background = universal.get_background()
    screen = universal.get_screen()
    screen.blit(background, (0, 0))
    commandView = universal.get_command_view()
    worldView = universal.get_world_view()
    #commandSurface = pygame.Surface((commandView.width, commandView.height))
    #commandSurface.fill((255, 0, 0))
    #commandSurface.fill(DARK_GREY)
    #commandSurface.fill(LIGHT_GREY)
    #pygame.display.flip()
    leftCommandView = universal.get_left_command_view()
    rightCommandView = universal.get_right_command_view()
    middleCommandView = universal.get_middle_command_view()
    dirtyRects = titleScreen.title_screen(episode)
    #screen.blit(commandSurface, commandView.topleft)
    #screen.blit(background, (0,))
    # Event loop
    #fps = 30
    #clock = pygame.time.Clock()
    while True:
        #screen.blit(commandSurface, commandView.topleft)
        #pygame.draw.rect(commandSurface, LIGHT_GREY, commandView, 5)
        #Technically, this for loop is silly now, because I'm only allowing one event in
        #queue at a time. (Search for CLEAR) 
        for event in pygame.event.get():
            if event.type == KEYUP:
                if event.key == K_LSUPER or event.key == K_RSUPER: 
                    pygame.display.iconify()
                else:
                    #CLEAR
                    #This will have to be changed if I ever implement something that requires rapid key combinations.
                    pygame.event.clear()
                    newDirtyRects = universal.get_command_interpreter()(event)
                    try:
                        dirtyRects.extend(newDirtyRects)
                    except TypeError:
                        pass
            elif event.type == QUIT:
                music.close_music_files()
                import os
                if '.init.sav' in os.listdir('save'):
                    os.remove(os.path.join('save', '.init.sav'))
                music.clean_up_music()
                return
            if universal.get_text_to_display() != '':
                if universal.get_title_text() != '':
                    position = (worldView.topleft[0], worldView.topleft[1] + titleFont.get_linesize())
                    textRect = worldView.copy()
                    textRect.height = textRect.height - titleFont.get_linesize()
                    universal.display_text(universal.get_title_text(), worldView, position, isTitle=True)
                displayPosition = (worldView.topleft[0], worldView.topleft[1] + 2 * titleFont.get_linesize())
                textRect = worldView.copy()
                dirtyRects.append(textRect)
                textRect.height = textRect.height - 2 * titleFont.get_linesize()
                universal.display_text(universal.get_text_to_display(), textRect, displayPosition, isTitle=False)
                universal.clear_text_to_display()
        #The following is a bit of command position fiddling to make everything look nice and balanced.
        universal.display_commands()
        pygame.draw.rect(screen, universal.LIGHT_GREY, pygame.Rect(commandView.topleft, commandView.size), universal.COMMAND_VIEW_LINE_WIDTH)
        #pygame.display.flip()
        #clock.tick_busy_loop(fps)
        newDirtyRects = []
        #Bonemouth was having a strange error where the game would crash when trying to save, apparently because the game only takes one list of dirty rects? Not sure, and couldn't replicate it,
        #and of course the error message doesn't actually print the value of dirty rects :-/, so I can't figure out what dirty rects look like when the bug is thrown. So I'm assuming for some
        #strange reason I'm ending up with a nested list. So I flatten it first. Note that since every atomic element is a rectangle, and those aren't iterable, we don't need to worry about 
        #accidentally flattening tuples or strings.
        for maybeList in dirtyRects:
            if isinstance(maybeList, pygame.Rect):
                newDirtyRects.append(maybeList)
            else:
                newDirtyRects.extend(maybeList)
        newDirtyRects.append(get_command_view())
        #Wine doesn't play nice with the dirty rects approach, so if we are running under Wine, then we update everything forever.
        if universal.playOnMac:
            pygame.display.flip()
        elif dirtyRects:
            pygame.display.update(newDirtyRects)
        dirtyRects = []