juke

Crates.iojuke
lib.rsjuke
version0.0.12
sourcesrc
created_at2022-05-15 01:39:41.248001
updated_at2022-05-22 04:02:05.342854
description🤖 A small engine for prototyping projects
homepage
repositoryhttps://github.com/BumpyBill/juke/
max_upload_size
id586855
size59,406
bumpy (BumpyBill)

documentation

https://docs.rs/juke

README

Version Documentation

🤖 A small engine for prototyping projects

Usage

# Cargo.toml
[dependencies]
juke = "0.0.12"

Example

use juke::{egui::Context, resources::ResourceManager, *};
use std::time::Duration;

fn main() {
    Engine::new("Hello, World! - ESC to exit", 256, 144, 4)
        .ui(ui)
        .run(update);
}

fn update(f: FrameContext, resources: &mut ResourceManager) {
    for pixel in f.buffer.chunks_exact_mut(4) {
        pixel[0] = 0xff; // R
        pixel[1] = 0x00; // G
        pixel[2] = 0xff; // B
        pixel[3] = 0xff; // A
    }

    resources.set("frame_time", f.delta);
}

fn ui(ctx: &Context, resources: &mut ResourceManager) {
    egui::Window::new("Hello, egui!").show(ctx, |ui| {
        ui.label("This example demonstrates using egui with juke.");

        ui.separator();

        ui.horizontal(|ui| {
            let delta = resources.get::<Duration>("frame_time").unwrap();

            ui.spacing_mut().item_spacing.x /= 2.0;
            ui.label(format!("Frame Time: {:?}", delta));
            ui.label(format!("FPS: {}", 1. / delta.as_secs_f32()));
        });
    });
}

Commit count: 0

cargo fmt