1use nightshade_api::prelude::*;
2
3fn main() {
4 let mut app = open();
5 show_grid(&mut app.world, false);
6 set_bloom(&mut app.world, true);
7 spawn_floor(&mut app.world, 12.0);
8
9 let mut gems = Vec::new();
10 for index in 0..9 {
11 let angle = index as f32 / 9.0 * std::f32::consts::TAU;
12 let gem = spawn_object(
13 &mut app.world,
14 Object {
15 shape: Shape::Sphere,
16 position: vec3(angle.cos() * 5.0, 0.6, angle.sin() * 5.0),
17 scale: vec3(0.6, 0.6, 0.6),
18 color: TEAL,
19 ..Object::default()
20 },
21 );
22 gems.push(gem);
23 }
24
25 let door = spawn_object(
26 &mut app.world,
27 Object {
28 position: vec3(0.0, 1.5, -8.0),
29 scale: vec3(4.0, 3.0, 0.4),
30 color: STEEL,
31 ..Object::default()
32 },
33 );
34
35 emit_fire(&mut app.world, vec3(0.0, 0.2, 0.0));
36 point_light(&mut app.world, vec3(0.0, 1.2, 0.0), [1.0, 0.6, 0.2], 5.0);
37 spawn_text(
38 &mut app.world,
39 "click a gem, O slides the door, B bursts",
40 ScreenAnchor::BottomLeft,
41 );
42
43 let mut door_open = false;
44 while frame(&mut app) {
45 if let Some(target) = clicked_entity(&app.world)
46 && gems.contains(&target)
47 {
48 animate_scale(
49 &mut app.world,
50 target,
51 vec3(1.0, 1.0, 1.0),
52 0.25,
53 EasingFunction::BackOut,
54 );
55 animate_color(&mut app.world, target, GOLD, 0.25, EasingFunction::QuadOut);
56 let burst_position = position(&app.world, target);
57 emit_burst(&mut app.world, burst_position, GOLD, 80);
58 shake_camera(&mut app.world, 0.08, 0.3);
59 }
60 if key_pressed(&app.world, KeyCode::KeyO) {
61 door_open = !door_open;
62 let target_height = if door_open { 4.6 } else { 1.5 };
63 animate_position(
64 &mut app.world,
65 door,
66 vec3(0.0, target_height, -8.0),
67 0.8,
68 EasingFunction::CubicInOut,
69 );
70 }
71 if key_pressed(&app.world, KeyCode::KeyB) {
72 let center = camera_position(&app.world) + camera_forward(&app.world) * 6.0;
73 emit_burst(&mut app.world, center, PINK, 200);
74 shake_camera(&mut app.world, 0.2, 0.5);
75 }
76 }
77}