piston-dyon_interactive 0.9.0

A library for interactive coding with the Piston game engine
Documentation
/// Returns the source code of render module.
/// The render module is imported from source by default in the top module.
///
/// In loader scripts, to import the render module in loaded modules:
/// ```
/// render := unwrap(module(in: "render.dyon", string: render_source(), imports: []))
/// source := "snake.dyon"
/// m := unwrap(load(source: source, imports: [render]))
/// ```
fn render_source() -> str { ... }

/// Draws draw list.
fn draw(draw_list: [any]) { ... }

/// Returns the window size without border in points.
fn window_size() -> vec4 { ... }

/// Returns the frame buffer size in pixels.
fn window_draw_size() -> vec4 { ... }

/// Returns `true` when time to render.
fn render() -> bool { ... }

/// Returns `true` when time to update.
fn update() -> bool { ... }

/// Returns `true` when pressing a button.
fn press() -> bool { ... }

/// Returns `true` when releasing a button.
fn release() -> bool { ... }

/// Returns `true` when window receives or loses focus.
fn focus() -> bool { ... }

/// Returns `true` when there is a mouse cursor event.
fn mouse_cursor() -> bool { ... }

/// Returns:
/// - `some(true)` when window received focus.
/// - `some(false)` when window looses focus.
/// - `none` when there is no focus event.
fn focus_args() -> opt[bool] { ... }

/// Returns the position for mouse cursor event.
fn mouse_cursor_pos() -> opt[vec4] { ... }

/// Sets title of window.
fn set__title(text: str) { ... }

/// Returns the delta time for update event.
fn update_dt() -> opt[f64] { ... }

/// Returns the keyboard key for press event.
fn press_keyboard_key() -> opt[f64] { ... }

/// Returns the keyboard key for release event.
fn release_keyboard_key() -> opt[f64] { ... }

/// Returns the mouse button for press event.
fn press_mouse_button() -> opt[f64] { ... }

/// Returns the mouse button for release event.
fn release_mouse_button() -> opt[f64] { ... }

/// Returns the width of rendered text for a given font.
fn width__font_size_string(font: f64, size: f64, text: str) -> f64 { ... }

/// Returns list of font names.
fn font_names() -> [str] { ... }

/// Loads font from file.
///
/// Returns `ok(id)` when successful.
fn load_font(file: str) -> res[f64] { ... }

/// Returns list of image names.
fn image_names() -> [str] { ... }

/// Loads image from file.
///
/// Returns `ok(id)` when successful.
fn load_image(file: str) -> res[f64] { ... }

/// Saves image to file.
fn save__image_file(image: f64, file: str) -> res[str] { ... }

/// Creates empty image.
fn create_image__name_size(name: str, size: vec4) -> f64 { ... }

/// Returns image size.
fn image_size(image: f64) -> vec4 { ... }

/// Sets pixel color in image.
fn pxl__image_pos_color(image: f64, pos: vec4, color: vec4) { ... }

/// Gets pixel color from image.
fn pxl__image_pos(image: f64, pos: vec4) -> vec4 { ... }

/// Creates texture from image.
///
/// Takes an image id and returns a texture id.
fn create_texture(image: f64) -> f64 { ... }

/// Updates texture with image.
fn update__texture_image(image: f64, texture: f64) { ... }