nightshade-api 0.42.0

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

fn main() {
    let mut app = open();
    show_grid(&mut app.world, false);
    set_bloom(&mut app.world, true);
    spawn_floor(&mut app.world, 12.0);

    let mut gems = Vec::new();
    for index in 0..9 {
        let angle = index as f32 / 9.0 * std::f32::consts::TAU;
        let gem = spawn_object(
            &mut app.world,
            Object {
                shape: Shape::Sphere,
                position: vec3(angle.cos() * 5.0, 0.6, angle.sin() * 5.0),
                scale: vec3(0.6, 0.6, 0.6),
                color: TEAL,
                ..Object::default()
            },
        );
        gems.push(gem);
    }

    let door = spawn_object(
        &mut app.world,
        Object {
            position: vec3(0.0, 1.5, -8.0),
            scale: vec3(4.0, 3.0, 0.4),
            color: STEEL,
            ..Object::default()
        },
    );

    emit_fire(&mut app.world, vec3(0.0, 0.2, 0.0));
    point_light(&mut app.world, vec3(0.0, 1.2, 0.0), [1.0, 0.6, 0.2], 5.0);
    spawn_text(
        &mut app.world,
        "click a gem, O slides the door, B bursts",
        ScreenAnchor::BottomLeft,
    );

    let mut door_open = false;
    while frame(&mut app) {
        if let Some(target) = clicked_entity(&app.world)
            && gems.contains(&target)
        {
            animate_scale(
                &mut app.world,
                target,
                vec3(1.0, 1.0, 1.0),
                0.25,
                EasingFunction::BackOut,
            );
            animate_color(&mut app.world, target, GOLD, 0.25, EasingFunction::QuadOut);
            let burst_position = position(&app.world, target);
            emit_burst(&mut app.world, burst_position, GOLD, 80);
            shake_camera(&mut app.world, 0.08, 0.3);
        }
        if key_pressed(&app.world, KeyCode::KeyO) {
            door_open = !door_open;
            let target_height = if door_open { 4.6 } else { 1.5 };
            animate_position(
                &mut app.world,
                door,
                vec3(0.0, target_height, -8.0),
                0.8,
                EasingFunction::CubicInOut,
            );
        }
        if key_pressed(&app.world, KeyCode::KeyB) {
            let center = camera_position(&app.world) + camera_forward(&app.world) * 6.0;
            emit_burst(&mut app.world, center, PINK, 200);
            shake_camera(&mut app.world, 0.2, 0.5);
        }
    }
}