Esempio n. 1
0
    def remove(self, obj):
        """
        Remove an object from the room.

        Arguments:

        - ``obj`` -- The :class:`sge.Object` object to remove.

        .. warning::

           This method modifies the contents of :attr:`objects`.  Do not
           call this method during a loop through :attr:`objects`; doing
           so may cause problems with the loop. To get around this, you
           can create a shallow copy of :attr:`objects` to iterate
           through instead, e.g.::

               for obj in self.objects[:]:
                   self.remove(obj)
        """
        while obj in self.objects:
            self.objects.remove(obj)

        while obj in self.rd["new_objects"]:
            self.rd["new_objects"].remove(obj)

        if self is sge.game.current_room:
            o_update_object_areas(obj)
            o_update_collision_lists(obj)
            r._active_objects.discard(obj)
            obj.event_destroy()
Esempio n. 2
0
    def add(self, obj):
        """
        Add an object to the room.

        Arguments:

        - ``obj`` -- The :class:`sge.Object` object to add.

        .. warning::

           This method modifies the contents of :attr:`objects`.  Do not
           call this method during a loop through :attr:`objects`; doing
           so may cause problems with the loop. To get around this, you
           can create a shallow copy of :attr:`objects` to iterate
           through instead, e.g.::

               for obj in self.objects[:]:
                   self.add(obj.friend)

        """
        obj.alive = True
        if obj not in self.objects:
            self.objects.append(obj)

            if self is sge.game.current_room and self.rd["started"]:
                obj.event_create()
                obj.rd["object_areas"] = set()
                o_update_object_areas(obj)
                o_update_collision_lists(obj)
                if obj.active:
                    r._active_objects.add(obj)
            else:
                self.rd["new_objects"].append(obj)
Esempio n. 3
0
 def bbox_height(self, value):
     if self.__bbox_height != value:
         if value is not None:
             self.__bbox_height = value
         else:
             if self.sprite is not None:
                 self.__bbox_height = self.sprite.bbox_height
             else:
                 self.__bbox_height = 1
         o_update_object_areas(self)
Esempio n. 4
0
 def bbox_y(self, value):
     if self.__bbox_y != value:
         if value is not None:
             self.__bbox_y = value
         else:
             if self.sprite is not None:
                 self.__bbox_y = self.sprite.bbox_y
             else:
                 self.__bbox_y = 0
         o_update_object_areas(self)
Esempio n. 5
0
 def bbox_width(self, value):
     if self.__bbox_width != value:
         if value is not None:
             self.__bbox_width = value
         else:
             if self.sprite is not None:
                 self.__bbox_width = self.sprite.bbox_width
             else:
                 self.__bbox_width = 1
         o_update_object_areas(self)
Esempio n. 6
0
 def bbox_x(self, value):
     if self.__bbox_x != value:
         if value is not None:
             self.__bbox_x = value
         else:
             if self.sprite is not None:
                 self.__bbox_x = self.sprite.bbox_x
             else:
                 self.__bbox_x = 0
         o_update_object_areas(self)
Esempio n. 7
0
 def sprite(self, value):
     if self.rd["sprite"] != value:
         self.rd["sprite"] = value
         if value is not None:
             self.image_index = self.image_index % value.frames
         o_update_object_areas(self)
Esempio n. 8
0
 def y(self, value):
     if self.__y != value:
         self.__y = value
         o_update_object_areas(self)
Esempio n. 9
0
 def x(self, value):
     if self.__x != value:
         self.__x = value
         o_update_object_areas(self)
Esempio n. 10
0
 def event_step(self, time_passed, delta_mult):
     o_update_object_areas(self)
     o_update_collision_lists(self)