nightshade-api 0.43.0

Procedural high level API for the nightshade game engine
Documentation
use nightshade_api::prelude::*;

struct Hud {
    cube: Entity,
    fps_text: Entity,
    grid: bool,
    bloom: bool,
}

fn main() {
    run(
        |world| {
            let cube = spawn_cube(world, vec3(0.0, 0.5, 0.0));
            set_color(world, cube, TEAL);

            let fps_text = spawn_text(world, "fps: 0", ScreenAnchor::TopLeft);
            spawn_text(
                world,
                "G grid, B bloom, 1 sky, 2 night, 3 black",
                ScreenAnchor::BottomLeft,
            );

            Hud {
                cube,
                fps_text,
                grid: true,
                bloom: false,
            }
        },
        |world, hud| {
            let step = delta_time(world);
            rotate(world, hud.cube, Vec3::y(), step);
            let frames_per_second = world.resources.window.timing.frames_per_second;
            set_text(world, hud.fps_text, &format!("fps: {frames_per_second:.0}"));
            if key_pressed(world, KeyCode::KeyG) {
                hud.grid = !hud.grid;
                show_grid(world, hud.grid);
            }
            if key_pressed(world, KeyCode::KeyB) {
                hud.bloom = !hud.bloom;
                set_bloom(world, hud.bloom);
            }
            if key_pressed(world, KeyCode::Digit1) {
                set_background(world, Background::Sky);
            }
            if key_pressed(world, KeyCode::Digit2) {
                set_background(world, Background::Color([0.02, 0.01, 0.08, 1.0]));
            }
            if key_pressed(world, KeyCode::Digit3) {
                set_background(world, Background::Color(BLACK));
            }
        },
    )
    .unwrap();
}