|
@@ -26,9 +26,6 @@ _predefined_attributes_allowed = [
|
|
|
# FUNCTIONS #
|
|
# FUNCTIONS #
|
|
|
# ------------------ #
|
|
# ------------------ #
|
|
|
|
|
|
|
|
-# TODO:
|
|
|
|
|
-# Nome do videojogo -> set_caption
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
def _load_scene(data: dict) -> 'scene.Scene':
|
|
def _load_scene(data: dict) -> 'scene.Scene':
|
|
|
"""
|
|
"""
|
|
@@ -148,6 +145,22 @@ def add_character(new_character: 'character.Character'):
|
|
|
_globals.vg_characters.append(new_character)
|
|
_globals.vg_characters.append(new_character)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def add_chronometer(new_chronometer: 'widgets.Chronometer'):
|
|
|
|
|
+ """
|
|
|
|
|
+ Add a new chronometer to the videogame.
|
|
|
|
|
+
|
|
|
|
|
+ Parameters:
|
|
|
|
|
+ new_chronometer: the chronometer to be added
|
|
|
|
|
+
|
|
|
|
|
+ Examples:
|
|
|
|
|
+ >>> chrono = widgets.Chronometer(30)
|
|
|
|
|
+ >>> add_chronometer(chrono) # doctest: +SKIP
|
|
|
|
|
+ """
|
|
|
|
|
+ if not isinstance(new_chronometer, widgets.Chronometer):
|
|
|
|
|
+ raise TypeError(_('Only Chronometer instances can be added.'))
|
|
|
|
|
+ _globals.vg_chronometers.append(new_chronometer)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def add_group(new_group: 'group.SquareGroup'):
|
|
def add_group(new_group: 'group.SquareGroup'):
|
|
|
"""
|
|
"""
|
|
|
Add a new group to the videogame.
|
|
Add a new group to the videogame.
|
|
@@ -210,7 +223,7 @@ def add_text(new_text: 'widgets.Text'):
|
|
|
"""
|
|
"""
|
|
|
if not isinstance(new_text, widgets.Text):
|
|
if not isinstance(new_text, widgets.Text):
|
|
|
raise TypeError(_('Only Text instances can be added.'))
|
|
raise TypeError(_('Only Text instances can be added.'))
|
|
|
- _globals.vg_widgets.append(new_text)
|
|
|
|
|
|
|
+ _globals.vg_texts.append(new_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
def init():
|
|
def init():
|
|
@@ -293,7 +306,7 @@ def paint(
|
|
|
| Type['widgets.Text'],
|
|
| Type['widgets.Text'],
|
|
|
):
|
|
):
|
|
|
"""
|
|
"""
|
|
|
- Paint both a scene and a character.
|
|
|
|
|
|
|
+ Paint multiple sprite types on the main window.
|
|
|
|
|
|
|
|
Parameters:
|
|
Parameters:
|
|
|
sprite: The element to be painted.
|
|
sprite: The element to be painted.
|
|
@@ -306,6 +319,12 @@ def paint(
|
|
|
|
|
|
|
|
|
|
|
|
|
def paint_group(group: Type['group.SquareGroup']):
|
|
def paint_group(group: Type['group.SquareGroup']):
|
|
|
|
|
+ """
|
|
|
|
|
+ Paint a group of sprites on the main window.
|
|
|
|
|
+
|
|
|
|
|
+ Parameters:
|
|
|
|
|
+ group: The group of sprites to be painted.
|
|
|
|
|
+ """
|
|
|
group.draw(_globals._window)
|
|
group.draw(_globals._window)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -347,6 +366,17 @@ def set_marks(
|
|
|
width: int = 1,
|
|
width: int = 1,
|
|
|
debug: bool = False,
|
|
debug: bool = False,
|
|
|
):
|
|
):
|
|
|
|
|
+ """
|
|
|
|
|
+ Set distance mark lines and position information along both axis.
|
|
|
|
|
+
|
|
|
|
|
+ Parameters:
|
|
|
|
|
+ x_gap: The gap distance on abscissa axis.
|
|
|
|
|
+ y_gap: The gap distance on ordinate axis.
|
|
|
|
|
+ x_color: The line color on abscissa axis.
|
|
|
|
|
+ y_color: The line color on ordinate axis.
|
|
|
|
|
+ width: The line width.
|
|
|
|
|
+ debug: If True, extra detailed information is shown.
|
|
|
|
|
+ """
|
|
|
_globals.marks = utils.Marks(x_gap, y_gap, x_color, y_color, width, debug)
|
|
_globals.marks = utils.Marks(x_gap, y_gap, x_color, y_color, width, debug)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -403,6 +433,10 @@ def update():
|
|
|
vg_character._update_rect_position(tracking=tracking)
|
|
vg_character._update_rect_position(tracking=tracking)
|
|
|
paint(vg_character)
|
|
paint(vg_character)
|
|
|
vg_character.update()
|
|
vg_character.update()
|
|
|
|
|
+ if _globals.vg_chronometers:
|
|
|
|
|
+ for chronometers_item in _globals.vg_chronometers:
|
|
|
|
|
+ paint(chronometers_item)
|
|
|
|
|
+ chronometers_item.update()
|
|
|
if _globals.vg_groups:
|
|
if _globals.vg_groups:
|
|
|
for group_item in _globals.vg_groups:
|
|
for group_item in _globals.vg_groups:
|
|
|
for sprite_item in group_item.sprites():
|
|
for sprite_item in group_item.sprites():
|
|
@@ -415,9 +449,9 @@ def update():
|
|
|
if _globals.vg_scoreboards:
|
|
if _globals.vg_scoreboards:
|
|
|
for scoreboard_item in _globals.vg_scoreboards:
|
|
for scoreboard_item in _globals.vg_scoreboards:
|
|
|
paint(scoreboard_item)
|
|
paint(scoreboard_item)
|
|
|
- if _globals.vg_widgets:
|
|
|
|
|
- for widgets_item in _globals.vg_widgets:
|
|
|
|
|
- paint(widgets_item)
|
|
|
|
|
|
|
+ if _globals.vg_texts:
|
|
|
|
|
+ for texts_item in _globals.vg_texts:
|
|
|
|
|
+ paint(texts_item)
|
|
|
if _globals.marks:
|
|
if _globals.marks:
|
|
|
_globals.marks.draw()
|
|
_globals.marks.draw()
|
|
|
pygame.display.flip()
|
|
pygame.display.flip()
|