Generated on 2025-07-10 01:13:53
This documentation was dynamically generated from the compiled module.
createScenecreateScene(name: str) -> None
Create a new empty scene. Note:
createSoundBuffercreateSoundBuffer(filename: str) -> int
Load a sound effect from a file and return its buffer ID.
Returns: int: Buffer ID for use with playSound() RuntimeError: If the file cannot be loaded
currentScenecurrentScene() -> str
Get the name of the currently active scene.
Returns: str: Name of the current scene
delTimerdelTimer(name: str) -> None
Stop and remove a timer. Note:
exitexit() -> None
Cleanly shut down the game engine and exit the application. Note:
findfind(name: str, scene: str = None) -> UIDrawable | None
Find 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.
findAllfindAll(pattern: str, scene: str = None) -> list
Find all UI elements matching a name pattern.
Returns: list: All matching UI elements and entities
findAll('enemy*') # Find all elements starting with 'enemy'
findAll('*_button') # Find all elements ending with '_button'
getMetricsgetMetrics() -> dict
Get 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
getMusicVolumegetMusicVolume() -> int
Get the current music volume level.
Returns: int: Current volume (0-100)
getSoundVolumegetSoundVolume() -> int
Get the current sound effects volume level.
Returns: int: Current volume (0-100)
keypressScenekeypressScene(handler: callable) -> None
Set the keyboard event handler for the current scene.
def on_key(key, pressed):
if key == 'A' and pressed:
print('A key pressed')
mcrfpy.keypressScene(on_key)
loadMusicloadMusic(filename: str) -> None
Load and immediately play background music from a file. Note:
playSoundplaySound(buffer_id: int) -> None
Play a sound effect using a previously loaded buffer.
sceneUIsceneUI(scene: str = None) -> list
Get all UI elements for a scene.
Returns: list: All UI elements (Frame, Caption, Sprite, Grid) in the scene KeyError: If the specified scene doesn't exist
setMusicVolumesetMusicVolume(volume: int) -> None
Set the global music volume.
setScalesetScale(multiplier: float) -> None
Scale the game window size. Note:
setScenesetScene(scene: str, transition: str = None, duration: float = 0.0) -> None
Switch to a different scene with optional transition effect.
setSoundVolumesetSoundVolume(volume: int) -> None
Set the global sound effects volume.
setTimersetTimer(name: str, handler: callable, interval: int) -> None
Create or update a recurring timer. Note:
Animation object for animating UI properties
get_current_value(...)
Get the current interpolated value
start(...)
Start the animation on a target UIDrawable
updateUpdate the animation by deltaTime (returns True if still running)
Inherits from: Drawable
Caption(text='', x=0, y=0, font=None, fill_color=None, outline_color=None, outline=0, click=None) A text display UI element with customizable font and styling. Args: text (str): The text content to display. Default: '' x (float): X position in pixels. Default: 0 y (float): Y position in pixels. Default: 0 font (Font): Font object for text rendering. Default: engine default font 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 click (callable): Click event handler. Default: None Attributes: text (str): The displayed text content x, y (float): Position in pixels font (Font): Font used for rendering fill_color, outline_color (Color): Text appearance outline (float): Outline thickness click (callable): Click event handler visible (bool): Visibility state z_index (int): Rendering order w, h (float): Read-only computed size based on text and font
get_boundsGet bounding box as (x, y, width, height)
moveMove by relative offset (dx, dy)
resizeResize to new dimensions (width, height)
SFML Color Object
from_hexCreate Color from hex string (e.g., '#FF0000' or 'FF0000')
lerp(...)
Linearly interpolate between this color and another
to_hex(...)
Convert Color to hex string
Base class for all drawable UI elements
get_boundsGet bounding box as (x, y, width, height)
moveMove by relative offset (dx, dy)
resizeResize to new dimensions (width, height)
Inherits from: Drawable
UIEntity objects
at(...)
die(...)
Remove this entity from its grid
get_boundsGet bounding box as (x, y, width, height)
index(...)
Return the index of this entity in its grid's entity collection
moveMove by relative offset (dx, dy)
path_topath_to(x: int, y: int) -> bool
Find and follow path to target position using A* pathfinding.
Returns: True if a path was found and the entity started moving, False otherwise
resizeResize to new dimensions (width, height)
update_visibilityupdate_visibility() -> None
Update 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(...)
count(...)
extend(...)
index(...)
remove(...)
SFML Font Object
Inherits from: Drawable
Frame(x=0, y=0, w=0, h=0, fill_color=None, outline_color=None, outline=0, click=None, children=None) A rectangular frame UI element that can contain other drawable elements. Args: x (float): X position in pixels. Default: 0 y (float): Y position in pixels. Default: 0 w (float): Width in pixels. Default: 0 h (float): Height in pixels. Default: 0 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 Attributes: x, y (float): Position in pixels w, h (float): Size in pixels 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 z_index (int): Rendering order clip_children (bool): Whether to clip children to frame bounds
get_boundsGet bounding box as (x, y, width, height)
moveMove by relative offset (dx, dy)
resizeResize to new dimensions (width, height)
Inherits from: Drawable
Grid(x=0, y=0, grid_size=(20, 20), texture=None, tile_width=16, tile_height=16, scale=1.0, click=None) A grid-based tilemap UI element for rendering tile-based levels and game worlds. Args: x (float): X position in pixels. Default: 0 y (float): Y position in pixels. Default: 0 grid_size (tuple): Grid dimensions as (width, height) in tiles. Default: (20, 20) texture (Texture): Texture atlas containing tile sprites. Default: None tile_width (int): Width of each tile in pixels. Default: 16 tile_height (int): Height of each tile in pixels. Default: 16 scale (float): Grid scaling factor. Default: 1.0 click (callable): Click event handler. Default: None Attributes: x, y (float): Position in pixels grid_size (tuple): Grid dimensions (width, height) in tiles tile_width, tile_height (int): Tile dimensions in pixels texture (Texture): Tile texture atlas scale (float): Scale multiplier points (list): 2D array of GridPoint objects for tile data entities (list): Collection of Entity objects in the grid background_color (Color): Grid background color click (callable): Click event handler visible (bool): Visibility state z_index (int): Rendering order
at(...)
compute_astar_pathcompute_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
compute_dijkstracompute_dijkstra(root_x: int, root_y: int, diagonal_cost: float = 1.41) -> None
Compute Dijkstra map from root position.
compute_fovcompute_fov(x: int, y: int, radius: int = 0, light_walls: bool = True, algorithm: int = FOV_BASIC) -> None
Compute field of view from a position.
find_pathfind_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
get_boundsGet bounding box as (x, y, width, height)
get_dijkstra_distanceget_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
get_dijkstra_pathget_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
is_in_fovis_in_fov(x: int, y: int) -> bool
Check if a cell is in the field of view.
Returns: True if the cell is visible, False otherwise
moveMove by relative offset (dx, dy)
resizeResize to new dimensions (width, height)
UIGridPoint object
UIGridPointState object
Base class for object-oriented scenes
activate(...)
Make this the active scene
get_ui(...)
Get the UI element collection for this scene
register_keyboardRegister a keyboard handler function (alternative to overriding on_keypress)
Inherits from: Drawable
Sprite(x=0, y=0, texture=None, sprite_index=0, scale=1.0, click=None) A sprite UI element that displays a texture or portion of a texture atlas. Args: x (float): X position in pixels. Default: 0 y (float): Y position in pixels. Default: 0 texture (Texture): Texture object to display. Default: None sprite_index (int): Index into texture atlas (if applicable). Default: 0 scale (float): Sprite scaling factor. Default: 1.0 click (callable): Click event handler. Default: None Attributes: x, y (float): Position in pixels texture (Texture): The texture being displayed sprite_index (int): Current sprite index in texture atlas scale (float): Scale multiplier click (callable): Click event handler visible (bool): Visibility state z_index (int): Rendering order w, h (float): Read-only computed size based on texture and scale
get_boundsGet bounding box as (x, y, width, height)
moveMove by relative offset (dx, dy)
resizeResize to new dimensions (width, height)
SFML Texture Object
Timer object for scheduled callbacks
cancel(...)
Cancel the timer and remove it from the system
pause(...)
Pause the timer
restart(...)
Restart the timer from the current time
resume(...)
Resume a paused timer
Iterable, indexable collection of UI objects
append(...)
count(...)
extend(...)
index(...)
remove(...)
Iterator for a collection of UI objects
Iterator for a collection of UI objects
SFML Vector Object
angle(...)
Return the angle in radians from the positive X axis
copy(...)
Return a copy of this vector
distance_to(...)
Return the distance to another vector
dot(...)
Return the dot product with another vector
magnitude(...)
Return the length of the vector
magnitude_squared(...)
Return the squared length of the vector
normalize(...)
Return a unit vector in the same direction
Window singleton for accessing and modifying the game window properties
center(...)
Center the window on the screen
get(...)
Get the Window singleton instance
screenshot(...)
Take a screenshot. Pass filename to save to file, or get raw bytes if no filename.
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