Beispiel #1
0
def main():
    librpg.init()
    graphics_config.config(screen_width=480, screen_height=320)
    librpg.config.menu_config.config(theme=ClassicMenuTheme())

    get_context_stack().stack_model(BarMenu())
    get_context_stack().gameloop()
Beispiel #2
0
    def gameloop(self):
        assert not self.party.empty(), 'Party is empty'
        prev_facing = None
        self.schedule_teleport(self.party_pos[1], self.party_pos[0])

        while self.scheduled_teleport:
            # print self.state.locals

            # Create new map
            map_id, position, args = self.scheduled_teleport
            map_model = self.create_map(map_id, *args)

            # Use data that was stored
            if prev_facing is None:
                if self.party_pos is not None:
                    prev_facing = self.party_pos[2]
                else:
                    prev_facing = DOWN
            map_model.add_party(self.party, position, prev_facing)
            local_state = self.state.load_local(map_id)

            # Transfer control to map
            self.scheduled_teleport = None
            map_model.set_states(local_state, self.state)
            get_context_stack().stack_model(map_model)
            get_context_stack().gameloop()

            # Store data that we wish to carry
            local_state = map_model.save_state()
            self.state.save_local(map_id, local_state)
            prev_facing = map_model.party_avatar.facing
            map_model.remove_party()

            gc.collect()
Beispiel #3
0
def main():
    librpg.init()
    graphics_config.config(screen_width=480, screen_height=320)
    librpg.config.menu_config.config(theme=ClassicMenuTheme())

    get_context_stack().stack_model(BarMenu())
    get_context_stack().gameloop()
Beispiel #4
0
    def gameloop(self):
        assert not self.party.empty(), 'Party is empty'
        prev_facing = None
        self.schedule_teleport(self.party_pos[1], self.party_pos[0])

        while self.scheduled_teleport:
            # print self.state.locals

            # Create new map
            map_id, position, args = self.scheduled_teleport
            map_model = self.create_map(map_id, *args)

            # Use data that was stored
            if prev_facing is None:
                if self.party_pos is not None:
                    prev_facing = self.party_pos[2]
                else:
                    prev_facing = DOWN
            map_model.add_party(self.party, position, prev_facing)
            local_state = self.state.load_local(map_id)

            # Transfer control to map
            self.scheduled_teleport = None
            map_model.set_states(local_state, self.state)
            get_context_stack().stack_model(map_model)
            get_context_stack().gameloop()

            # Store data that we wish to carry
            local_state = map_model.save_state()
            self.state.save_local(map_id, local_state)
            prev_facing = map_model.party_avatar.facing
            map_model.remove_party()

            gc.collect()
Beispiel #5
0
    def __update_input(self):
        for key in game_config.key_cancel:
            if Input.was_pressed(key) is not None:
                self.do_cancel = True
                return

        for key in game_config.key_action:
            if Input.was_pressed(key) is not None:
                self.do_action = True
                return

        if self.party_avatar.scheduled_movement \
           or self.party_avatar.movement_phase \
           or self.message_queue.is_busy():
            return

        if self.do_cancel:
            self.do_cancel = False
            get_context_stack().stop()
            return

        if self.do_action:
            self.do_action = False
            self.map_model.party_action()
            return

        for key in game_config.key_up:
            if Input.motion(key):
                self.party_avatar.schedule_movement(Step(UP))
                return

        for key in game_config.key_down:
            if Input.motion(key):
                self.party_avatar.schedule_movement(Step(DOWN))
                return

        for key in game_config.key_left:
            if Input.motion(key):
                self.party_avatar.schedule_movement(Step(LEFT))
                return

        for key in game_config.key_right:
            if Input.motion(key):
                self.party_avatar.schedule_movement(Step(RIGHT))
                return

        if game_config.map_mouse_enabled:
            evt = Input.was_pressed(M_1)
            if evt is not None:
                if not self.party_avatar.scheduled_movement:
                    self.__mouse_movement(evt.pos)
                    return
Beispiel #6
0
    def __update_input(self):
        for key in game_config.key_cancel:
            if Input.was_pressed(key) is not None:
                self.do_cancel = True
                return
            
        for key in game_config.key_action:
            if Input.was_pressed(key) is not None:
                self.do_action = True
                return

        if self.party_avatar.scheduled_movement \
           or self.party_avatar.movement_phase \
           or self.message_queue.is_busy():
            return
        
        if self.do_cancel:
            self.do_cancel = False
            get_context_stack().stop()
            return
            
        if self.do_action:
            self.do_action = False
            self.map_model.party_action()
            return

        for key in game_config.key_up:
            if Input.motion(key):
                self.party_avatar.schedule_movement(Step(UP))
                return

        for key in game_config.key_down:
            if Input.motion(key):
                self.party_avatar.schedule_movement(Step(DOWN))
                return

        for key in game_config.key_left:
            if Input.motion(key):
                self.party_avatar.schedule_movement(Step(LEFT))
                return

        for key in game_config.key_right:
            if Input.motion(key):
                self.party_avatar.schedule_movement(Step(RIGHT))
                return

        if game_config.map_mouse_enabled:
            evt = Input.was_pressed(M_1)
            if evt is not None:
                if not self.party_avatar.scheduled_movement:
                    self.__mouse_movement(evt.pos)
                    return
Beispiel #7
0
    def initialize(self):
        map_model = self.map_model
        self.__map_view_draw = self.map_view.draw
        self.party_avatar = map_model.party_avatar

        # Initialize contexts
        context_stack = get_context_stack()
        context_stack.stack_context(self.message_queue)
        for context in map_model.contexts:
            context_stack.stack_context(context)
Beispiel #8
0
    def gameloop(self):
        # Create new map
        map_id, position, facing = self.party_pos
        assert map_id == MicroWorld.TEH_MAP_ID, \
               'The loaded map id is not TEH map id.'

        # Use data that was stored
        self.only_map.add_party(self.party, position, facing)
        local_state = self.state.load_local(map_id)

        # Transfer control to map
        self.only_map.set_states(local_state, self.state)
        get_context_stack().stack_model(self.only_map)
        get_context_stack().gameloop()

        # Store data that we wish to carry
        local_state = self.only_map.save_state()
        self.state.save_local(map_id, local_state)
        self.only_map.remove_party()
Beispiel #9
0
    def initialize(self):
        map_model = self.map_model
        self.__map_view_draw = self.map_view.draw
        self.party_avatar = map_model.party_avatar

        # Initialize contexts
        context_stack = get_context_stack()
        context_stack.stack_context(self.message_queue)
        for context in map_model.contexts:
            context_stack.stack_context(context)
Beispiel #10
0
    def gameloop(self):
        # Create new map
        map_id, position, facing = self.party_pos
        assert map_id == MicroWorld.TEH_MAP_ID, \
               'The loaded map id is not TEH map id.'

        # Use data that was stored
        self.only_map.add_party(self.party, position, facing)
        local_state = self.state.load_local(map_id)

        # Transfer control to map
        self.only_map.set_states(local_state, self.state)
        get_context_stack().stack_model(self.only_map)
        get_context_stack().gameloop()

        # Store data that we wish to carry
        local_state = self.only_map.save_state()
        self.state.save_local(map_id, local_state)
        self.only_map.remove_party()
Beispiel #11
0
def main():
    librpg.init()
    librpg.config.menu_config.config(theme=ClassicMenuTheme())

    get_context_stack().stack_model(TestMenu())
    get_context_stack().gameloop()
Beispiel #12
0
 def gameover(self):
     get_context_stack().stop()
Beispiel #13
0
 def open(self):
     """
     Open the menu.
     """
     get_context_stack().stack_model(self)
Beispiel #14
0
 def gameover(self):
     get_context_stack().stop()
Beispiel #15
0
 def open(self):
     """
     Open the menu.
     """
     get_context_stack().stack_model(self)
Beispiel #16
0
def main():
    librpg.init()
    librpg.config.menu_config.config(theme=ClassicMenuTheme())

    get_context_stack().stack_model(TestMenu())
    get_context_stack().gameloop()