Exemplo n.º 1
0
 def _handle_player_collide_block(self, player: Player, block: Block, data,
                                  arbiter: pymunk.Arbiter) -> bool :
     ''' handle when the player hit some blocks, when they are colliding, the on_hit function will run'''
     if block.get_id() == "switch":
         block.on_hit(arbiter, (self._world, player))
         return False
     if block.get_id() == "flag":
         if get_collision_direction(player, block) == "L" or get_collision_direction(player, block) == "R":
             self.reset_world(new_level=block.get_filename())
         if get_collision_direction(player, block) == "A" :
             block.on_hit(arbiter, (self._world, player))
     if block.get_id() == "tunnel":
         if get_collision_direction(player, block) == "A":
             #
             self._master.bind("s", lambda a : self._tunnel(block))
             self._master.bind("<Down>", lambda a : self._tunnel(block))
     else:
         block.on_hit(arbiter, (self._world, player))
     return True
Exemplo n.º 2
0
 def _tunnel(self, block: Block):
     '''when the player stand on a tunnel and press the <down> or s, this function will bring him to a new level'''
     self.reset_world(new_level=block.get_filename())