McRogueFace/docs/api_reference_complete.html

1602 lines
53 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>McRogueFace API Reference - Complete Documentation</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background: #f8f9fa;
}
.container {
background: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
color: #2c3e50;
border-bottom: 3px solid #3498db;
padding-bottom: 15px;
margin-bottom: 30px;
}
h2 {
color: #34495e;
border-bottom: 2px solid #ecf0f1;
padding-bottom: 10px;
margin-top: 40px;
}
h3 {
color: #2c3e50;
margin-top: 30px;
}
h4 {
color: #34495e;
margin-top: 20px;
font-size: 1.1em;
}
h5 {
color: #555;
margin-top: 15px;
font-size: 1em;
}
code {
background: #f4f4f4;
padding: 2px 6px;
border-radius: 3px;
font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
font-size: 0.9em;
}
pre {
background: #f8f8f8;
border: 1px solid #e1e4e8;
border-radius: 6px;
padding: 16px;
overflow-x: auto;
margin: 15px 0;
}
pre code {
background: none;
padding: 0;
font-size: 0.875em;
line-height: 1.45;
}
.class-name {
color: #8e44ad;
font-weight: bold;
}
.property {
color: #27ae60;
font-weight: 600;
}
.method {
color: #2980b9;
font-weight: 600;
}
.function-signature {
color: #d73a49;
font-weight: 600;
}
.method-section {
margin: 20px 0;
padding: 15px;
background: #f8f9fa;
border-radius: 6px;
border-left: 4px solid #3498db;
}
.arg-list {
margin: 10px 0;
}
.arg-item {
margin: 8px 0;
padding: 8px;
background: #fff;
border-radius: 4px;
border: 1px solid #e1e4e8;
}
.arg-name {
color: #d73a49;
font-weight: 600;
}
.arg-type {
color: #6f42c1;
font-style: italic;
}
.returns {
background: #e8f5e8;
padding: 10px;
border-radius: 4px;
border-left: 4px solid #28a745;
margin: 10px 0;
}
.note {
background: #fff3cd;
padding: 10px;
border-radius: 4px;
border-left: 4px solid #ffc107;
margin: 10px 0;
}
.example {
background: #e7f3ff;
padding: 15px;
border-radius: 4px;
border-left: 4px solid #0366d6;
margin: 15px 0;
}
.toc {
background: #f8f9fa;
border: 1px solid #e1e4e8;
border-radius: 6px;
padding: 20px;
margin: 20px 0;
}
.toc ul {
list-style: none;
padding-left: 0;
}
.toc li {
margin: 8px 0;
}
.toc a {
color: #3498db;
text-decoration: none;
font-weight: 500;
}
.toc a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>McRogueFace API Reference - Complete Documentation</h1>
<p><em>Generated on 2025-07-08 11:53:54</em></p>
<div class="toc">
<h2>Table of Contents</h2>
<ul>
<li><a href="#functions">Functions</a></li>
<li><a href="#classes">Classes</a></li>
<li><a href="#automation">Automation Module</a></li>
</ul>
</div>
<h2 id="functions">Functions</h2>
<h3>Scene Management</h3>
<div class="method-section">
<h4><code class="function-signature">createScene(name: str) -> None</code></h4>
<p>Create a new empty scene with the given name.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">name</span>
<span class="arg-type">(str)</span>:
Unique name for the new scene
</div>
</div>
<div class="note">
<strong>Raises:</strong> ValueError: If a scene with this name already exists
</div>
<div class="note">
<strong>Note:</strong> The scene is created but not made active. Use setScene() to switch to it.
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.createScene(&quot;game_over&quot;)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">setScene(scene: str, transition: str = None, duration: float = 0.0) -> None</code></h4>
<p>Switch to a different scene with optional transition effect.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">scene</span>
<span class="arg-type">(str)</span>:
Name of the scene to switch to
</div>
<div class="arg-item">
<span class="arg-name">transition</span>
<span class="arg-type">(str)</span>:
Transition type: &quot;fade&quot;, &quot;slide_left&quot;, &quot;slide_right&quot;, &quot;slide_up&quot;, &quot;slide_down&quot;
</div>
<div class="arg-item">
<span class="arg-name">duration</span>
<span class="arg-type">(float)</span>:
Transition duration in seconds (default: 0.0 for instant)
</div>
</div>
<div class="note">
<strong>Raises:</strong> KeyError: If the scene doesn&#x27;t exist
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.setScene(&quot;game&quot;, &quot;fade&quot;, 0.5)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">currentScene() -> str</code></h4>
<p>Get the name of the currently active scene.</p>
<div class="returns">
<strong>Returns:</strong> str: Name of the current scene
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
scene_name = mcrfpy.currentScene()
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">sceneUI(scene: str = None) -> UICollection</code></h4>
<p>Get all UI elements for a scene.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">scene</span>
<span class="arg-type">(str)</span>:
Scene name. If None, uses current scene
</div>
</div>
<div class="returns">
<strong>Returns:</strong> UICollection: All UI elements in the scene
</div>
<div class="note">
<strong>Raises:</strong> KeyError: If the specified scene doesn&#x27;t exist
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
ui_elements = mcrfpy.sceneUI(&quot;game&quot;)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">keypressScene(handler: callable) -> None</code></h4>
<p>Set the keyboard event handler for the current scene.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">handler</span>
<span class="arg-type">(callable)</span>:
Function that receives (key_name: str, is_pressed: bool)
</div>
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
def on_key(key, pressed):
if key == &quot;SPACE&quot; and pressed:
player.jump()
mcrfpy.keypressScene(on_key)
</code></pre>
</div>
</div>
<h3>Audio</h3>
<div class="method-section">
<h4><code class="function-signature">createSoundBuffer(filename: str) -> int</code></h4>
<p>Load a sound effect from a file and return its buffer ID.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">filename</span>
<span class="arg-type">(str)</span>:
Path to the sound file (WAV, OGG, FLAC)
</div>
</div>
<div class="returns">
<strong>Returns:</strong> int: Buffer ID for use with playSound()
</div>
<div class="note">
<strong>Raises:</strong> RuntimeError: If the file cannot be loaded
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
jump_sound = mcrfpy.createSoundBuffer(&quot;assets/jump.wav&quot;)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">loadMusic(filename: str, loop: bool = True) -> None</code></h4>
<p>Load and immediately play background music from a file.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">filename</span>
<span class="arg-type">(str)</span>:
Path to the music file (WAV, OGG, FLAC)
</div>
<div class="arg-item">
<span class="arg-name">loop</span>
<span class="arg-type">(bool)</span>:
Whether to loop the music (default: True)
</div>
</div>
<div class="note">
<strong>Note:</strong> Only one music track can play at a time. Loading new music stops the current track.
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.loadMusic(&quot;assets/background.ogg&quot;, True)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">playSound(buffer_id: int) -> None</code></h4>
<p>Play a sound effect using a previously loaded buffer.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">buffer_id</span>
<span class="arg-type">(int)</span>:
Sound buffer ID returned by createSoundBuffer()
</div>
</div>
<div class="note">
<strong>Raises:</strong> RuntimeError: If the buffer ID is invalid
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.playSound(jump_sound)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">getMusicVolume() -> int</code></h4>
<p>Get the current music volume level.</p>
<div class="returns">
<strong>Returns:</strong> int: Current volume (0-100)
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
current_volume = mcrfpy.getMusicVolume()
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">getSoundVolume() -> int</code></h4>
<p>Get the current sound effects volume level.</p>
<div class="returns">
<strong>Returns:</strong> int: Current volume (0-100)
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
current_volume = mcrfpy.getSoundVolume()
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">setMusicVolume(volume: int) -> None</code></h4>
<p>Set the global music volume.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">volume</span>
<span class="arg-type">(int)</span>:
Volume level from 0 (silent) to 100 (full volume)
</div>
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.setMusicVolume(50) # Set to 50% volume
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">setSoundVolume(volume: int) -> None</code></h4>
<p>Set the global sound effects volume.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">volume</span>
<span class="arg-type">(int)</span>:
Volume level from 0 (silent) to 100 (full volume)
</div>
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.setSoundVolume(75) # Set to 75% volume
</code></pre>
</div>
</div>
<h3>UI Utilities</h3>
<div class="method-section">
<h4><code class="function-signature">find(name: str, scene: str = None) -> UIDrawable | None</code></h4>
<p>Find the first UI element with the specified name.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">name</span>
<span class="arg-type">(str)</span>:
Exact name to search for
</div>
<div class="arg-item">
<span class="arg-name">scene</span>
<span class="arg-type">(str)</span>:
Scene to search in (default: current scene)
</div>
</div>
<div class="returns">
<strong>Returns:</strong> UIDrawable or None: The found element, or None if not found
</div>
<div class="note">
<strong>Note:</strong> Searches scene UI elements and entities within grids.
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
button = mcrfpy.find(&quot;start_button&quot;)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">findAll(pattern: str, scene: str = None) -> list</code></h4>
<p>Find all UI elements matching a name pattern.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">pattern</span>
<span class="arg-type">(str)</span>:
Name pattern with optional wildcards (* matches any characters)
</div>
<div class="arg-item">
<span class="arg-name">scene</span>
<span class="arg-type">(str)</span>:
Scene to search in (default: current scene)
</div>
</div>
<div class="returns">
<strong>Returns:</strong> list: All matching UI elements and entities
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
enemies = mcrfpy.findAll(&quot;enemy_*&quot;)
</code></pre>
</div>
</div>
<h3>System</h3>
<div class="method-section">
<h4><code class="function-signature">exit() -> None</code></h4>
<p>Cleanly shut down the game engine and exit the application.</p>
<div class="note">
<strong>Note:</strong> This immediately closes the window and terminates the program.
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.exit()
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">getMetrics() -> dict</code></h4>
<p>Get current performance metrics.</p>
<div class="returns">
<strong>Returns:</strong> 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
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
metrics = mcrfpy.getMetrics()
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">setTimer(name: str, handler: callable, interval: int) -> None</code></h4>
<p>Create or update a recurring timer.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">name</span>
<span class="arg-type">(str)</span>:
Unique identifier for the timer
</div>
<div class="arg-item">
<span class="arg-name">handler</span>
<span class="arg-type">(callable)</span>:
Function called with (runtime: float) parameter
</div>
<div class="arg-item">
<span class="arg-name">interval</span>
<span class="arg-type">(int)</span>:
Time between calls in milliseconds
</div>
</div>
<div class="note">
<strong>Note:</strong> If a timer with this name exists, it will be replaced.
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
def update_score(runtime):
score += 1
mcrfpy.setTimer(&quot;score_update&quot;, update_score, 1000)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">delTimer(name: str) -> None</code></h4>
<p>Stop and remove a timer.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">name</span>
<span class="arg-type">(str)</span>:
Timer identifier to remove
</div>
</div>
<div class="note">
<strong>Note:</strong> No error is raised if the timer doesn&#x27;t exist.
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.delTimer(&quot;score_update&quot;)
</code></pre>
</div>
</div>
<div class="method-section">
<h4><code class="function-signature">setScale(multiplier: float) -> None</code></h4>
<p>Scale the game window size.</p>
<div class="arg-list">
<h5>Arguments:</h5>
<div class="arg-item">
<span class="arg-name">multiplier</span>
<span class="arg-type">(float)</span>:
Scale factor (e.g., 2.0 for double size)
</div>
</div>
<div class="note">
<strong>Note:</strong> The internal resolution remains 1024x768, but the window is scaled.
</div>
<div class="example">
<h5>Example:</h5>
<pre><code>
mcrfpy.setScale(2.0) # Double the window size
</code></pre>
</div>
</div>
<h2 id="classes">Classes</h2>
<div class="method-section">
<h3><span class="class-name">Animation</span></h3>
<p>Animation object for animating UI properties</p>
<h4>Properties:</h4>
<div class="arg-item">
<span class="property">property</span>: str: Name of the property being animated (e.g., &quot;x&quot;, &quot;y&quot;, &quot;scale&quot;)
</div>
<div class="arg-item">
<span class="property">duration</span>: float: Total duration of the animation in seconds
</div>
<div class="arg-item">
<span class="property">elapsed_time</span>: float: Time elapsed since animation started (read-only)
</div>
<div class="arg-item">
<span class="property">current_value</span>: float: Current interpolated value of the animation (read-only)
</div>
<div class="arg-item">
<span class="property">is_running</span>: bool: True if animation is currently running (read-only)
</div>
<div class="arg-item">
<span class="property">is_finished</span>: bool: True if animation has completed (read-only)
</div>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get_current_value()</code></h5>
<p>Get the current interpolated value of the animation.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> float: Current animation value between start and end
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">update(delta_time)</code></h5>
<p>Update the animation by the given time delta.</p>
<div style="margin-left: 20px;">
<span class="arg-name">delta_time</span>
<span class="arg-type">(float)</span>:
Time elapsed since last update in seconds
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> bool: True if animation is still running, False if finished
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">start(target)</code></h5>
<p>Start the animation on a target UI element.</p>
<div style="margin-left: 20px;">
<span class="arg-name">target</span>
<span class="arg-type">(UIDrawable)</span>:
The UI element to animate
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> The target must have the property specified in the animation constructor.
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Caption</span></h3>
<p>Caption(text=&#x27;&#x27;, 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: &#x27;&#x27;
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</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get_bounds()</code></h5>
<p>Get the bounding rectangle of this drawable element.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> tuple: (x, y, width, height) representing the element&#x27;s bounds
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> The bounds are in screen coordinates and account for current position and size.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">resize(width, height)</code></h5>
<p>Resize the element to new dimensions.</p>
<div style="margin-left: 20px;">
<span class="arg-name">width</span>
<span class="arg-type">(float)</span>:
New width in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">height</span>
<span class="arg-type">(float)</span>:
New height in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> For Caption and Sprite, this may not change actual size if determined by content.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">move(dx, dy)</code></h5>
<p>Move the element by a relative offset.</p>
<div style="margin-left: 20px;">
<span class="arg-name">dx</span>
<span class="arg-type">(float)</span>:
Horizontal offset in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">dy</span>
<span class="arg-type">(float)</span>:
Vertical offset in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> This modifies the x and y position properties by the given amounts.
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Color</span></h3>
<p>SFML Color Object</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">lerp(other, t)</code></h5>
<p>Linearly interpolate between this color and another.</p>
<div style="margin-left: 20px;">
<span class="arg-name">other</span>
<span class="arg-type">(Color)</span>:
The color to interpolate towards
</div>
<div style="margin-left: 20px;">
<span class="arg-name">t</span>
<span class="arg-type">(float)</span>:
Interpolation factor from 0.0 to 1.0
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> Color: New interpolated Color object
</div>
<div style="margin-left: 20px;">
<strong>Example:</strong>
<pre><code>
mixed = red.lerp(blue, 0.5) # 50% between red and blue
</code></pre>
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">to_hex()</code></h5>
<p>Convert this Color to a hexadecimal string.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> str: Hex color string in format &quot;#RRGGBB&quot;
</div>
<div style="margin-left: 20px;">
<strong>Example:</strong>
<pre><code>
hex_str = color.to_hex() # Returns &quot;#FF0000&quot;
</code></pre>
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">from_hex(hex_string)</code></h5>
<p>Create a Color from a hexadecimal color string.</p>
<div style="margin-left: 20px;">
<span class="arg-name">hex_string</span>
<span class="arg-type">(str)</span>:
Hex color string (e.g., &quot;#FF0000&quot; or &quot;FF0000&quot;)
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> Color: New Color object from hex string
</div>
<div style="margin-left: 20px;">
<strong>Example:</strong>
<pre><code>
red = Color.from_hex(&quot;#FF0000&quot;)
</code></pre>
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Drawable</span></h3>
<p>Base class for all drawable UI elements</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get_bounds()</code></h5>
<p>Get the bounding rectangle of this drawable element.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> tuple: (x, y, width, height) representing the element&#x27;s bounds
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> The bounds are in screen coordinates and account for current position and size.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">resize(width, height)</code></h5>
<p>Resize the element to new dimensions.</p>
<div style="margin-left: 20px;">
<span class="arg-name">width</span>
<span class="arg-type">(float)</span>:
New width in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">height</span>
<span class="arg-type">(float)</span>:
New height in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> For Caption and Sprite, this may not change actual size if determined by content.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">move(dx, dy)</code></h5>
<p>Move the element by a relative offset.</p>
<div style="margin-left: 20px;">
<span class="arg-name">dx</span>
<span class="arg-type">(float)</span>:
Horizontal offset in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">dy</span>
<span class="arg-type">(float)</span>:
Vertical offset in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> This modifies the x and y position properties by the given amounts.
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Entity</span></h3>
<p>UIEntity objects</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get_bounds()</code></h5>
<p>Get the bounding rectangle of this drawable element.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> tuple: (x, y, width, height) representing the element&#x27;s bounds
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> The bounds are in screen coordinates and account for current position and size.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">move(dx, dy)</code></h5>
<p>Move the element by a relative offset.</p>
<div style="margin-left: 20px;">
<span class="arg-name">dx</span>
<span class="arg-type">(float)</span>:
Horizontal offset in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">dy</span>
<span class="arg-type">(float)</span>:
Vertical offset in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> This modifies the x and y position properties by the given amounts.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">at(x, y)</code></h5>
<p>Check if this entity is at the specified grid coordinates.</p>
<div style="margin-left: 20px;">
<span class="arg-name">x</span>
<span class="arg-type">(int)</span>:
Grid x coordinate to check
</div>
<div style="margin-left: 20px;">
<span class="arg-name">y</span>
<span class="arg-type">(int)</span>:
Grid y coordinate to check
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> bool: True if entity is at position (x, y), False otherwise
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">resize(width, height)</code></h5>
<p>Resize the element to new dimensions.</p>
<div style="margin-left: 20px;">
<span class="arg-name">width</span>
<span class="arg-type">(float)</span>:
New width in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">height</span>
<span class="arg-type">(float)</span>:
New height in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> For Caption and Sprite, this may not change actual size if determined by content.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">index()</code></h5>
<p>Get the index of this entity in its parent grid&#x27;s entity list.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> int: Index position, or -1 if not in a grid
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">die()</code></h5>
<p>Remove this entity from its parent grid.</p>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> The entity object remains valid but is no longer rendered or updated.
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">EntityCollection</span></h3>
<p>Iterable, indexable collection of Entities</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">remove(entity)</code></h5>
<p>Remove the first occurrence of an entity from the collection.</p>
<div style="margin-left: 20px;">
<span class="arg-name">entity</span>
<span class="arg-type">(Entity)</span>:
The entity to remove
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">extend(iterable)</code></h5>
<p>Add all entities from an iterable to the collection.</p>
<div style="margin-left: 20px;">
<span class="arg-name">iterable</span>
<span class="arg-type">(Iterable[Entity])</span>:
Entities to add
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">append(entity)</code></h5>
<p>Add an entity to the end of the collection.</p>
<div style="margin-left: 20px;">
<span class="arg-name">entity</span>
<span class="arg-type">(Entity)</span>:
The entity to add
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">index(entity)</code></h5>
<p>Find the index of the first occurrence of an entity.</p>
<div style="margin-left: 20px;">
<span class="arg-name">entity</span>
<span class="arg-type">(Entity)</span>:
The entity to find
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> int: Index of entity in collection
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">count(entity)</code></h5>
<p>Count the number of occurrences of an entity in the collection.</p>
<div style="margin-left: 20px;">
<span class="arg-name">entity</span>
<span class="arg-type">(Entity)</span>:
The entity to count
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> int: Number of times entity appears in collection
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Font</span></h3>
<p>SFML Font Object</p>
</div>
<div class="method-section">
<h3><span class="class-name">Frame</span></h3>
<p>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</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get_bounds()</code></h5>
<p>Get the bounding rectangle of this drawable element.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> tuple: (x, y, width, height) representing the element&#x27;s bounds
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> The bounds are in screen coordinates and account for current position and size.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">resize(width, height)</code></h5>
<p>Resize the element to new dimensions.</p>
<div style="margin-left: 20px;">
<span class="arg-name">width</span>
<span class="arg-type">(float)</span>:
New width in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">height</span>
<span class="arg-type">(float)</span>:
New height in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> For Caption and Sprite, this may not change actual size if determined by content.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">move(dx, dy)</code></h5>
<p>Move the element by a relative offset.</p>
<div style="margin-left: 20px;">
<span class="arg-name">dx</span>
<span class="arg-type">(float)</span>:
Horizontal offset in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">dy</span>
<span class="arg-type">(float)</span>:
Vertical offset in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> This modifies the x and y position properties by the given amounts.
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Grid</span></h3>
<p>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</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get_bounds()</code></h5>
<p>Get the bounding rectangle of this drawable element.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> tuple: (x, y, width, height) representing the element&#x27;s bounds
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> The bounds are in screen coordinates and account for current position and size.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">at(x, y)</code></h5>
<p>Get the GridPoint at the specified grid coordinates.</p>
<div style="margin-left: 20px;">
<span class="arg-name">x</span>
<span class="arg-type">(int)</span>:
Grid x coordinate
</div>
<div style="margin-left: 20px;">
<span class="arg-name">y</span>
<span class="arg-type">(int)</span>:
Grid y coordinate
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> GridPoint or None: The grid point at (x, y), or None if out of bounds
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">resize(width, height)</code></h5>
<p>Resize the element to new dimensions.</p>
<div style="margin-left: 20px;">
<span class="arg-name">width</span>
<span class="arg-type">(float)</span>:
New width in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">height</span>
<span class="arg-type">(float)</span>:
New height in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> For Caption and Sprite, this may not change actual size if determined by content.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">move(dx, dy)</code></h5>
<p>Move the element by a relative offset.</p>
<div style="margin-left: 20px;">
<span class="arg-name">dx</span>
<span class="arg-type">(float)</span>:
Horizontal offset in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">dy</span>
<span class="arg-type">(float)</span>:
Vertical offset in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> This modifies the x and y position properties by the given amounts.
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">GridPoint</span></h3>
<p>UIGridPoint object</p>
<h4>Properties:</h4>
<div class="arg-item">
<span class="property">x</span>: int: Grid x coordinate of this point
</div>
<div class="arg-item">
<span class="property">y</span>: int: Grid y coordinate of this point
</div>
<div class="arg-item">
<span class="property">texture_index</span>: int: Index of the texture/sprite to display at this point
</div>
<div class="arg-item">
<span class="property">solid</span>: bool: Whether this point blocks movement
</div>
<div class="arg-item">
<span class="property">transparent</span>: bool: Whether this point allows light/vision through
</div>
<div class="arg-item">
<span class="property">color</span>: Color: Color tint applied to the texture at this point
</div>
</div>
<div class="method-section">
<h3><span class="class-name">GridPointState</span></h3>
<p>UIGridPointState object</p>
<h4>Properties:</h4>
<div class="arg-item">
<span class="property">visible</span>: bool: Whether this point is currently visible to the player
</div>
<div class="arg-item">
<span class="property">discovered</span>: bool: Whether this point has been discovered/explored
</div>
<div class="arg-item">
<span class="property">custom_flags</span>: int: Bitfield for custom game-specific flags
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Scene</span></h3>
<p>Base class for object-oriented scenes</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">keypress(handler)</code></h5>
<p>Register a keyboard handler function for this scene.</p>
<div style="margin-left: 20px;">
<span class="arg-name">handler</span>
<span class="arg-type">(callable)</span>:
Function that takes (key_name: str, is_pressed: bool)
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Alternative to overriding the on_keypress method.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get_ui()</code></h5>
<p>Get the UI element collection for this scene.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> UICollection: Collection of all UI elements in this scene
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">activate()</code></h5>
<p>Make this scene the active scene.</p>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Equivalent to calling setScene() with this scene&#x27;s name.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">register_keyboard(callable)</code></h5>
<p>Register a keyboard event handler function for the scene.</p>
<div style="margin-left: 20px;">
<span class="arg-name">callable</span>
<span class="arg-type">(callable)</span>:
Function that takes (key: str, action: str) parameters
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Alternative to overriding the on_keypress method when subclassing Scene objects.
</div>
<div style="margin-left: 20px;">
<strong>Example:</strong>
<pre><code>
def handle_keyboard(key, action):
print(f&quot;Key &#x27;{key}&#x27; was {action}&quot;)
if key == &quot;q&quot; and action == &quot;press&quot;:
# Handle quit
pass
scene.register_keyboard(handle_keyboard)
</code></pre>
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Sprite</span></h3>
<p>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</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get_bounds()</code></h5>
<p>Get the bounding rectangle of this drawable element.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> tuple: (x, y, width, height) representing the element&#x27;s bounds
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> The bounds are in screen coordinates and account for current position and size.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">resize(width, height)</code></h5>
<p>Resize the element to new dimensions.</p>
<div style="margin-left: 20px;">
<span class="arg-name">width</span>
<span class="arg-type">(float)</span>:
New width in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">height</span>
<span class="arg-type">(float)</span>:
New height in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> For Caption and Sprite, this may not change actual size if determined by content.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">move(dx, dy)</code></h5>
<p>Move the element by a relative offset.</p>
<div style="margin-left: 20px;">
<span class="arg-name">dx</span>
<span class="arg-type">(float)</span>:
Horizontal offset in pixels
</div>
<div style="margin-left: 20px;">
<span class="arg-name">dy</span>
<span class="arg-type">(float)</span>:
Vertical offset in pixels
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> This modifies the x and y position properties by the given amounts.
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Texture</span></h3>
<p>SFML Texture Object</p>
</div>
<div class="method-section">
<h3><span class="class-name">Timer</span></h3>
<p>Timer object for scheduled callbacks</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">resume()</code></h5>
<p>Resume a paused timer.</p>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Has no effect if timer is not paused.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">pause()</code></h5>
<p>Pause the timer, stopping its callback execution.</p>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Use resume() to continue the timer from where it was paused.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">cancel()</code></h5>
<p>Cancel the timer and remove it from the system.</p>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> After cancelling, the timer object cannot be reused.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">restart()</code></h5>
<p>Restart the timer from the beginning.</p>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Resets the timer&#x27;s internal clock to zero.
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">UICollection</span></h3>
<p>Iterable, indexable collection of UI objects</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">remove(drawable)</code></h5>
<p>Remove the first occurrence of a drawable from the collection.</p>
<div style="margin-left: 20px;">
<span class="arg-name">drawable</span>
<span class="arg-type">(UIDrawable)</span>:
The drawable to remove
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">extend(iterable)</code></h5>
<p>Add all drawables from an iterable to the collection.</p>
<div style="margin-left: 20px;">
<span class="arg-name">iterable</span>
<span class="arg-type">(Iterable[UIDrawable])</span>:
Drawables to add
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">append(drawable)</code></h5>
<p>Add a drawable element to the end of the collection.</p>
<div style="margin-left: 20px;">
<span class="arg-name">drawable</span>
<span class="arg-type">(UIDrawable)</span>:
The drawable element to add
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">index(drawable)</code></h5>
<p>Find the index of the first occurrence of a drawable.</p>
<div style="margin-left: 20px;">
<span class="arg-name">drawable</span>
<span class="arg-type">(UIDrawable)</span>:
The drawable to find
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> int: Index of drawable in collection
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">count(drawable)</code></h5>
<p>Count the number of occurrences of a drawable in the collection.</p>
<div style="margin-left: 20px;">
<span class="arg-name">drawable</span>
<span class="arg-type">(UIDrawable)</span>:
The drawable to count
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> int: Number of times drawable appears in collection
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">UICollectionIter</span></h3>
<p>Iterator for a collection of UI objects</p>
</div>
<div class="method-section">
<h3><span class="class-name">UIEntityCollectionIter</span></h3>
<p>Iterator for a collection of UI objects</p>
</div>
<div class="method-section">
<h3><span class="class-name">Vector</span></h3>
<p>SFML Vector Object</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">magnitude()</code></h5>
<p>Calculate the length/magnitude of this vector.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> float: The magnitude of the vector
</div>
<div style="margin-left: 20px;">
<strong>Example:</strong>
<pre><code>
length = vector.magnitude()
</code></pre>
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">distance_to(other)</code></h5>
<p>Calculate the distance to another vector.</p>
<div style="margin-left: 20px;">
<span class="arg-name">other</span>
<span class="arg-type">(Vector)</span>:
The other vector
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> float: Distance between the two vectors
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">angle()</code></h5>
<p>Get the angle of this vector in radians.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> float: Angle in radians from positive x-axis
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">dot(other)</code></h5>
<p>Calculate the dot product with another vector.</p>
<div style="margin-left: 20px;">
<span class="arg-name">other</span>
<span class="arg-type">(Vector)</span>:
The other vector
</div>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> float: Dot product of the two vectors
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">normalize()</code></h5>
<p>Return a unit vector in the same direction.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> Vector: New normalized vector with magnitude 1.0
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">magnitude_squared()</code></h5>
<p>Calculate the squared magnitude of this vector.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> float: The squared magnitude (faster than magnitude())
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Use this for comparisons to avoid expensive square root calculation.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">copy()</code></h5>
<p>Create a copy of this vector.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> Vector: New Vector object with same x and y values
</div>
</div>
</div>
<div class="method-section">
<h3><span class="class-name">Window</span></h3>
<p>Window singleton for accessing and modifying the game window properties</p>
<h4>Methods:</h4>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">screenshot(filename)</code></h5>
<p>Take a screenshot and save it to a file.</p>
<div style="margin-left: 20px;">
<span class="arg-name">filename</span>
<span class="arg-type">(str)</span>:
Path where to save the screenshot
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Supports PNG, JPG, and BMP formats based on file extension.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">center()</code></h5>
<p>Center the window on the screen.</p>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> Only works if the window is not fullscreen.
</div>
</div>
<div style="margin-left: 20px; margin-bottom: 15px;">
<h5><code class="method">get()</code></h5>
<p>Get the Window singleton instance.</p>
<div style="margin-left: 20px; color: #28a745;">
<strong>Returns:</strong> Window: The singleton window object
</div>
<div style="margin-left: 20px; color: #856404;">
<strong>Note:</strong> This is a static method that returns the same instance every time.
</div>
</div>
</div>
<h2 id="automation">Automation Module</h2>
<p>The <code>mcrfpy.automation</code> module provides testing and automation capabilities.</p>
<div class="method-section">
<h4><code class="function-signature">automation.click</code></h4>
<p>Click at position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.doubleClick</code></h4>
<p>Double click at position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.dragRel</code></h4>
<p>Drag mouse relative to current position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.dragTo</code></h4>
<p>Drag mouse to position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.hotkey</code></h4>
<p>Press a hotkey combination (e.g., hotkey(&#x27;ctrl&#x27;, &#x27;c&#x27;))</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.keyDown</code></h4>
<p>Press and hold a key</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.keyUp</code></h4>
<p>Release a key</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.middleClick</code></h4>
<p>Middle click at position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.mouseDown</code></h4>
<p>Press mouse button</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.mouseUp</code></h4>
<p>Release mouse button</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.moveRel</code></h4>
<p>Move mouse relative to current position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.moveTo</code></h4>
<p>Move mouse to absolute position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.onScreen</code></h4>
<p>Check if coordinates are within screen bounds</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.position</code></h4>
<p>Get current mouse position as (x, y) tuple</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.rightClick</code></h4>
<p>Right click at position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.screenshot</code></h4>
<p>Save a screenshot to the specified file</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.scroll</code></h4>
<p>Scroll wheel at position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.size</code></h4>
<p>Get screen size as (width, height) tuple</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.tripleClick</code></h4>
<p>Triple click at position</p>
</div>
<div class="method-section">
<h4><code class="function-signature">automation.typewrite</code></h4>
<p>Type text with optional interval between keystrokes</p>
</div>
</div>
</body>
</html>