Exemple #1
0
    def update(self, events, world):
        context = world.find_component("context")
        settings = world.find_component("settings")
        context["paused"] = True

        exiting = False

        for event in events:
            if event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE:
                context["paused"] = False
                return SceneManager.pop()
            elif event.type == PAUSE_CONTINUE:
                context["paused"] = False
                return SceneManager.pop()
            elif event.type == PAUSE_SAVE_AND_QUIT:
                self._save(settings["save_file"], world)
                context["paused"] = False
                exiting = True
            elif event.type == PAUSE_QUIT_TO_MENU:
                context["paused"] = False
                exiting = True

        if exiting:
            world.inject_event({
                "type": "sound",
                "action": "stop",
                "sound": "background_music",
            })
            return SceneManager.new_root(scenes.title.TitleScene())

        world.process_all_systems(events)
Exemple #2
0
    def update(self, events, world):
        settings = world.find_component("settings")

        for event in events:
            if event.type == EQUIP_QUIT:
                return SceneManager.new_root(scenes.title.TitleScene())
            if event.type == EQUIP_BUY_CLOUD_SLEEVES:
                self._shop(settings["cloudSleevesCost"], "cloud_sleeves", world)
                self.teardown(world)
                self.setup(world)
            if event.type == EQUIP_BUY_WINGS:
                self._shop(settings["wingsCost"], "wings", world)
                self.teardown(world)
                self.setup(world)
            if event.type == EQUIP_BUY_JET_BOOTS:
                self._shop(settings["jetBootsCost"], "jet_boots", world)
                self.teardown(world)
                self.setup(world)
            if event.type == EQUIP_SAVE_AND_START:
                self._save(settings["save_file"], world)
                self.teardown(world)
                post(Event(LOAD))
                return SceneManager.pop()

        world.process_all_systems(events)
Exemple #3
0
    def update(self, events, world):
        for event in events:
            if event.type == NEW_GAME:
                return SceneManager.new_root(GameScene())
            if event.type == CONTINUE:
                # we have no data to save right now, so just start a fresh game if we have a save file
                settings = world.find_component("settings")
                if path.exists(
                        path.join(user_data_dir(APP_NAME, APP_AUTHOR),
                                  settings["save_file"])):
                    with open(
                            path.join(user_data_dir(APP_NAME, APP_AUTHOR),
                                      settings["save_file"]),
                            "r",
                    ) as f:
                        loaded_json = json.load(f)
                        player_entity = world.find_entity("player")
                        player_entity.player.currency = loaded_json["currency"]
                        player_entity.player.hasCloudSleeves = loaded_json[
                            "hasCloudSleeves"]
                        player_entity.player.hasWings = loaded_json["hasWings"]
                        player_entity.player.hasJetBoots = loaded_json[
                            "hasJetBoots"]
                self.teardown(world)
                return SceneManager.push(EquipScene())
            if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                return SceneManager.pop()

        world.process_all_systems(events)
Exemple #4
0
    def update(self, events, world):
        for event in events:
            if event.type == BACK:
                return SceneManager.pop()
            if event.type == pygame.MOUSEBUTTONDOWN:
                if event.button == 4 and self.scroll_offset < 0:
                    self.scroll_offset += 5
                if event.button == 5 and self.scroll_offset > -180:
                    self.scroll_offset -= 5

        world.process_all_systems(events)
Exemple #5
0
    def update(self, events, world):
        settings = world.find_component("settings")

        for event in events:
            if event.type == EQUIP_QUIT:
                world.inject_event({
                    "type": "sound",
                    "action": "stop",
                    "sound": "shop_music",
                })
                return SceneManager.new_root(scenes.title.TitleScene())
            if event.type == EQUIP_BUY_CLOUD_SLEEVES:
                self._shop(settings["cloudSleevesCost"], "cloud_sleeves",
                           world)
                self.teardown(world)
                self.setup(world)
            if event.type == EQUIP_BUY_WINGS:
                self._shop(settings["wingsCost"], "wings", world)
                self.teardown(world)
                self.setup(world)
            if event.type == EQUIP_BUY_JET_BOOTS:
                self._shop(settings["jetBootsCost"], "jet_boots", world)
                self.teardown(world)
                self.setup(world)
            if event.type == EQUIP_BUY_MORE_FUEL:
                self._shop(self.extra_fuel_cost, "extra_fuel", world)
                self.teardown(world)
                self.setup(world)
            if event.type == EQUIP_SAVE_AND_START:
                world.inject_event({
                    "type": "sound",
                    "action": "stop",
                    "sound": "shop_music",
                })
                self._save(settings["save_file"], world)
                self.teardown(world)
                post(Event(LOAD))
                return SceneManager.pop()

        world.process_all_systems(events)

        # start music
        world.inject_event({
            "type": "sound",
            "action": "start",
            "sound": "shop_music",
        })
Exemple #6
0
    def update(self, events, world):
        for event in events:
            if event.type == SCENE_REFOCUS:
                self._transition_back_to(events, world)
            if event.type == NEW_GAME:
                self.teardown(world)
                return SceneManager.new_root(GameScene())
            if event.type == CONTINUE:
                self.teardown(world)
                post(Event(LOAD))
                return SceneManager.new_root(GameScene())
            if event.type == CONTROLS:
                self._transition_away_from(events, world)
                return SceneManager.push(ControlsScene())
            if event.type == CREDITS:
                self._transition_away_from(events, world)
                return SceneManager.push(CreditsScene())
            if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                return SceneManager.pop()

        world.process_all_systems(events)
Exemple #7
0
    def update(self, events, world):
        for event in events:
            if event.type == BACK:
                return SceneManager.pop()

        world.process_all_systems(events)