|
|
@@ -17,6 +17,10 @@ from jogai.utils import _get_events, _get_keys
|
|
|
# --------------- #
|
|
|
|
|
|
running = True
|
|
|
+_predefined_attributes_allowed = [
|
|
|
+ _('caption'),
|
|
|
+ _('gravity'),
|
|
|
+]
|
|
|
|
|
|
# ------------------ #
|
|
|
# FUNCTIONS #
|
|
|
@@ -49,14 +53,15 @@ def _load_attributes(data: dict):
|
|
|
Parameters:
|
|
|
data: input schema
|
|
|
"""
|
|
|
- if _('attributes') in data:
|
|
|
- attributes = data[_('attributes')]
|
|
|
- if not isinstance(attributes, dict):
|
|
|
- raise TypeError(
|
|
|
- _('The attributes in the input schema must be a dict.')
|
|
|
- )
|
|
|
- if _('gravity') in attributes:
|
|
|
- set_gravity(attributes[_('gravity')])
|
|
|
+
|
|
|
+ if not isinstance(data, dict):
|
|
|
+ raise TypeError(
|
|
|
+ _('The attributes in the input schema must be a dict.')
|
|
|
+ )
|
|
|
+ for attribute in data:
|
|
|
+ # utils._convert_function_arguments_to_string()
|
|
|
+ if attribute in _predefined_attributes_allowed:
|
|
|
+ eval(f'set_{attribute}(data["{attribute}"])')
|
|
|
|
|
|
|
|
|
def _load_characters(data: dict) -> list:
|
|
|
@@ -252,6 +257,21 @@ def paint_group(group: Type['group.SquareGroup']):
|
|
|
group.draw(_globals._window)
|
|
|
|
|
|
|
|
|
+def set_caption(caption: str):
|
|
|
+ """
|
|
|
+ Set the caption for the videogame.
|
|
|
+
|
|
|
+ Parameters:
|
|
|
+ caption: Caption to be setted
|
|
|
+
|
|
|
+ Examples:
|
|
|
+ >>> set_caption('My videogame')
|
|
|
+ """
|
|
|
+ if not isinstance(caption, str):
|
|
|
+ raise TypeError(_('The caption for the videogame must be a string.'))
|
|
|
+ pygame.display.set_caption(caption)
|
|
|
+
|
|
|
+
|
|
|
def set_gravity(gravity: int):
|
|
|
"""
|
|
|
Set the gravity in the videogame.
|