Generated on 2025-11-29 10:12:05
This documentation was dynamically generated from the compiled module.
createScene(name: str) -> NoneCreate a new empty scene. Note:
Returns: None
Raises: ValueError: If a scene with this name already exists The scene is created but not made active. Use setScene() to switch to it.
createSoundBuffer(filename: str) -> intLoad a sound effect from a file and return its buffer ID.
Returns: int: Buffer ID for use with playSound()
Raises: RuntimeError: If the file cannot be loaded
currentScene() -> strGet the name of the currently active scene.
Returns: str: Name of the current scene
delTimer(name: str) -> NoneStop and remove a timer. Note:
Returns: None No error is raised if the timer doesn't exist.
end_benchmark() -> strStop benchmark capture and write data to JSON file. Note:
Returns: str: The filename of the written benchmark data
Raises: RuntimeError: If no benchmark is currently running Returns the auto-generated filename (e.g., 'benchmark_12345_20250528_143022.json')
exit() -> NoneCleanly shut down the game engine and exit the application. Note:
Returns: None This immediately closes the window and terminates the program.
find(name: str, scene: str = None) -> UIDrawable | NoneFind the first UI element with the specified name. Note:
Returns: Frame, Caption, Sprite, Grid, or Entity if found; None otherwise Searches scene UI elements and entities within grids.
findAll(pattern: str, scene: str = None) -> listFind all UI elements matching a name pattern. Note:
Returns: list: All matching UI elements and entities
getMetrics() -> dictGet current performance metrics.
Returns: dict: Performance data with keys: frame_time (last frame duration in seconds), avg_frame_time (average frame time), fps (frames per second), draw_calls (number of draw calls), ui_elements (total UI element count), visible_elements (visible element count), current_frame (frame counter), runtime (total runtime in seconds)
getMusicVolume() -> intGet the current music volume level.
Returns: int: Current volume (0-100)
getSoundVolume() -> intGet the current sound effects volume level.
Returns: int: Current volume (0-100)
keypressScene(handler: callable) -> NoneSet the keyboard event handler for the current scene. Note:
Returns: None
loadMusic(filename: str) -> NoneLoad and immediately play background music from a file. Note:
Returns: None Only one music track can play at a time. Loading new music stops the current track.
log_benchmark(message: str) -> NoneAdd a log message to the current benchmark frame. Note:
Returns: None
Raises: RuntimeError: If no benchmark is currently running Messages appear in the 'logs' array of each frame in the output JSON.
playSound(buffer_id: int) -> NonePlay a sound effect using a previously loaded buffer.
Returns: None
Raises: RuntimeError: If the buffer ID is invalid
sceneUI(scene: str = None) -> listGet all UI elements for a scene.
Returns: list: All UI elements (Frame, Caption, Sprite, Grid) in the scene
Raises: KeyError: If the specified scene doesn't exist
setDevConsole(enabled: bool) -> NoneEnable or disable the developer console overlay. Note:
Returns: None When disabled, the grave/tilde key will not open the console. Use this to ship games without debug features.
setMusicVolume(volume: int) -> NoneSet the global music volume.
Returns: None
setScale(multiplier: float) -> NoneScale the game window size. Note:
Returns: None The internal resolution remains 1024x768, but the window is scaled. This is deprecated - use Window.resolution instead.
setScene(scene: str, transition: str = None, duration: float = 0.0) -> NoneSwitch to a different scene with optional transition effect.
Returns: None
Raises: KeyError: If the scene doesn't exist ValueError: If the transition type is invalid
setSoundVolume(volume: int) -> NoneSet the global sound effects volume.
Returns: None
setTimer(name: str, handler: callable, interval: int) -> NoneCreate or update a recurring timer. Note:
Returns: None If a timer with this name exists, it will be replaced. The handler receives the total runtime in seconds as its argument.
start_benchmark() -> NoneStart capturing benchmark data to a file. Note:
Returns: None
Raises: RuntimeError: If a benchmark is already running Benchmark filename is auto-generated from PID and timestamp. Use end_benchmark() to stop and get filename.
Animation object for animating UI properties
complete() -> NoneComplete the animation immediately by jumping to the final value. Note:
Returns: None Sets elapsed = duration and applies target value immediately. Completion callback will be called if set.
get_current_value() -> AnyGet the current interpolated value of the animation. Note:
Returns: Any: Current value (type depends on property: float, int, Color tuple, Vector tuple, or str) Return type matches the target property type. For sprite_index returns int, for pos returns (x, y), for fill_color returns (r, g, b, a).
hasValidTarget() -> boolCheck if the animation still has a valid target. Note:
Returns: bool: True if the target still exists, False if it was destroyed Animations automatically clean up when targets are destroyed. Use this to check if manual cleanup is needed.
start(target: UIDrawable) -> NoneStart the animation on a target UI element. Note:
Returns: None The animation will automatically stop if the target is destroyed. Call AnimationManager.update(delta_time) each frame to progress animations.
update(delta_time: float) -> boolUpdate the animation by the given time delta. Note:
Returns: bool: True if animation is still running, False if complete Typically called by AnimationManager automatically. Manual calls only needed for custom animation control.
Inherits from: Drawable
Arc(center=None, radius=0, start_angle=0, end_angle=90, color=None, thickness=1, **kwargs) An arc UI element for drawing curved line segments. Args: center (tuple, optional): Center position as (x, y). Default: (0, 0) radius (float, optional): Arc radius in pixels. Default: 0 start_angle (float, optional): Starting angle in degrees. Default: 0 end_angle (float, optional): Ending angle in degrees. Default: 90 color (Color, optional): Arc color. Default: White thickness (float, optional): Line thickness. Default: 1.0 Keyword Args: click (callable): Click handler. Default: None visible (bool): Visibility state. Default: True opacity (float): Opacity (0.0-1.0). Default: 1.0 z_index (int): Rendering order. Default: 0 name (str): Element name for finding. Default: None Attributes: center (Vector): Center position radius (float): Arc radius start_angle (float): Starting angle in degrees end_angle (float): Ending angle in degrees color (Color): Arc color thickness (float): Line thickness visible (bool): Visibility state opacity (float): Opacity value z_index (int): Rendering order name (str): Element name
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
Inherits from: Drawable
Caption(pos=None, font=None, text='', **kwargs) A text display UI element with customizable font and styling. Args: pos (tuple, optional): Position as (x, y) tuple. Default: (0, 0) font (Font, optional): Font object for text rendering. Default: engine default font text (str, optional): The text content to display. Default: '' Keyword Args: fill_color (Color): Text fill color. Default: (255, 255, 255, 255) outline_color (Color): Text outline color. Default: (0, 0, 0, 255) outline (float): Text outline thickness. Default: 0 font_size (float): Font size in points. Default: 16 click (callable): Click event handler. Default: None visible (bool): Visibility state. Default: True opacity (float): Opacity (0.0-1.0). Default: 1.0 z_index (int): Rendering order. Default: 0 name (str): Element name for finding. Default: None x (float): X position override. Default: 0 y (float): Y position override. Default: 0 Attributes: text (str): The displayed text content x, y (float): Position in pixels pos (Vector): Position as a Vector object font (Font): Font used for rendering font_size (float): Font size in points fill_color, outline_color (Color): Text appearance outline (float): Outline thickness click (callable): Click event handler visible (bool): Visibility state opacity (float): Opacity value z_index (int): Rendering order name (str): Element name w, h (float): Read-only computed size based on text and font
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
Inherits from: Drawable
Circle(radius=0, center=None, fill_color=None, outline_color=None, outline=0, **kwargs) A circle UI element for drawing filled or outlined circles. Args: radius (float, optional): Circle radius in pixels. Default: 0 center (tuple, optional): Center position as (x, y). Default: (0, 0) fill_color (Color, optional): Fill color. Default: White outline_color (Color, optional): Outline color. Default: Transparent outline (float, optional): Outline thickness. Default: 0 (no outline) Keyword Args: click (callable): Click handler. Default: None visible (bool): Visibility state. Default: True opacity (float): Opacity (0.0-1.0). Default: 1.0 z_index (int): Rendering order. Default: 0 name (str): Element name for finding. Default: None Attributes: radius (float): Circle radius center (Vector): Center position fill_color (Color): Fill color outline_color (Color): Outline color outline (float): Outline thickness visible (bool): Visibility state opacity (float): Opacity value z_index (int): Rendering order name (str): Element name
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
SFML Color Object
from_hex(hex_string: str) -> ColorCreate a Color from a hexadecimal string. Note:
Returns: Color: New Color object with values from hex string
Raises: ValueError: If hex string is not 6 or 8 characters (RGB or RGBA) This is a class method. Call as Color.from_hex('#FF0000')
lerp(other: Color, t: float) -> ColorLinearly interpolate between this color and another. Note:
Returns: Color: New Color representing the interpolated value All components (r, g, b, a) are interpolated independently
to_hex() -> strConvert this Color to a hexadecimal string. Note:
Returns: str: Hex string in format '#RRGGBB' or '#RRGGBBAA' (if alpha < 255) Alpha component is only included if not fully opaque (< 255)
ColorLayer(z_index=-1, grid_size=None) A grid layer that stores RGBA colors per cell. Args: z_index (int): Render order. Negative = below entities. Default: -1 grid_size (tuple): Dimensions as (width, height). Default: parent grid size Attributes: z_index (int): Layer z-order relative to entities visible (bool): Whether layer is rendered grid_size (tuple): Layer dimensions (read-only) Methods: at(x, y): Get color at cell position set(x, y, color): Set color at cell position fill(color): Fill entire layer with color
at(x, y) -> ColorGet the color at cell position (x, y).
fill(color)Fill the entire layer with the specified color.
set(x, y, color)Set the color at cell position (x, y).
Base class for all drawable UI elements
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
Entity(grid_pos=None, texture=None, sprite_index=0, **kwargs) A game entity that exists on a grid with sprite rendering. Args: grid_pos (tuple, optional): Grid position as (x, y) tuple. Default: (0, 0) texture (Texture, optional): Texture object for sprite. Default: default texture sprite_index (int, optional): Index into texture atlas. Default: 0 Keyword Args: grid (Grid): Grid to attach entity to. Default: None visible (bool): Visibility state. Default: True opacity (float): Opacity (0.0-1.0). Default: 1.0 name (str): Element name for finding. Default: None x (float): X grid position override. Default: 0 y (float): Y grid position override. Default: 0 Attributes: pos (tuple): Grid position as (x, y) tuple x, y (float): Grid position coordinates draw_pos (tuple): Pixel position for rendering gridstate (GridPointState): Visibility state for grid points sprite_index (int): Current sprite index visible (bool): Visibility state opacity (float): Opacity value name (str): Element name
at(...)die(...)Remove this entity from its grid
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
index(...)Return the index of this entity in its grid's entity collection
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
path_to(x: int, y: int) -> boolFind and follow path to target position using A* pathfinding.
Returns: True if a path was found and the entity started moving, False otherwise The entity will automatically move along the path over multiple frames. Call this again to change the target or repath.
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
update_visibility() -> NoneUpdate entity's visibility state based on current FOV. Recomputes which cells are visible from the entity's position and updates the entity's gridstate to track explored areas. This is called automatically when the entity moves if it has a grid with perspective set.
Iterable, indexable collection of Entities
append(entity)Add an entity to the end of the collection.
count(entity) -> intCount occurrences of entity in the collection.
extend(iterable)Add all entities from an iterable to the collection.
find(name) -> entity or listFind entities by name.
Returns: Single entity if exact match, list if wildcard, None if not found.
index(entity) -> intReturn index of first occurrence of entity. Raises ValueError if not found.
insert(index, entity)Insert entity at index. Like list.insert(), indices past the end append.
pop([index]) -> entityRemove and return entity at index (default: last entity).
remove(entity)Remove first occurrence of entity. Raises ValueError if not found.
SFML Font Object
Inherits from: Drawable
Frame(pos=None, size=None, **kwargs) A rectangular frame UI element that can contain other drawable elements. Args: pos (tuple, optional): Position as (x, y) tuple. Default: (0, 0) size (tuple, optional): Size as (width, height) tuple. Default: (0, 0) Keyword Args: fill_color (Color): Background fill color. Default: (0, 0, 0, 128) outline_color (Color): Border outline color. Default: (255, 255, 255, 255) outline (float): Border outline thickness. Default: 0 click (callable): Click event handler. Default: None children (list): Initial list of child drawable elements. Default: None visible (bool): Visibility state. Default: True opacity (float): Opacity (0.0-1.0). Default: 1.0 z_index (int): Rendering order. Default: 0 name (str): Element name for finding. Default: None x (float): X position override. Default: 0 y (float): Y position override. Default: 0 w (float): Width override. Default: 0 h (float): Height override. Default: 0 clip_children (bool): Whether to clip children to frame bounds. Default: False cache_subtree (bool): Cache rendering to texture for performance. Default: False Attributes: x, y (float): Position in pixels w, h (float): Size in pixels pos (Vector): Position as a Vector object fill_color, outline_color (Color): Visual appearance outline (float): Border thickness click (callable): Click event handler children (list): Collection of child drawable elements visible (bool): Visibility state opacity (float): Opacity value z_index (int): Rendering order name (str): Element name clip_children (bool): Whether to clip children to frame bounds cache_subtree (bool): Cache subtree rendering to texture
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
Inherits from: Drawable
Grid(pos=None, size=None, grid_size=None, texture=None, **kwargs) A grid-based UI element for tile-based rendering and entity management. Args: pos (tuple, optional): Position as (x, y) tuple. Default: (0, 0) size (tuple, optional): Size as (width, height) tuple. Default: auto-calculated from grid_size grid_size (tuple, optional): Grid dimensions as (grid_x, grid_y) tuple. Default: (2, 2) texture (Texture, optional): Texture containing tile sprites. Default: default texture Keyword Args: fill_color (Color): Background fill color. Default: None click (callable): Click event handler. Default: None center_x (float): X coordinate of center point. Default: 0 center_y (float): Y coordinate of center point. Default: 0 zoom (float): Zoom level for rendering. Default: 1.0 perspective (int): Entity perspective index (-1 for omniscient). Default: -1 visible (bool): Visibility state. Default: True opacity (float): Opacity (0.0-1.0). Default: 1.0 z_index (int): Rendering order. Default: 0 name (str): Element name for finding. Default: None x (float): X position override. Default: 0 y (float): Y position override. Default: 0 w (float): Width override. Default: auto-calculated h (float): Height override. Default: auto-calculated grid_x (int): Grid width override. Default: 2 grid_y (int): Grid height override. Default: 2 Attributes: x, y (float): Position in pixels w, h (float): Size in pixels pos (Vector): Position as a Vector object size (tuple): Size as (width, height) tuple center (tuple): Center point as (x, y) tuple center_x, center_y (float): Center point coordinates zoom (float): Zoom level for rendering grid_size (tuple): Grid dimensions (width, height) in tiles grid_x, grid_y (int): Grid dimensions texture (Texture): Tile texture atlas fill_color (Color): Background color entities (EntityCollection): Collection of entities in the grid perspective (int): Entity perspective index click (callable): Click event handler visible (bool): Visibility state opacity (float): Opacity value z_index (int): Rendering order name (str): Element name
add_layer(type: str, z_index: int = -1, texture: Texture = None) -> ColorLayer | TileLayerAdd a new layer to the grid.
Returns: The created ColorLayer or TileLayer object.
at(...)compute_astar_path(x1: int, y1: int, x2: int, y2: int, diagonal_cost: float = 1.41) -> List[Tuple[int, int]]Compute A* path between two points.
Returns: List of (x, y) tuples representing the path, empty list if no path exists Alternative A* implementation. Prefer find_path() for consistency.
compute_dijkstra(root_x: int, root_y: int, diagonal_cost: float = 1.41) -> NoneCompute Dijkstra map from root position.
compute_fov(x: int, y: int, radius: int = 0, light_walls: bool = True, algorithm: int = FOV_BASIC) -> NoneCompute field of view from a position.
find_path(x1: int, y1: int, x2: int, y2: int, diagonal_cost: float = 1.41) -> List[Tuple[int, int]]Find A* path between two points.
Returns: List of (x, y) tuples representing the path, empty list if no path exists Uses A* algorithm with walkability from grid cells.
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
get_dijkstra_distance(x: int, y: int) -> Optional[float]Get distance from Dijkstra root to position.
Returns: Distance as float, or None if position is unreachable or invalid Must call compute_dijkstra() first.
get_dijkstra_path(x: int, y: int) -> List[Tuple[int, int]]Get path from position to Dijkstra root.
Returns: List of (x, y) tuples representing path to root, empty if unreachable Must call compute_dijkstra() first. Path includes start but not root position.
is_in_fov(x: int, y: int) -> boolCheck if a cell is in the field of view.
Returns: True if the cell is visible, False otherwise Must call compute_fov() first to calculate visibility.
layer(z_index: int) -> ColorLayer | TileLayer | NoneGet a layer by its z_index.
Returns: The layer with the specified z_index, or None if not found.
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
remove_layer(layer: ColorLayer | TileLayer) -> NoneRemove a layer from the grid.
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
UIGridPoint object
UIGridPointState object
Inherits from: Drawable
Line(start=None, end=None, thickness=1.0, color=None, **kwargs) A line UI element for drawing straight lines between two points. Args: start (tuple, optional): Starting point as (x, y). Default: (0, 0) end (tuple, optional): Ending point as (x, y). Default: (0, 0) thickness (float, optional): Line thickness in pixels. Default: 1.0 color (Color, optional): Line color. Default: White Keyword Args: click (callable): Click handler. Default: None visible (bool): Visibility state. Default: True opacity (float): Opacity (0.0-1.0). Default: 1.0 z_index (int): Rendering order. Default: 0 name (str): Element name for finding. Default: None Attributes: start (Vector): Starting point end (Vector): Ending point thickness (float): Line thickness color (Color): Line color visible (bool): Visibility state opacity (float): Opacity value z_index (int): Rendering order name (str): Element name
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
Base class for object-oriented scenes
activate() -> NoneMake this the active scene. Note:
Returns: None Deactivates the current scene and activates this one. Scene transitions and lifecycle callbacks are triggered.
get_ui() -> UICollectionGet the UI element collection for this scene. Note:
Returns: UICollection: Collection of UI elements (Frames, Captions, Sprites, Grids) in this scene Use to add, remove, or iterate over UI elements. Changes are reflected immediately.
register_keyboard(callback: callable) -> NoneRegister a keyboard event handler function. Note:
Returns: None Alternative to overriding on_keypress() method. Handler is called for both key press and release events.
Inherits from: Drawable
Sprite(pos=None, texture=None, sprite_index=0, **kwargs) A sprite UI element that displays a texture or portion of a texture atlas. Args: pos (tuple, optional): Position as (x, y) tuple. Default: (0, 0) texture (Texture, optional): Texture object to display. Default: default texture sprite_index (int, optional): Index into texture atlas. Default: 0 Keyword Args: scale (float): Uniform scale factor. Default: 1.0 scale_x (float): Horizontal scale factor. Default: 1.0 scale_y (float): Vertical scale factor. Default: 1.0 click (callable): Click event handler. Default: None visible (bool): Visibility state. Default: True opacity (float): Opacity (0.0-1.0). Default: 1.0 z_index (int): Rendering order. Default: 0 name (str): Element name for finding. Default: None x (float): X position override. Default: 0 y (float): Y position override. Default: 0 Attributes: x, y (float): Position in pixels pos (Vector): Position as a Vector object texture (Texture): The texture being displayed sprite_index (int): Current sprite index in texture atlas scale (float): Uniform scale factor scale_x, scale_y (float): Individual scale factors click (callable): Click event handler visible (bool): Visibility state opacity (float): Opacity value z_index (int): Rendering order name (str): Element name w, h (float): Read-only computed size based on texture and scale
get_bounds() -> tupleGet the bounding rectangle of this drawable element. Note:
Returns: tuple: (x, y, width, height) representing the element's bounds The bounds are in screen coordinates and account for current position and size.
move(dx: float, dy: float) -> NoneMove the element by a relative offset. Note:
resize(width: float, height: float) -> NoneResize the element to new dimensions. Note:
SFML Texture Object
TileLayer(z_index=-1, texture=None, grid_size=None) A grid layer that stores sprite indices per cell. Args: z_index (int): Render order. Negative = below entities. Default: -1 texture (Texture): Sprite atlas for tile rendering. Default: None grid_size (tuple): Dimensions as (width, height). Default: parent grid size Attributes: z_index (int): Layer z-order relative to entities visible (bool): Whether layer is rendered texture (Texture): Tile sprite atlas grid_size (tuple): Layer dimensions (read-only) Methods: at(x, y): Get tile index at cell position set(x, y, index): Set tile index at cell position fill(index): Fill entire layer with tile index
at(x, y) -> intGet the tile index at cell position (x, y). Returns -1 if no tile.
fill(index)Fill the entire layer with the specified tile index.
set(x, y, index)Set the tile index at cell position (x, y). Use -1 for no tile.
Timer(name, callback, interval, once=False) Create a timer that calls a function at regular intervals. Args: name (str): Unique identifier for the timer callback (callable): Function to call - receives (timer, runtime) args interval (int): Time between calls in milliseconds once (bool): If True, timer stops after first call. Default: False Attributes: interval (int): Time between calls in milliseconds remaining (int): Time until next call in milliseconds (read-only) paused (bool): Whether timer is paused (read-only) active (bool): Whether timer is active and not paused (read-only) callback (callable): The callback function once (bool): Whether timer stops after firing once Methods: pause(): Pause the timer, preserving time remaining resume(): Resume a paused timer cancel(): Stop and remove the timer restart(): Reset timer to start from beginning Example: def on_timer(timer, runtime): print(f'Timer {timer} fired at {runtime}ms') if runtime > 5000: timer.cancel() timer = mcrfpy.Timer('my_timer', on_timer, 1000) timer.pause() # Pause timer timer.resume() # Resume timer timer.once = True # Make it one-shot
cancel() -> NoneCancel the timer and remove it from the timer system. Note:
Returns: None The timer will no longer fire and cannot be restarted. The callback will not be called again.
pause() -> NonePause the timer, preserving the time remaining until next trigger. Note:
Returns: None The timer can be resumed later with resume(). Time spent paused does not count toward the interval.
restart() -> NoneRestart the timer from the beginning. Note:
Returns: None Resets the timer to fire after a full interval from now, regardless of remaining time.
resume() -> NoneResume a paused timer from where it left off. Note:
Returns: None Has no effect if the timer is not paused. Timer will fire after the remaining time elapses.
Iterable, indexable collection of UI objects
append(element)Add an element to the end of the collection.
count(element) -> intCount occurrences of element in the collection.
extend(iterable)Add all elements from an iterable to the collection.
find(name, recursive=False) -> element or listFind elements by name.
Returns: Single element if exact match, list if wildcard, None if not found.
index(element) -> intReturn index of first occurrence of element. Raises ValueError if not found.
insert(index, element)Insert element at index. Like list.insert(), indices past the end append. Note: If using z_index for sorting, insertion order may not persist after the next render. Use name-based .find() for stable element access.
pop([index]) -> elementRemove and return element at index (default: last element). Note: If using z_index for sorting, indices may shift after render. Use name-based .find() for stable element access.
remove(element)Remove first occurrence of element. Raises ValueError if not found.
Iterator for a collection of UI objects
Iterator for a collection of UI objects
SFML Vector Object
angle() -> floatGet the angle of this vector in radians.
Returns: float: Angle in radians from positive x-axis
copy() -> VectorCreate a copy of this vector.
Returns: Vector: New Vector object with same x and y values
distance_to(other: Vector) -> floatCalculate the distance to another vector.
Returns: float: Distance between the two vectors
dot(other: Vector) -> floatCalculate the dot product with another vector.
Returns: float: Dot product of the two vectors
floor() -> VectorReturn a new vector with floored (integer) coordinates. Note:
Returns: Vector: New Vector with floor(x) and floor(y) Useful for grid-based positioning. For a hashable tuple, use the .int property instead.
magnitude() -> floatCalculate the length/magnitude of this vector.
Returns: float: The magnitude of the vector
magnitude_squared() -> floatCalculate the squared magnitude of this vector. Note:
Returns: float: The squared magnitude (faster than magnitude()) Use this for comparisons to avoid expensive square root calculation.
normalize() -> VectorReturn a unit vector in the same direction. Note:
Returns: Vector: New normalized vector with magnitude 1.0 For zero vectors (magnitude 0.0), returns a zero vector rather than raising an exception
Window singleton for accessing and modifying the game window properties
center() -> NoneCenter the window on the screen. Note:
Returns: None Only works in windowed mode. Has no effect when fullscreen or in headless mode.
get() -> WindowGet the Window singleton instance. Note:
Returns: Window: The global window object This is a class method. Call as Window.get(). There is only one window instance per application.
screenshot(filename: str = None) -> bytes | NoneTake a screenshot of the current window contents. Note:
Returns: bytes | None: Raw RGBA pixel data if no filename given, otherwise None after saving Screenshot is taken at the actual window resolution. Use after render loop update for current frame.
FOV_BASIC (int): 0FOV_DIAMOND (int): 1FOV_PERMISSIVE_0 (int): 3FOV_PERMISSIVE_1 (int): 4FOV_PERMISSIVE_2 (int): 5FOV_PERMISSIVE_3 (int): 6FOV_PERMISSIVE_4 (int): 7FOV_PERMISSIVE_5 (int): 8FOV_PERMISSIVE_6 (int): 9FOV_PERMISSIVE_7 (int): 10FOV_PERMISSIVE_8 (int): 11FOV_RESTRICTIVE (int): 12FOV_SHADOW (int): 2