nightshade-api 0.41.0

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

fn main() {
    let mut app = open();
    let cube = spawn_cube(&mut app.world, vec3(0.0, 0.5, 0.0));
    set_color(&mut app.world, cube, TEAL);

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

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