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();
    spawn_floor(&mut app.world, 20.0);

    for level in 0..6 {
        for column in 0..(6 - level) {
            spawn_object(
                &mut app.world,
                Object {
                    position: vec3(
                        column as f32 + level as f32 * 0.5 - 3.0,
                        level as f32 + 0.5,
                        0.0,
                    ),
                    color: GREEN,
                    body: Body::Dynamic { mass: 1.0 },
                    ..Object::default()
                },
            );
        }
    }

    let counter = spawn_text(&mut app.world, "shots: 0", ScreenAnchor::TopLeft);
    spawn_text(
        &mut app.world,
        "space fires a ball, click pops a block upward",
        ScreenAnchor::BottomLeft,
    );

    let mut shots = 0;
    while frame(&mut app) {
        if key_pressed(&app.world, KeyCode::Space) {
            let muzzle = camera_position(&app.world);
            let ball = spawn_object(
                &mut app.world,
                Object {
                    shape: Shape::Sphere,
                    position: muzzle,
                    scale: vec3(0.3, 0.3, 0.3),
                    color: ORANGE,
                    body: Body::Dynamic { mass: 3.0 },
                },
            );
            let velocity = camera_forward(&app.world) * 25.0;
            set_velocity(&mut app.world, ball, velocity);
            shots += 1;
            set_text(&mut app.world, counter, &format!("shots: {shots}"));
        }
        if let Some(target) = clicked_entity(&app.world) {
            push(&mut app.world, target, vec3(0.0, 6.0, 0.0));
            let pop_position = position(&app.world, target);
            emit_burst(&mut app.world, pop_position, ORANGE, 60);
            shake_camera(&mut app.world, 0.05, 0.2);
        }
    }
}