SDK 6.3/Rust/cubios
SDK 6.3 · PAWN API: Core ·
Graphics ·
Topology ·
Sound ·
Motion Sensor ·
Leaderboard ·
Splash Screen ·
Physics ·
Network ·
Save ·
Scramble ·
Logging
C++: Native API · Application · GFX Engine · Rust: Rust API (experimental) · Changelog
← SDK 6.3 · Rust / cubios (safe high-level layer)
Complete reference of the high-level layer crate cubios: a Rust port of the C++ Cubios:: classes — scene graph, screens, sprites, text, sound, scramble and splash screen. Builders are chainable; storage is heapless; everything is no_std. The crate re-exports the raw layer as cubios::sys.
Contents
- 1 high_level::screen
- 2 high_level::scene
- 3 high_level::gfx::background
- 4 high_level::gfx::sprite
- 5 high_level::gfx::animated_sprite
- 6 high_level::gfx::sprite_atlas
- 7 high_level::gfx::text
- 8 high_level::gfx::qrcode
- 9 high_level::gfx::offscreen
- 10 high_level::gfx::colors
- 11 high_level::sound
- 12 high_level::scramble
- 13 high_level::splashscreen
high_level::screen
Retained per-frame screen: begin(orientation, auto_rotation) → add(object) → end(); topology accessors.
Types: struct Screen — Per-screen rendering context. Manages rendering to a specific display, handling orientation and providing a queue for scene objects. # Type Parameters * `MAX_OBJECTS` - Maximum number of objects in the render queue (default: 16).
22 public functions:
fn new(display_id: u8) -> Self- Creates a new screen context for the specified display. # Arguments * `display_id` - Display ID (0-23, corresponding to the 24 screens).
fn display_id(&self) -> u8- Returns the display ID.
fn module(&self) -> u8- Returns the module ID.
fn screen_in_module(&self) -> u8- Returns the screen index within the module.
fn angle(&self) -> u32- Returns the current screen angle. This angle should be passed to `SceneObject::render()` for proper orientation handling.
fn orientation_mode(&self) -> TopologyOrientation- Returns the current orientation mode.
fn auto_rotation(&self) -> bool- Returns whether auto-rotation is enabled.
fn is_in_begin(&self) -> bool- Returns whether we're currently between begin() and end().
fn object_count(&self) -> usize- Returns the number of objects in the render queue.
fn begin(&mut self, mode: TopologyOrientation, auto_rotation: bool)- Begins rendering to this screen. Sets the render target and computes the screen angle based on the current topology. # Arguments * `mode` - Orientation mode for angle computation. * `auto_rotation` - Whether to auto-rotate based on topology.
fn end(&mut self)- Ends rendering to this screen. Renders all queued objects and calls `gfx::render()` to present.
fn add(&mut self, object: SceneObjectEnum) -> bool- Adds an object to the render queue. Returns `true` if successful, `false` if the queue is full.
fn remove(&mut self, index: usize) -> Option<SceneObjectEnum>- Removes an object from the render queue by index. Returns the removed object if found.
fn clear(&mut self)- Clears all objects from the render queue.
fn get(&self, index: usize) -> Option<&SceneObjectEnum>- Gets an object from the queue by index.
fn get_mut(&mut self, index: usize) -> Option<&mut SceneObjectEnum>- Gets a mutable reference to an object by index.
fn iter(&self) -> impl Iterator<Item = &SceneObjectEnum>- Iterates over all objects in the queue.
fn iter_mut(&mut self) -> impl Iterator<Item = &mut SceneObjectEnum>- Iterates mutably over all objects in the queue.
fn render_immediate(&self, object: &impl SceneObject)- Renders an object immediately without adding to queue. The object is rendered using the current screen angle. Call this between `begin()` and `end()`.
fn present(&mut self)- Renders the screen without the queue (manual mode). Use this when you want to render objects directly without using the object queue. Call `begin()`, render your objects with the screen's angle, then call `present()`.
fn for_each_screen<F>(mode: TopologyOrientation, auto_rotation: bool, mut render_fn: F) where F: FnMut(&Screen<1>),- Helper to render to all screens in a loop. This is a common pattern for WOWCube apps that render the same content to all 24 screens. # Example ```no_run use wowcube_sys::high_level::screen::for_each_screen; use wowcube_sys::high_level::gfx::Background; use wowcube_sys::high_level::scene::SceneObject; use wowcube_sys::high_level::Color; use wowcube_sys::ffi::types::TopologyOrientation; let background = Background::new(Color::rgb(0, 0, 128)); for_each_screen(TopologyOrientation::Menu, true, |screen| { background.render(screen.angle()); }); ```
fn for_face_screens<F>( face: u8, mode: TopologyOrientation, auto_rotation: bool, mut render_fn: F, ) where F: FnMut(&Screen<1>, u8), // screen, position on face (0-3)- Helper to render to screens on specific faces. Renders to the 4 screens on the specified face. # Arguments * `face` - Face index (0-5). * `mode` - Orientation mode. * `auto_rotation` - Whether to auto-rotate. * `render_fn` - Function to call for each screen.
high_level::scene
Scene<MAX_OBJECTS, MAX_SOUNDS> object registry, SceneObjectEnum, SceneObjectBase builder.
Types: trait SceneObject — Base trait for all renderable scene objects. Matches C++ SDK's `Cubios::SceneObject` virtual class pattern. All scene objects must implement this trait to be rendered. · struct SceneObjectBase — Common fields for scene objects, use via composition. This struct provides the base fields that all scene objects need. Use it via composition in your custom scene objects. · enum SceneObjectEnum — Enum wrapper for heterogeneous scene object storage (no_std compatible). Instead of using `Box<dyn SceneObject>`, this enum allows storing different scene object types in fixed-size arrays without heap allocation. · struct Scene — Scene container managing objects by ID. Matches C++ SDK's `Cubios::Scene` class. Uses fixed-size arrays for no_std compatibility. # Type Parameters - `MAX_OBJECTS`: Maximum number of scene objects (default: 32) - `MAX_SOUNDS`: Maximum number of sounds (default: 16)
28 public functions:
SceneObject::fn render(&self, screen_angle: u32)- Render this object to the current render target. Called within Screen::begin/end block. `screen_angle` is the rotation angle for auto-rotation support.
SceneObject::fn transform_mut(&mut self) -> &mut Transform- Get mutable reference to transform
SceneObject::fn transform(&self) -> &Transform- Get reference to transform
SceneObject::fn color_mut(&mut self) -> &mut Color- Get mutable reference to color
SceneObject::fn color(&self) -> &Color- Get reference to color
SceneObject::fn is_visible(&self) -> bool- Visibility flag
SceneObject::fn set_visible(&mut self, visible: bool)- Set visibility
fn at(x: f32, y: f32) -> Self- Create with position
fn with_position(mut self, x: f32, y: f32) -> Self- Set position (builder pattern)
fn with_rotation(mut self, degrees: i32) -> Self- Set rotation (builder pattern)
fn with_scale(mut self, scale: u32) -> Self- Set uniform scale (builder pattern)
fn with_color(mut self, color: Color) -> Self- Set color (builder pattern)
fn with_alpha(mut self, alpha: u8) -> Self- Set alpha (builder pattern)
fn new() -> Self- Create a new empty scene
fn create_object(&mut self, obj: SceneObjectEnum) -> Option<ObjectId>- Create object with auto-assigned ID. Returns the assigned ID, or None if the scene is full.
fn create_object_with_id(&mut self, id: ObjectId, obj: SceneObjectEnum) -> bool- Create object with specific ID. Returns false if the ID is already in use or scene is full.
fn get(&self, id: ObjectId) -> Option<&SceneObjectEnum>- Get object by ID
fn get_mut(&mut self, id: ObjectId) -> Option<&mut SceneObjectEnum>- Get mutable object by ID
fn dispose(&mut self, id: ObjectId) -> bool- Remove object by ID
fn dispose_all(&mut self)- Remove all objects
fn object_count(&self) -> usize- Get the number of objects in the scene
fn create_sound(&mut self, sound: super::sound::Sound) -> Option<u32>- Create sound with auto-assigned ID
fn create_sound_with_id(&mut self, id: u32, sound: super::sound::Sound) -> bool- Create sound with specific ID
fn play(&self, id: u32, volume: u32)- Play sound by ID
fn dispose_sound(&mut self, id: u32) -> bool- Remove sound by ID
fn iter(&self) -> impl Iterator<Item = (ObjectId, &SceneObjectEnum)>- Iterate over all objects
fn iter_mut(&mut self) -> impl Iterator<Item = (ObjectId, &mut SceneObjectEnum)>- Iterate over all objects mutably
fn compute_screen_position(pos: &Vec2, screen_angle: u32) -> Vec2- Compute screen-space position accounting for screen rotation. Used by render implementations to adjust positions based on screen orientation.
high_level::gfx::background
Full-screen fill.
Types: struct Background — Fills entire screen with solid color. This is the simplest scene object - it just clears the screen with a solid color when rendered. # Example ```no_run use wowcube_sys::high_level::gfx::Background; use wowcube_sys::high_level::Color; let bg = Background::new(Color::rgb(0, 0, 128)); // Dark blue ```
6 public functions:
fn new(color: Color) -> Self- Create a new background with the specified color.
fn from_rgb(r: u8, g: u8, b: u8) -> Self- Create a background from RGB values.
fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Self- Create a background from RGBA values.
fn black() -> Self- Create a black background.
fn white() -> Self- Create a white background.
fn with_color(mut self, color: Color) -> Self- Set color (builder pattern)
high_level::gfx::sprite
Static sprite bound to an image asset.
Types: struct Sprite — Static image sprite. Wraps a sprite resource ID and renders it with transform and color. # Example ```no_run use wowcube_sys::high_level::gfx::Sprite; let sprite = Sprite::from_name("player") .with_position(120.0, 120.0) .with_scale(200); // 2x scale ```
12 public functions:
fn from_name(name: &str) -> Self- Create from asset name (looks up ID via GFX_getAssetId).
fn from_name_at(name: &str, x: f32, y: f32) -> Self- Create from asset name with position.
fn from_id(resource_id: SpriteId) -> Self- Create from pre-resolved resource ID.
fn from_id_at(resource_id: SpriteId, x: f32, y: f32) -> Self- Create from ID with position.
fn resource_id(&self) -> SpriteId- Get the resource ID.
fn with_position(mut self, x: f32, y: f32) -> Self- Set position (builder pattern)
fn with_rotation(mut self, degrees: i32) -> Self- Set rotation in degrees (builder pattern)
fn with_scale(mut self, scale: u32) -> Self- Set uniform scale as percentage (builder pattern)
fn with_scale_xy(mut self, scale_x: u32, scale_y: u32) -> Self- Set non-uniform scale (builder pattern)
fn with_mirror(mut self, mirror: GfxMirror) -> Self- Set mirroring (builder pattern)
fn with_color(mut self, color: Color) -> Self- Set color/tint (builder pattern)
fn with_alpha(mut self, alpha: u8) -> Self- Set alpha/opacity (builder pattern)
high_level::gfx::animated_sprite
Frame animation: name list / name+range / atlas source; tick(dt), PlaybackMode.
Types: enum PlaybackMode — Animation playback mode. · struct AnimatedSprite — Animated sprite with multiple frames. Supports Loop, Bounce, and Set (manual) playback modes. # Example ```no_run use wowcube_sys::high_level::gfx::AnimatedSprite; use wowcube_sys::high_level::scene::SceneObject; let mut anim = AnimatedSprite::from_names(&["run_1", "run_2", "run_3", "run_4"]) .with_position(120.0, 120.0) .with_playback_speed(12); // 12 FPS // In game loop: let delta_time_ms = 16; let screen_angle = 0; anim.tick(delta_time_ms); anim.render(screen_angle); ```
20 public functions:
fn from_names(names: &[&str]) -> Self- Create from array of asset names.
fn from_pattern(prefix: &str, extension: &str, first: i16, last: i16) -> Self- Create from naming pattern. E.g., `from_pattern("run_", ".png", 1, 4)` loads "run_1.png" through "run_4.png"
fn from_ids(ids: &[SpriteId]) -> Self- Create from array of pre-resolved resource IDs.
fn tick(&mut self, dt: u32) -> i16- Advance animation by delta time (milliseconds). Returns the current frame index after update.
fn set_frame(&mut self, frame: i16) -> &mut Self- Set current frame directly.
fn set_playback_speed(&mut self, fps: i16) -> &mut Self- Set playback speed in frames per second.
fn set_playback_mode(&mut self, mode: PlaybackMode) -> &mut Self- Set playback mode.
fn next_frame(&mut self) -> i16- Advance to next frame manually.
fn prev_frame(&mut self) -> i16- Go to previous frame manually.
fn current_frame(&self) -> i16- Get current frame index.
fn frame_count(&self) -> u16- Get total frame count.
fn playback_speed(&self) -> i16- Get playback speed.
fn playback_mode(&self) -> PlaybackMode- Get playback mode.
fn current_resource_id(&self) -> Option<SpriteId>- Get the resource ID of the current frame.
fn with_position(mut self, x: f32, y: f32) -> Self- Set position (builder pattern)
fn with_rotation(mut self, degrees: i32) -> Self- Set rotation (builder pattern)
fn with_scale(mut self, scale: u32) -> Self- Set scale (builder pattern)
fn with_playback_speed(mut self, fps: i16) -> Self- Set playback speed (builder pattern)
fn with_playback_mode(mut self, mode: PlaybackMode) -> Self- Set playback mode (builder pattern)
fn with_color(mut self, color: Color) -> Self- Set color (builder pattern)
high_level::gfx::sprite_atlas
Sprite sheet + SpriteAtlasElement (sub-rect sprites).
Types: struct SpriteAtlasElement — A single element within a sprite atlas. Each element references a rectangular region of the parent atlas texture and can be rendered independently with its own transform and color. · struct SpriteAtlas — A sprite atlas containing multiple sprite elements from a single texture. The atlas manages a collection of elements, each defined by a rectangular region within the atlas texture. This is more efficient than loading multiple separate textures. # Type Parameters * `MAX_ELEMENTS` - Maximum number of elements the atlas can hold (default: 64).
26 public functions:
fn new(atlas_id: SpriteId, region: Rect2) -> Self- Creates a new atlas element with the given region.
fn atlas_id(&self) -> SpriteId- Returns the atlas texture ID.
fn region(&self) -> Rect2- Returns the region within the atlas.
fn set_region(&mut self, region: Rect2)- Sets the region within the atlas.
fn with_position(mut self, x: f32, y: f32) -> Self- Builder: set position.
fn with_rotation(mut self, degrees: i32) -> Self- Builder: set rotation in degrees.
fn with_scale(mut self, scale: u32) -> Self- Builder: set uniform scale.
fn with_scale_xy(mut self, scale_x: u32, scale_y: u32) -> Self- Builder: set non-uniform scale.
fn with_mirror(mut self, mirror: GfxMirror) -> Self- Builder: set mirroring.
fn with_color(mut self, color: Color) -> Self- Builder: set color (affects tinting).
fn with_alpha(mut self, alpha: u8) -> Self- Builder: set alpha (opacity).
fn from_name(name: &str) -> Self- Creates a new sprite atlas from an asset name.
fn from_id(texture_id: SpriteId) -> Self- Creates a new sprite atlas from an existing sprite ID.
fn texture_id(&self) -> SpriteId- Returns the atlas texture ID.
fn len(&self) -> usize- Returns the number of elements in the atlas.
fn is_empty(&self) -> bool- Returns true if the atlas has no elements.
fn add_element(&mut self, id: u32, region: Rect2) -> bool- Adds an element to the atlas with the given ID and region. Returns `true` if successful, `false` if the atlas is full or an element with that ID already exists.
fn add_element_with(&mut self, id: u32, mut element: SpriteAtlasElement) -> bool- Adds an element with a pre-configured SpriteAtlasElement. The element's atlas_id will be overwritten with this atlas's texture_id.
fn get(&self, id: u32) -> Option<&SpriteAtlasElement>- Gets an element by ID.
fn get_mut(&mut self, id: u32) -> Option<&mut SpriteAtlasElement>- Gets a mutable reference to an element by ID.
fn remove(&mut self, id: u32) -> Option<SpriteAtlasElement>- Removes an element by ID. Returns the removed element if found.
fn clear(&mut self)- Removes all elements from the atlas.
fn render_all(&self, screen_angle: u32)- Renders all visible elements in the atlas.
fn iter(&self) -> impl Iterator<Item = (u32, &SpriteAtlasElement)>- Iterates over all elements in the atlas.
fn iter_mut(&mut self) -> impl Iterator<Item = (u32, &mut SpriteAtlasElement)>- Iterates mutably over all elements in the atlas.
fn add_grid( &mut self, start_id: u32, cols: u16, rows: u16, cell_width: i16, cell_height: i16, offset_x: i16, offset_y: i16, ) -> usize- Adds elements from a regular grid layout. # Arguments * `start_id` - Starting ID for the first element * `cols` - Number of columns in the grid * `rows` - Number of rows in the grid * `cell_width` - Width of each cell * `cell_height` - Height of each cell * `offset_x` - X offset from the top-left of the texture * `offset_y` - Y offset from the top-left of the texture # Returns Number of elements successfully added.
high_level::gfx::text
Text label (content, font size, alignment, color).
Types: struct Text — Text label with font size and alignment. Uses `heapless::String` for no_std compatibility. # Example ```no_run use wowcube_sys::high_level::gfx::Text; use wowcube_sys::ffi::types::TextAlign; let text = Text::new("Score: 100") .with_position(120.0, 120.0) .with_font_size(12) .with_alignment(TextAlign::Center); ```
14 public functions:
fn new(content: &str) -> Self- Create new text with content.
fn at(content: &str, x: f32, y: f32) -> Self- Create text at position.
fn set_content(&mut self, content: &str)- Set content (replaces existing).
fn content(&self) -> &str- Get current content.
fn with_font_size(mut self, size: u32) -> Self- Set font size (builder pattern)
fn with_alignment(mut self, align: TextAlign) -> Self- Set alignment (builder pattern)
fn with_position(mut self, x: f32, y: f32) -> Self- Set position (builder pattern)
fn with_rotation(mut self, degrees: i32) -> Self- Set rotation (builder pattern)
fn with_color(mut self, color: Color) -> Self- Set color (builder pattern)
fn font_size(&self) -> u32- Get font size.
fn set_font_size(&mut self, size: u32)- Set font size.
fn alignment(&self) -> TextAlign- Get alignment.
fn set_alignment(&mut self, align: TextAlign)- Set alignment.
fn format(&mut self, args: core::fmt::Arguments<'_>)- Format content using core::fmt. Note: This clears existing content and writes new formatted text.
high_level::gfx::qrcode
QR-code object (data, size, colors).
Types: struct QRCode — QR code scene object. Renders a QR code with customizable colors and size. # Example ```no_run use wowcube_sys::high_level::gfx::QRCode; use wowcube_sys::ffi::math::Color; let qr = QRCode::new("https://wowcube.com") .with_position(120.0, 120.0) .with_size(100) .with_colors(Color::from_u32(0xFF000000), Color::from_u32(0xFFFFFFFF)); ```
14 public functions:
fn new(data: &str) -> Self- Create a new QR code with the given data.
fn at(data: &str, x: f32, y: f32) -> Self- Create at a specific position.
fn with_size(mut self, size: u32) -> Self- Set the QR code size (builder pattern).
fn with_colors(mut self, zeros: Color, ones: Color) -> Self- Set the colors (builder pattern). - `zeros`: Background color (usually white) - `ones`: Foreground/data color (usually black)
fn with_background_color(mut self, color: Color) -> Self- Set the background color (zeros).
fn with_foreground_color(mut self, color: Color) -> Self- Set the foreground/data color (ones).
fn with_position(mut self, x: f32, y: f32) -> Self- Set position (builder pattern).
fn with_rotation(mut self, degrees: i32) -> Self- Set rotation in degrees (builder pattern).
fn data(&self) -> &str- Get the QR code data.
fn set_data(&mut self, data: &str)- Set new QR code data.
fn size(&self) -> u32- Get the size.
fn set_size(&mut self, size: u32)- Set the size.
fn color_zeros(&self) -> Color- Get the background color.
fn color_ones(&self) -> Color- Get the foreground color.
high_level::gfx::offscreen
Offscreen render target (bake once, draw as an object).
Types: struct OffscreenRenderTarget — Offscreen render target for render-to-texture operations. The render target creates a texture buffer that can be drawn to and then rendered as a regular sprite. This is managed automatically: - The buffer is created when `begin()` is first called - The buffer is cleaned up when the target is dropped # Render Layer Order The C++ SDK has `RenderLayer(order)` for before/after queue rendering. In this simplified Rust version, manual control of render order is achieved by calling `draw()` at the appropriate time.
15 public functions:
fn new(width: u32, height: u32) -> Self- Creates a new offscreen render target with the specified dimensions. Uses ARGB8888 format by default for full alpha support.
fn with_format(width: u32, height: u32, format: GfxPixelFormat) -> Self- Creates a new offscreen render target with a specific pixel format.
fn id(&self) -> SpriteId- Returns the render target's unique ID.
fn width(&self) -> u32- Returns the width of the render target.
fn height(&self) -> u32- Returns the height of the render target.
fn is_created(&self) -> bool- Returns whether the render target has been created.
fn is_in_render(&self) -> bool- Returns whether we're currently rendering to this target.
fn begin(&mut self, overwrite: bool) -> Result<(), i32>- Begins rendering to this offscreen target. All subsequent draw calls will render to this buffer until `end()` is called. # Arguments * `overwrite` - If true, clears the buffer. If false, preserves existing content. # Returns `Ok(())` on success, `Err(i32)` with the error code on failure.
fn end(&mut self)- Ends rendering to this offscreen target. After calling this, the buffer contains the rendered content and can be drawn using `draw()` or the `SceneObject` trait.
fn draw(&self, x: i32, y: i32, screen_angle: u32)- Draws the offscreen buffer to the screen at the specified position. # Arguments * `x` - X position on screen * `y` - Y position on screen * `screen_angle` - Current screen orientation angle
fn with_position(mut self, x: f32, y: f32) -> Self- Builder: set position.
fn with_rotation(mut self, degrees: i32) -> Self- Builder: set rotation in degrees.
fn with_scale(mut self, scale: u32) -> Self- Builder: set uniform scale.
fn with_scale_xy(mut self, scale_x: u32, scale_y: u32) -> Self- Builder: set non-uniform scale.
fn with_alpha(mut self, alpha: u8) -> Self- Builder: set alpha (opacity).
high_level::gfx::colors
142 named colors as u32 ARGB constants + Color helpers.
Types: struct Colors — Named color constants matching the C++ SDK's `Cubios::Gfx::Colors` enum. All colors are fully opaque (alpha = 0xFF) unless otherwise noted. # Example ```no_run use wowcube_sys::high_level::gfx::Colors; use wowcube_sys::ffi::math::Color; let red = Colors::RED; let custom = Colors::from_u32(Colors::BLUE); ```
142 named colors (Colors::NAME, ARGB u32):
ALICE_BLUEANTIQUE_WHITEAQUAAQUAMARINEAZUREBEIGEBISQUEBLACKBLANCHED_ALMONDBLUEBLUE_VIOLETBROWNBURLY_WOODCADET_BLUECHARTREUSECHOCOLATECORALCORNFLOWER_BLUECORNSILKCRIMSONCYANDARK_BLUEDARK_CYANDARK_GOLDENRODDARK_GRAYDARK_GREENDARK_KHAKIDARK_MAGENTADARK_OLIVE_GREENDARK_ORANGEDARK_ORCHIDDARK_REDDARK_SALMONDARK_SEA_GREENDARK_SLATE_BLUEDARK_SLATE_GRAYDARK_TURQUOISEDARK_VIOLETDEEP_PINKDEEP_SKY_BLUEDIM_GRAYDODGER_BLUEFIREBRICKFLORAL_WHITEFOREST_GREENFUCHSIAGAINSBOROGHOST_WHITEGOLDGOLDENRODGRAYGREENGREEN_YELLOWGREYHONEYDEWHOT_PINKINDIAN_REDINDIGOIVORYKHAKILAVENDERLAVENDER_BLUSHLAWN_GREENLEMON_CHIFFONLIGHT_BLUELIGHT_CORALLIGHT_CYANLIGHT_GOLDENROD_YELLOWLIGHT_GRAYLIGHT_GREENLIGHT_PINKLIGHT_SALMONLIGHT_SEA_GREENLIGHT_SKY_BLUELIGHT_SLATE_GRAYLIGHT_STEEL_BLUELIGHT_YELLOWLIMELIME_GREENLINENMAGENTAMAROONMEDIUM_AQUAMARINEMEDIUM_BLUEMEDIUM_ORCHIDMEDIUM_PURPLEMEDIUM_SEA_GREENMEDIUM_SLATE_BLUEMEDIUM_SPRING_GREENMEDIUM_TURQUOISEMEDIUM_VIOLET_REDMIDNIGHT_BLUEMINT_CREAMMISTY_ROSEMOCCASINNAVAJO_WHITENAVYOLD_LACEOLIVEOLIVE_DRABORANGEORANGE_REDORCHIDPALE_GOLDENRODPALE_GREENPALE_TURQUOISEPALE_VIOLET_REDPAPAYA_WHIPPEACH_PUFFPERUPINKPLUMPOWDER_BLUEPURPLEREDROSY_BROWNROYAL_BLUESADDLE_BROWNSALMONSANDY_BROWNSEA_GREENSEA_SHELLSIENNASILVERSKY_BLUESLATE_BLUESLATE_GRAYSNOWSPRING_GREENSTEEL_BLUETANTEALTHISTLETOMATOTRANSPARENTTURQUOISEVIOLETWHEATWHITEWHITE_SMOKEYELLOWYELLOW_GREENhigh_level::sound
Sound + SoundCollection (random playback, repeat with random delays).
Types: struct Sound — A single sound asset. Wraps a sound ID and provides convenient playback methods. · struct SoundCollection — A collection of sounds with random playback support. Useful for sound effects that should vary (footsteps, hits, etc.).
21 public functions:
fn from_name(name: &str) -> Self- Creates a sound from an asset name. Looks up the asset ID at creation time.
fn from_id(id: SoundId) -> Self- Creates a sound from an existing sound ID.
fn id(&self) -> SoundId- Returns the sound's asset ID.
fn play(&self, volume: u32) -> i32- Plays the sound at the specified volume. # Arguments * `volume` - Volume level (0-100). # Returns The result code from the sound system.
fn play_full(&self) -> i32- Plays the sound at full volume (100).
fn stop_all() -> i32- Stops all currently playing sounds. Note: This stops ALL sounds, not just this one.
fn is_any_playing() -> bool- Returns whether any sound is currently playing.
fn new() -> Self- Creates an empty sound collection.
fn from_names(names: &[&str]) -> Self- Creates a sound collection from an array of asset names.
fn from_ids(ids: &[SoundId]) -> Self- Creates a sound collection from an array of sound IDs.
fn len(&self) -> usize- Returns the number of sounds in the collection.
fn is_empty(&self) -> bool- Returns whether the collection is empty.
fn add(&mut self, sound: Sound) -> bool- Adds a sound to the collection. Returns `true` if successful, `false` if the collection is full.
fn get(&self, index: usize) -> Option<&Sound>- Gets a sound by index.
fn remove(&mut self, index: usize) -> Option<Sound>- Removes a sound by index.
fn clear(&mut self)- Clears all sounds from the collection.
fn play_random(&mut self, volume: u32) -> Option<usize>- Plays a random sound from the collection. Tries to avoid playing the same sound twice in a row. # Arguments * `volume` - Volume level (0-100). # Returns The index of the played sound, or `None` if collection is empty.
fn play_random_full(&mut self) -> Option<usize>- Plays a random sound at full volume.
fn repeat_random( &mut self, min_delay: i32, max_delay: i32, volume: u32, dt: i32, ) -> Option<usize>- Repeats random sounds at intervals. Call this every frame with the delta time. When the delay expires, a random sound is played and a new delay is set. # Arguments * `min_delay` - Minimum delay in milliseconds between sounds. * `max_delay` - Maximum delay in milliseconds between sounds. * `volume` - Volume level (0-100). * `dt` - Delta time in milliseconds since last call. # Returns The index of the played sound if one was played this frame.
fn reset_delay(&mut self)- Resets the repeat delay counter.
fn cache_all(&self)- Caches all sounds in the collection for faster playback.
high_level::scramble
Scramble / SimpleScramble cube-scramble helpers with mapping callbacks.
Types: trait ScrambleObserver — Observer trait for scramble events. Implement this trait to receive callbacks when the cube topology changes. · struct FaceletPosition — Facelet position tracking for a single facelet. · struct Scramble — Tracks facelet positions across cube twists. This struct maintains a mapping of where each facelet has moved to as the cube is twisted. It can be used to implement scramble-based puzzles or effects that follow facelets as they move. · struct SimpleScramble — Simple scramble tracker without observer callbacks. A lighter-weight version of `Scramble` for when you don't need the observer pattern.
23 public functions:
ScrambleObserver::fn on_before_twist(&mut self)- Called before a twist is about to occur. Use this to save state that might be affected by the twist.
ScrambleObserver::fn on_mapping_changed( &mut self, _to_module: u8, _to_screen: u8, _from_module: u8, _from_screen: u8, )- Called when a facelet mapping changes during a twist. # Arguments * `to_module` - Destination module ID. * `to_screen` - Destination screen ID within module. * `from_module` - Source module ID. * `from_screen` - Source screen ID within module.
fn new(module: u8, screen: u8) -> Self- Creates a new facelet position.
fn to_display_id(&self) -> u8- Converts to a linear display ID (0-23).
fn from_display_id(display_id: u8) -> Self- Creates from a linear display ID.
fn new() -> Self- Creates a new scramble tracker with identity mapping. Initially, each facelet is at its "home" position.
fn reset(&mut self)- Resets all positions to identity (home positions).
fn is_assembled(&self) -> bool- Returns whether the cube is currently assembled.
fn get_position(&self, original_display_id: u8) -> Option<FaceletPosition>- Returns the current position of a facelet by its original display ID.
fn get_previous_position(&self, original_display_id: u8) -> Option<FaceletPosition>- Returns the previous position of a facelet (before last twist).
fn last_twist(&self) -> Option<&TopologyTwistInfo>- Returns the last recorded twist info.
fn is_solved(&self) -> bool- Checks if all facelets are in their home positions.
fn count_home(&self) -> usize- Counts how many facelets are in their home positions.
fn update<O: ScrambleObserver>(&mut self, mut observer: Option<&mut O>)- Updates the scramble state based on current topology. Call this each frame or after twist events to keep tracking current. # Arguments * `observer` - Optional observer to receive callbacks.
fn positions(&self) -> &[FaceletPosition; 24]- Gets all positions as a slice.
fn previous_positions(&self) -> &[FaceletPosition; 24]- Gets previous positions as a slice.
fn new() -> Self- Creates a new simple scramble tracker.
fn reset(&mut self)- Resets to identity positions.
fn update(&mut self)- Updates based on current topology (no callbacks).
fn is_assembled(&self) -> bool- Returns whether the cube is assembled.
fn is_solved(&self) -> bool- Returns whether all facelets are home.
fn get_position(&self, original_display_id: u8) -> Option<FaceletPosition>- Gets the current position of a facelet.
fn last_twist(&self) -> Option<&TopologyTwistInfo>- Gets the last twist info.
high_level::splashscreen
Standard splash screen with leaderboard table, records, QR link.
Types: enum LeadersDataType — Data type for leaderboard values. · enum ScreenType — Screen type for each position on the splashscreen. · enum LeaderboardType — Preset leaderboard table layouts. · struct LeaderData — Data for a single leader entry. · struct ResultData — Data for a result parameter display. · struct RecordData — Data for the record/best score display. · struct SplashSprites — Sprite IDs for splashscreen graphics. · struct Splashscreen — Splashscreen display manager. Manages the layout and rendering of leaderboard and splash content across the cube's faces.
17 public functions:
fn new(name: &str, value: i32) -> Self- Creates a new leader entry.
fn empty() -> Self- Creates an empty/invalid entry.
fn new(name: &str, value: i32) -> Self- Creates a new result parameter.
fn new(value: i32, is_new: bool) -> Self- Creates new record data.
fn from_names( background: Option<&str>, game_icon: Option<&str>, trophy: Option<&str>, ) -> Self- Creates sprites from asset names.
fn set_animated_icon(&mut self, index: usize, name: &str)- Sets an animated icon sprite.
fn new() -> Self- Creates a new splashscreen with default settings.
fn set_data_type(&mut self, data_type: LeadersDataType)- Sets the data type for value formatting.
fn set_leader(&mut self, index: usize, name: &str, value: i32)- Sets a leader entry.
fn clear_leaders(&mut self)- Clears all leader entries.
fn set_record(&mut self, value: i32, is_new: bool)- Sets the record value.
fn set_param(&mut self, index: usize, name: &str, value: i32)- Sets a result parameter.
fn set_qr_text(&mut self, text: &str)- Sets the QR code text.
fn set_leaderboard_table(&mut self, table: [[ScreenType; 4]; 6])- Sets the leaderboard table layout.
fn apply_preset(&mut self, preset: LeaderboardType)- Applies a preset leaderboard layout.
fn tick(&mut self, dt: f32)- Updates animation state. # Arguments * `dt` - Delta time in seconds.
fn render_screen_type(&self, screen_type: ScreenType, screen_angle: u32, x: i32, y: i32)- Renders a specific screen type. # Arguments * `screen_type` - The type of content to render. * `screen_angle` - Screen orientation angle. * `x` - X position. * `y` - Y position.