예제 #1
0
def ontick():
    # set the saved message if needed
    if (variables.saved):
        menu.saved()
        variables.saved = False

    if variables.settings.slowtickp():
        onslowtick()

    
    if variables.settings.state == "world" or (variables.settings.state == "conversation" and variables.settings.backgroundstate == "world"):
        maps.musictick()
        
    if (not variables.settings.menuonq):
        if variables.settings.state == "world":
            classvar.player.move(maps.current_map)
            maps.checkconversation()
            maps.checkexit()
            maps.current_map.on_tick()
            
        elif variables.settings.state == "battle":
            classvar.battle.ontick()
        elif variables.settings.state == "game":
            variables.currentgame().tickfunction(variables.settings.current_time, variables.settings)
    else:
        menu.ontick()
예제 #2
0
    def resume(self):
        if self.mainmenup and self.firstbootup:
            self.state = "name"
            self.option = 0
            play_music("bearhome")
            # continue being in menu
            return

        # stop main menu music
        elif maps.current_map_name == "honeyhome" and self.mainmenup:
            play_music("bearhome")
        else:
            stop_music()


        
        self.reset()
        variables.settings.menuonq = False
        
        
        classvar.player.change_of_state()
        if variables.settings.state == "battle":
            if not isinstance(classvar.battle, str):
                classvar.battle.unpause()

            # keep the menu on if it was the main menu, so the player can see first
            if self.mainmenup:
                variables.settings.menuonq = True



        if variables.settings.state == "game":
            variables.currentgame().unpausefunction(variables.settings.current_time)
        self.mainmenup = False
예제 #3
0
    def resume(self):
        if self.mainmenup and self.firstbootup:
            self.state = "name"
            self.option = 0
            play_music("bearhome")
            # continue being in menu
            return

        # stop main menu music
        elif maps.current_map_name == "honeyhome" and self.mainmenup:
            play_music("bearhome")
        else:
            stop_music()


        
        self.reset()
        variables.settings.menuonq = False
        
        
        classvar.player.change_of_state()
        if variables.settings.state == "battle":
            if not isinstance(classvar.battle, str):
                classvar.battle.unpause()

            # keep the menu on if it was the main menu, so the player can see first
            if self.mainmenup:
                variables.settings.menuonq = True



        if variables.settings.state == "game":
            variables.currentgame().unpausefunction(variables.settings.current_time)
        self.mainmenup = False
예제 #4
0
def onkeyup(key):
    if variables.settings.menuonq:
        menu.onrelease(key)
    elif variables.settings.state == "world":
        if maps.playerenabledp() and maps.current_map.playerenabledp:
            classvar.player.keyrelease(key)
    elif variables.settings.state == "battle":
        classvar.battle.onrelease(key)
    elif variables.settings.state == "conversation" and conversations.currentconversation != None:
        conversations.currentconversation.keyrelease(key)
    elif variables.settings.state == "game":
        variables.currentgame().keyupfunction(variables.settings.current_time, variables.settings, key)
예제 #5
0
    def pause(self):
        play_effect("onedrum")
        self.pausetime = variables.settings.current_time
        
        if variables.settings.state == "battle":
            if (not isinstance(classvar.battle, str)):
                classvar.battle.pause()

        if variables.settings.state == "game":
            variables.currentgame().pausefunction(variables.settings.current_time)
        variables.settings.menuonq = not variables.settings.menuonq
        self.reset()
        classvar.player.change_of_state()
예제 #6
0
    def pause(self):
        play_effect("onedrum")
        self.pausetime = variables.settings.current_time
        
        if variables.settings.state == "battle":
            if (not isinstance(classvar.battle, str)):
                classvar.battle.pause()

        if variables.settings.state == "game":
            variables.currentgame().pausefunction(variables.settings.current_time)
        variables.settings.menuonq = not variables.settings.menuonq
        self.reset()
        classvar.player.change_of_state()
예제 #7
0
def onkeydown(key):
    # emergency dev quit
    if devoptions.devmode and key == devoptions.devquitkey:
        pygame.quit()
        sys.exit()

    # check if the player is pausing the game
    elif variables.checkkey("escape", key) and not variables.settings.menuonq:
        menu.pause()

    # menu press, also check exiting from the menu, saving from menu
    elif variables.settings.menuonq:
        if variables.checkkey("enter", key) and menu.state == "main":
            if menu.getoption() == "exit":
                global done
                done = True
            elif menu.getoption() == "save":
                save(True)
                variables.saved = True
            else:
                menu.onkey(key)
        else:
            menu.onkey(key)

    # check for dev battle key
    elif devoptions.devmode and key == devoptions.devengagebattlekey and variables.settings.state == "world":
        if devbattletest == None:
            initiatebattle(random_enemy())
        else:
            initiatebattle(devbattletest)
            
    # process key in minigame
    elif variables.settings.state == "game" and not variables.settings.menuonq:
        variables.currentgame().keydownfunction(variables.settings.current_time, variables.settings, key)

        
    elif variables.settings.state == "conversation" and conversations.currentconversation != None:
        message = conversations.currentconversation.keyevent(key)
        menu.setmessage(message)
        # check if it was exited to unhide rocks
        if variables.settings.state == "world":
            maps.unhiderock(conversations.currentconversation.unhidethisrock)
    elif variables.settings.state == "world":
        if maps.playerenabledp() and maps.current_map.playerenabledp:
            classvar.player.keypress(key)
        maps.on_key(key)
    elif variables.settings.state == "battle":
        classvar.battle.onkey(key)
예제 #8
0
def ondraw():

    
    def draw_world():
        current_map = maps.current_map
        
        #fill edges in with black
        screenxoffset = maps.current_map.screenxoffset()
        if screenxoffset != 0:
            variables.screen.fill(variables.BLACK,
                                  Rect(0, 0, screenxoffset+1, variables.height))
            variables.screen.fill(variables.BLACK,
                                  Rect(variables.width-screenxoffset-2, 0, screenxoffset+3, variables.height))
            
        classvar.player.update_drawpos(current_map)
        
        maps.current_map.draw([classvar.player.mapdrawx, classvar.player.mapdrawy])
        if maps.playerenabledp() and maps.current_map.playerenabledp:
            classvar.player.draw(current_map)
        maps.current_map.draw_foreground([classvar.player.mapdrawx, classvar.player.mapdrawy])


    drawnonmenup = True
    if variables.settings.menuonq:
        if menu.mainmenup:
            if menu.state in ["main", "settings"]:
                variables.screen.fill(variables.BLACK)
                drawnonmenup = False
                
    if drawnonmenup:
        if variables.settings.state == "conversation":
            if variables.settings.backgroundstate == "world":
                draw_world()
            else:
                variables.screen.fill(variables.BLACK)
                classvar.battle.draw()
            conversations.currentconversation.draw()
        elif variables.settings.state == "world":
            draw_world()
        elif variables.settings.state == "battle":
            variables.screen.fill(variables.BLACK)
            classvar.battle.draw()
        elif variables.settings.state == "game":
            if variables.settings.menuonq:
                variables.currentgame().drawfunction(menu.pausetime, variables.settings, variables.screen)
            else:
                variables.currentgame().drawfunction(variables.settings.current_time, variables.settings, variables.screen)

    if (variables.settings.menuonq):
        menu.draw()
    # draw message regardless
    if menu != None:
        menu.drawmessage()


    
    if devoptions.testsmallp:
        # blit red boarder for testing
        variables.screen.fill(variables.RED, Rect(variables.width, 0, 10, variables.height))
        variables.screen.fill(variables.RED, Rect(0, variables.height, variables.width, 10))


    # blit fps
    variables.screen.blit(variables.font.render(str(clock.get_fps()), 0, variables.WHITE), [10, variables.font.get_linesize()])

        
        

    # update the screen
    #if len(variables.dirtyrects) > 0 and devoptions.devmode:
    #pygame.draw.rect(variables.screen, variables.BLUE, variables.dirtyrects[0], 1)

    variables.updatescreen()

    # reset dirtyrects
    variables.olddirtyrects = variables.dirtyrects
    variables.dirtyrects = []