Example #1
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)
Example #2
0
def display_crawl():
    if skip:
        universal.say_replace('')
    worldView = universal.get_world_view()
    textRect = universal.get_world_view().copy()
    titleFont = pygame.font.SysFont(universal.FONT_LIST_TITLE, universal.TITLE_SIZE)
    displayPosition = (worldView.topleft[0], worldView.topleft[1] + 2 * titleFont.get_linesize())
    universal.display_text(universal.get_text_to_display(), textRect, displayPosition, isTitle=False)
    pygame.display.flip()
Example #3
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 = []