def __init__(self, fight_script: 'FightScript'): super().__init__(fight_script) self.board_texture = load_texture(Path('.') / 'assets' / 'fight' / 'bullet_board.png') self.heart_texture = load_texture(Path('.') / 'assets' / 'fight' / 'heart.png') self.hit_heart_texture = load_texture(Path('.') / 'assets' / 'fight' / 'hit_heart.png') self.row = 4 self.col = 4 self.movement_state = MovementState( coords = self.get_coords_at(self.row, self.col), movement_length = 0.15, mapping = Mappings.ease_out, ) self.sprites: WalList[BaseSprite] = WalList([]) self.unrestricted_sprites: WalList[BaseSprite] = WalList([]) self._last_time_player_hit: Optional[float] = None self._timeout_event: Any = None
async def choose(self): self.choices = self.get_choices() if len(self.choices) == 0: return None self.index = 0 self._scroll_offset = 0 self.font = load_font(Path('.') / 'assets' / 'fonts' / 'default') self.pointer_texture = load_texture(Path('.') / 'assets' / 'fight' / 'pointer.png', scale=2) self.start_displaying() try: while True: _, pygame_event = await wait_for_event('key:any') key = pygame_event.key if key == pg.K_UP: self.on_key_up() if key == pg.K_DOWN: self.on_key_down() if key in (pg.K_z, pg.K_RETURN): break if key in (pg.K_x, pg.K_RSHIFT): return None choice = self.choices[self.index] finally: self.stop_displaying() await next_frame() return choice
async def main(root, **kwargs): overworld = get_game().overworld overworld.freeze() await display_text(load_text('overworld/lyceum_2_left/grumpylook')) room = overworld.room grumpylook_object = room.named_objects['grumpylook'] pos = grumpylook_object.pos grumpylook_object.kill() del grumpylook_object player = room.player texture = AnimatedTexture( [load_texture(root / 'grumpylook' / 'overworld.png')], fps=1) grumpylook = TexturedWalkingSprite( pos=pos, left=texture, right=texture, front=texture, back=texture, speed=player.speed, ) room.spawn(grumpylook) await gather(grumpylook.walk_x(-240), player.walk_x(-240)) get_state()['grumpylook_met_at_floor2'] = True overworld.load_room('lyceum_5_left') overworld.unfreeze()
async def main(*args, root, **kwargs): game = get_game() room = game.overworld.room game.overworld.freeze() room.named_objects['grumpylook'].kill() texture = AnimatedTexture( [load_texture(root / 'grumpylook' / 'overworld.png')], fps=1) grumpy = TexturedWalkingSprite( pos=Vector(840, 360), left=texture, right=texture, front=texture, back=texture, speed=200.0, ) room.spawn(grumpy) await display_text(load_text('overworld/lyceum_hall/grumpylook/wait/1')) await grumpy.walk_x(-620) await display_text(load_text('overworld/lyceum_hall/grumpylook/wait/2')) await grumpy.walk_x(-240) grumpy.kill() get_state()['grumpylook_met'] = True game.overworld.unfreeze()
async def main(*, root, **kwargs): overworld = get_game().overworld room = overworld.room overworld.freeze() await sleep(0.8) old_flate = room.named_objects['flate'] old_flate.texture = load_texture(root / 'flate' / 'overworld_neutral.png', scale=2) await sleep(0.8) route = determine_route() if route not in ['cheater', 'pacifist', 'neutral', 'genocide']: raise NotImplementedError(f'Unknown route: {repr(route)}') text_name = f'overworld/lyceum_3_mid/flate/{route}' await display_text(load_text(text_name)) flate_texture = AnimatedTexture([old_flate.texture], fps=1) flate = TexturedWalkingSprite( pos=old_flate.pos, left=flate_texture, right=flate_texture, front=flate_texture, back=flate_texture, speed=240, ) room.spawn(flate) old_flate.kill() await flate.walk_x(-500) get_state()['lyceum_3_flate_met'] = True overworld.unfreeze()
async def process_enemy_attack(self): await super().process_enemy_attack() self._num_attacks += 1 if self._num_attacks == 3: flate_texture = AnimatedTexture( [ load_texture(Path('.') / 'assets' / 'textures' / 'flate' / 'fight.png', scale=4), ], fps=1, ) flate = TexturedWalkingSprite( pos=Vector(-100, 100), left=flate_texture, right=flate_texture, front=flate_texture, back=flate_texture, speed=200.0, ) self.spawn(flate) await flate.walk_x(300.0) await display_text( load_text('fight/lyceum/literallia/flate_intervention')) await flate.walk_x(-300.0) flate.kill() give(get_inventory(), 'nonsense')
async def main(root, **kwargs): overworld = get_game().overworld overworld.freeze() await display_text(load_text('overworld/lyceum_5_left/grumpylook')) room = overworld.room grumpylook_object = room.named_objects['grumpylook'] pos = grumpylook_object.pos grumpylook_object.kill() del grumpylook_object texture = AnimatedTexture( [load_texture(root / 'grumpylook' / 'overworld.png')], fps=1) grumpylook = TexturedWalkingSprite( pos=pos, left=texture, right=texture, front=texture, back=texture, speed=280, ) room.spawn(grumpylook) await grumpylook.walk_x(700) grumpylook.kill() get_state()['grumpylook_gone'] = True overworld.unfreeze()
def __init__(self, game: 'Game'): super().__init__(game) self.menu = MainMenuUi(self) self.element = None self.logo = load_texture(Path('.') / 'assets' / 'textures' / 'logo.png', scale=12) script = SimpleScript(self.run) script()
def __init__(self, game: 'Game'): super().__init__(game) if get_state()['genocide_route_possible']: logo_filename = 'logo_red.png' else: logo_filename = 'logo.png' self.logo = load_texture(Path('.') / 'assets' / 'textures' / logo_filename, scale=12) self._elapsed_time = 0.0
async def run(self, **kwargs): del kwargs heart_texture = load_texture(Path('.') / 'assets' / 'fight' / 'heart.png', scale=1) sprite = TexturedSprite(pos=self.heart_pos, texture=heart_texture) self.spawn(sprite) await sleep(2) sprite.kill() await DisappearAnimation(pos=self.heart_pos, texture=heart_texture).animate() self._elapsed_time = 0.0 await sleep(0.5) self._draw = self.draw_death_text
def load_animated_texture(path: Union[Path, str], scale: int = 1) -> AnimatedTexture: if isinstance(path, str): path = Path(path) config_path = path / 'animation.yml' with open(config_path) as f: config = yaml.safe_load(f) frames: List[BaseTexture] = [] for frame_filename in config['frames']: frames.append(load_texture(path / frame_filename, scale)) fps = config['fps'] return AnimatedTexture(frames, fps)
async def main(*, root, **kwargs): overworld = get_game().overworld if get_state()['lyceum_elevator_used']: overworld.freeze() await display_text(load_text('overworld/lyceum_5_right/elevator_1')) overworld.unfreeze() return overworld.freeze() elevator_open_texture = load_texture(root / 'elevator_open.png') elevator_open_sprite = TexturedSprite(pos=Vector(619, 126), texture=elevator_open_texture) overworld.room.spawn(elevator_open_sprite) await sleep(1) await display_text(load_text('overworld/lyceum_5_right/elevator_enter')) get_state()['lyceum_elevator_used'] = True overworld.load_room('lyceum_1_right') overworld.unfreeze()
def _load_texture(root, spec): filename, _, scale_str = spec.partition('//') if _ != '': scale = int(scale_str) return load_texture(root / filename, scale) return load_texture(root / filename)
async def spawn_water(root): water = TexturedSprite(pos=Vector(769, 262), texture=load_texture(root / 'water.png')) get_game().overworld.room.spawn(water)
def _load_texture(root: Path, spec: str) -> BaseTexture: filename, _, scale_str = spec.partition('//') if _ != '': scale = int(scale_str) return load_texture(root / filename, scale) return load_texture(root / filename)