-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
58 lines (49 loc) · 1.69 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
mod agent;
mod controller_ai;
mod controller_human;
mod environment;
mod experience;
mod graph;
mod model;
mod particle;
mod util;
use bevy::{prelude::*, window::WindowResolution};
use environment::*;
use graph::GraphPlugin;
const WINDOW_ZOOM: f32 = 2.0; // Affects only visually the scale of the window, adding zoom to camera.
fn main() {
let human_controller = false;
let mut app = App::default();
app.insert_resource(ClearColor(Color::BLACK));
app.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
resolution: WindowResolution::new(VIEWPORT_W * WINDOW_ZOOM, VIEWPORT_H * WINDOW_ZOOM),
..Default::default()
}),
..Default::default()
}));
app.add_plugins(EnvironmentPlugin::default());
app.add_plugins(GraphPlugin);
if human_controller {
app.add_systems(PostEnvResetSchedule, controller_human::env_post_reset);
app.add_systems(AvailableUpdateSchedule, controller_human::env_pre_step);
app.add_systems(PostEnvStepSchedule, controller_human::env_post_step);
} else {
app.add_systems(PostEnvResetSchedule, controller_ai::env_post_reset);
app.add_systems(AvailableUpdateSchedule, controller_ai::env_pre_step);
app.add_systems(PostEnvStepSchedule, controller_ai::env_post_step);
}
app.add_systems(PostStartup, common_init);
app.run();
}
fn common_init(mut commands: Commands) {
// Create camera
commands.spawn(Camera2dBundle {
transform: Transform::from_scale(Vec3::new(
1.0 / SCALE / WINDOW_ZOOM,
1.0 / SCALE / WINDOW_ZOOM,
1.0 / SCALE / WINDOW_ZOOM,
)),
..Default::default()
});
}