コード例 #1
0
ファイル: player.py プロジェクト: forcegk/CIIE2021-2D-EC1
    def __init__(self, level, data, coord, speedx=25, speedy=40, invert=False, invincible=False):
        Character.__init__(self, level, data, coord, invert, speedx, speedy)

        self._repo = ResourceManager.get_player_repository()
        self._text = ResourceManager.get_text_repository()

        self._last_hit = Player.INVULNERABILITY_LAPSE
        self._parry = Player.PARRY_CD

        self._invincible = invincible
        self._end_parry = True

        self._pending_trigger = None
        self._last_triggered = Player.TRIGGER_HYST
        self._interact_last_displayed = AnimatedText.get_duration()
        self._interact = False
コード例 #2
0
    def __init__(self):
        AbstractScene.__init__(self)
        self._scroll_x = 0
        self._hud = Hud()
        self._hud.create_hud_group(PlayerRepository.ATTR_HEALTH, HudHeart,
                                   (0, 0), Hud.GROW_RIGHT, 100)
        self._hud.create_hud_group(PlayerRepository.ATTR_MASKS, HudMask,
                                   (0, 6), Hud.GROW_RIGHT, 110)
        self._hud.create_hud_group(PlayerRepository.ATTR_TOILET_PAPER,
                                   HudToiletPaper, (80, 0), Hud.GROW_LEFT, 100)

        self._text_repo = ResourceManager.get_text_repository()
        self._player_repo = ResourceManager.get_player_repository()

        self._background = None
        self._sky = None

        self._last_scroll = self._scroll_x
コード例 #3
0
    def play_game(self):
        # stop music
        pygame.mixer.music.stop()

        # init repo
        repo = ResourceManager.get_player_repository()
        repo.reset_attr()
        repo.set_parameter(PlayerRepository.ATTR_TOTAL_TIME,
                           None,
                           accounted=False)

        level0 = Level("Level0", self._hacks)
        level1 = Level("Level1", self._hacks)
        level2 = Level("Level2", self._hacks)

        for level in [level2, level1, level0]:
            for scene in level.get_scenes():
                self._director.push_scene(scene)
コード例 #4
0
    def __init__(self, menu):
        AbstractScreen.__init__(self, menu, "backgrounds/main_menu.jpg")
        self._gui_elements.append(ExitButton(self, (self._x_total_half, 480)))

        repo = ResourceManager.get_player_repository()
        score = int(repo.get_parameter(PlayerRepository.ATTR_TOTAL_TIME))
        ResourceManager.append_hs(score)

        white = (255, 255, 255)
        font_64 = ResourceManager.load_font_asset("8bit.ttf", 64)
        font_32 = ResourceManager.load_font_asset("8bit.ttf", 32)

        title = TextGUI(self, font_64, white, "Has ganado",
                        (self._x_total_half, 120))
        score = TextGUI(self, font_64, white, f"Score: {score} sec",
                        (self._x_total_half, 300))
        exit = TextGUI(self, font_32, white, "Salir",
                       (self._x_total_half, 480))

        self._gui_elements.append(title)
        self._gui_elements.append(score)
        self._gui_elements.append(exit)
コード例 #5
0
ファイル: hud.py プロジェクト: forcegk/CIIE2021-2D-EC1
 def update(self):
     pl_repo = ResourceManager.get_player_repository()
     for param_name in pl_repo.updated:
         pl_repo.updated.remove(param_name)
         self._sprite_groups[param_name]["count"] = pl_repo.get_parameter(param_name)