Coverage for topdownengine/env_object.py: 58%
12 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-24 02:27 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-24 02:27 +0000
1# Copyright (c) 2026 Shaurya Sharma
2# SPDX-License-Identifier: MIT
4from .game_object import GameObject
5from typing import Any
6from .game import Game
7import pygame as pg
9class EnvObject(GameObject):
10 """This class represents all environment objects in the engine.
12 Attributes:
13 CAUSES_COLLISIONS (bool): Overrides GameObject. Defaults to True.
14 """
15 CAUSES_COLLISIONS = True
17 def __init__(
18 self,
19 animation_paths: dict[str,str]|None=None,
20 frame_size: tuple[int]|None=None,
21 colliders: list[pg.Rect]=None
22 ) -> None:
23 """Initialize the EnvObject.
25 Args:
26 animation_paths (dict[str,str], optional): The animation paths to load animations from. Defaults to None.
27 frame_size (tuple[int]|None, optional): The frame size to use to load/generate animations. Defaults to None.
28 colliders (list[pygame.Rect]|None, optional): The list of colliders of the EnvObject, relative to itself. If it is set to None, there will be no colliders. Defaults to None.
29 """
30 # Set animation paths dict and frame size before calling super().__init__()
31 # This make it automatically load in the animations without
32 # having to call it a second time.
33 self.animation_paths = animation_paths
34 if frame_size is not None:
35 self.frame_size = frame_size
37 super().__init__()
38 self.colliders = colliders if colliders is not None else []