def show_game_over(self): self.game_over_background.visible = True self.game_over_background.transition = NodeTransition( Node.color, Color(0, 0, 0, 0.8), duration=30000, ) self.game_over_text.transition = NodeTransition( Node.color, Color(1, 1, 1, 1), duration=3000, )
def flash(self): self.camera_shake_ticks = 15 self.flasher.transition = [ NodeTransition( Node.color, Color(1., 0., 0., 0.3), duration=200., ), NodeTransition( Node.color, Color(0., 0., 0., 0.0), duration=100., ) ]
def update_count(self, new_count: int): if new_count < self.current_count: for powerup in self.single_powerups[new_count:self.current_count]: powerup.transition = NodeTransitionsParallel([ NodeTransition(Node.scale, Vector(0., 0.), duration=400), NodeTransition(Node.color, Color(1., 1., 1., 0.), duration=400), ]) elif new_count > self.current_count: for powerup in self.single_powerups[self.current_count:new_count]: powerup.transition = NodeTransitionsParallel([ NodeTransition(Node.scale, Vector(1., 1.), duration=400), NodeTransition(Node.color, Color(1., 1., 1., 1.), duration=400), ]) self.current_count = new_count
def handle_destruction(self): if self._is_destroying: return self._is_destroying = True self.hitbox.delete() self.transitions_manager.set( 'destruction', NodeTransitionsSequence([ NodeTransition(Node.scale, Vector(0.01, 0.01), duration=400.), NodeTransitionCallback(lambda n: n.delete()), ]), )
def _process_movement(self): if (self.movement_direction and not self.is_moving and 0 <= self.current_lane + self.movement_direction < len(LANE_HERO_SLOTS) and not self.is_frozen): self.is_moving = True self.current_lane += self.movement_direction self.soap.transitions_manager.set( 'movement', NodeTransitionsSequence([ NodeTransition(Node.position, LANE_HERO_SLOTS[self.current_lane], duration=150.), NodeTransitionCallback(self._on_end_movement), ]), )
def __init__(self): self.camera.position = Vector(0., 0.) self.python_img = Sprite(PYTHON_IMAGE_PATH) self.obj = self.root.add_child(Node( position=Vector(-50, 0), shape=Circle(10.), color=random_color(), )) self.obj.transitions_manager.set( 'movement', NodeTransition( Node.position, Vector(100, 30), 3., advance_method=AttributeTransitionMethod.add, loops=0, back_and_forth=True, ) )
def handle_pickup_grab(self, pickup_node): if isinstance(pickup_node, OilRunner): if not self.is_frozen: self.is_frozen = True self.soap.transitions_manager.set( 'frozen', NodeTransitionsSequence([ NodeTransition(Node.color, Color(0.5, 0.5, 0.5), duration=400., back_and_forth=True), NodeTransitionCallback(self._on_end_frozen), ])) elif isinstance(pickup_node, MiniSoapRunner): self.player_state.soap_meter_counter.increase(10000) elif isinstance(pickup_node, LiquidSoapRunner): self.player_state.liquid_soap_powerup_counter.increase(1) elif isinstance(pickup_node, AntivirusRunner): self.player_state.antivirus_powerup_counter.increase(1)
def __init__(self, *, repeat_sprite, scroll_duration, z_index, **kwargs): self.vertical_move = repeat_sprite.dimensions.y super().__init__( transition=NodeTransition(Node.position, Vector(0., self.vertical_move), loops=0, duration=scroll_duration), **kwargs, ) self.repeat_1 = self.add_child( Node( sprite=repeat_sprite, z_index=z_index, )) self.repeat_2 = self.add_child( Node( sprite=repeat_sprite, position=Vector(0., -self.vertical_move), z_index=z_index, ))
def _randomize_color_transition(self): return NodeTransition( Node.color, random_color(), 2., loops=0, back_and_forth=True, )
def kill(self): self.soap.transition = NodeTransitionsParallel([ NodeTransition(Node.scale, Vector.xy(0.0), duration=1500), NodeTransition(Node.color, Color(1., 0., 0., 0.), duration=1500), ]) self.soap.lifetime = 1500
def fade(self): self.transitions_manager.set( 'fade', NodeTransition(Node.color, Color(0.5, 0.5, 0.5, 1.), duration=1500), )