Selaa lähdekoodia

set_collidable() added to character.

Zero! Studio 1 vuosi sitten
vanhempi
sitoutus
233e6d21d4
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 13 0
      jogai/character.py

+ 13 - 0
jogai/character.py

@@ -41,6 +41,7 @@ class Character(pygame.sprite.Sprite):
     ]
 
     _predefined_attributes_allowed = [
+        _('collidable'),
         _('height'),
         _('keys'),
         _('position'),
@@ -427,6 +428,18 @@ class Character(pygame.sprite.Sprite):
             self._original_image, self.angle, self.scale_factor
         )
 
+    def set_collidable(self, collidable: bool = True):
+        """
+        Set the character collidable.
+
+        Parameters:
+            collidable: True if it is collidable, False otherwise.
+        """
+        if not isinstance(collidable, bool):
+            raise TypeError(_('The collidable argument must be a boolean.'))
+
+        self.collidable = collidable
+
     def set_height(self, height: int):
         """
         Set the character height.