Exemplo n.º 1
0
 def update_over(self, instance = None):
     collision = mouse_collision
     collision.set_position(self.x, self.y)
     oldOver = self.over
     if instance is not None:
         instanceCollision = instance.objectPlayer.collision
         if collide(instanceCollision, collision):
             if instance not in oldOver:
                 instance.objectPlayer.on_mouse_over()
                 oldOver.append(instance)
         elif instance in oldOver:
             oldOver.remove(instance)
             instance.objectPlayer.on_mouse_left()
         return
     self.over = over = []
     for objectInfo in self.enabledInstances:
         try:
             for instance in self.player.frame.instanceHandles[objectInfo]:
                 objectPlayer = instance.objectPlayer
                 instanceCollision = objectPlayer.collision
                 if collide(instanceCollision, collision):
                     if instance not in oldOver:
                         objectPlayer.on_mouse_over()
                     over.append(instance)
                 elif instance in oldOver:
                     objectPlayer.on_mouse_left()
         except KeyError:
             pass
 def set_above(self, instance):
     parent = self.parent
     set_position = parent.set_position
     parent_collision = parent.objectPlayer.collision
     instance_collision = instance.objectPlayer.collision
     while 1:
         if not collide(parent_collision, instance_collision):
             break
         set_position(parent.x, int(parent.y) - 1)
Exemplo n.º 3
0
 def check(self):
     x = self.evaluate_expression(self.get_parameter(0))
     y = self.evaluate_expression(self.get_parameter(1))
     collision = Point(x, y)
     for layer in self.player.frame.layers:
         for instance in layer.obstacles:
             if collide(collision, instance.objectPlayer.collision):
                 return not self.negated
     return self.negated
Exemplo n.º 4
0
 def check(self):
     x = self.evaluate_index(0)
     y = self.evaluate_index(1)
     collision = Point(x, y)
     for layer in self.player.frame.layers:
         for instance in layer.obstacles:
             if collide(collision, instance.objectPlayer.collision):
                 return not self.negated
     return self.negated
Exemplo n.º 5
0
 def check(self):
     x = self.evaluate_index(0)
     y = self.evaluate_index(1)
     collision = Point(x, y)
     for layer in self.player.frame.layers:
         for instance in layer.obstacles:
             if collide(collision, instance.objectPlayer.collision):
                 return not self.negated
     return self.negated
Exemplo n.º 6
0
 def get(self):
     x = self.next_argument()
     y = self.next_argument()
     collision = Point(x, y)
     for layer in self.player.frame.layers:
         if layer.ladder_at(x, y):
             return 2
         for instance in layer.obstacles:
             if collide(collision, instance.objectPlayer.collision):
                 return 1
     return 0
Exemplo n.º 7
0
 def get(self):
     x = self.next_argument()
     y = self.next_argument()
     collision = Point(x, y)
     for layer in self.player.frame.layers:
         if layer.ladder_at(x, y):
             return 2
         for instance in layer.obstacles:
             if collide(collision, instance.objectPlayer.collision):
                 return 1
     return 0
Exemplo n.º 8
0
 def test_collision(self, x, y, instances):
     parent = self.parent
     parent.set_position(x, y)
     objectPlayer = parent.objectPlayer
     if parent.handle in self.player.frame.borderCollisionHandles:
         if parent.is_leaving():
             return False
     for instance in instances:
         if instance is self.parent:
             continue
         if collide(instance.objectPlayer.collision, objectPlayer.collision):
             return False
     return True
Exemplo n.º 9
0
 def execute(self):
     layer = self.evaluate_expression(self.get_parameter(0)) - 1
     x = self.evaluate_expression(self.get_parameter(1))
     y = self.evaluate_expression(self.get_parameter(2))
     fineDetection = bool(self.evaluate_expression(self.get_parameter(3)))
     if fineDetection:
         collision = Point(x, y)
     for instance in self.player.frame.pastedInstances[:]:
         if instance.layerIndex != layer:
             continue
         if fineDetection:
             collided = collide(instance.objectPlayer.collision, collision)
         else:
             collided = collides(x, y, x + 1, y + 1, instance.x1,
                                 instance.y1, instance.x2, instance.y2)
         if collided:
             instance.destroy()
Exemplo n.º 10
0
 def execute(self):
     layer = self.evaluate_expression(self.get_parameter(0)) - 1
     x = self.evaluate_expression(self.get_parameter(1))
     y = self.evaluate_expression(self.get_parameter(2))
     fineDetection = bool(self.evaluate_expression(self.get_parameter(3)))
     if fineDetection:
         collision = Point(x, y)
     for instance in self.player.frame.pastedInstances[:]:
         if instance.layerIndex != layer:
             continue
         if fineDetection:
             collided = collide(instance.objectPlayer.collision, collision)
         else:
             collided = collides(x, y, x + 1, y + 1, instance.x1, 
                 instance.y1, instance.x2, instance.y2)
         if collided:
             instance.destroy()