forked from guimcaballero/bevy_chess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
49 lines (46 loc) · 1.35 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
use bevy::prelude::*;
use bevy_mod_picking::*;
mod pieces;
use pieces::*;
mod board;
use board::*;
mod ui;
use ui::*;
fn main() {
App::build()
// Set antialiasing to use 4 samples
.insert_resource(Msaa { samples: 4 })
// Set WindowDescriptor Resource to change title and size
.insert_resource(WindowDescriptor {
title: "Chess!".to_string(),
width: 600.,
height: 600.,
..Default::default()
})
.add_plugins(DefaultPlugins)
.init_resource::<PickingCamera>()
.add_plugin(PickingPlugin)
.add_plugin(BoardPlugin)
.add_plugin(PiecesPlugin)
.add_plugin(UIPlugin)
.add_startup_system(setup.system())
.run();
}
fn setup(mut commands: Commands) {
commands
// Camera
.spawn_bundle(PerspectiveCameraBundle {
transform: Transform::from_matrix(Mat4::from_rotation_translation(
Quat::from_xyzw(-0.3, -0.5, -0.3, 0.5).normalize(),
Vec3::new(-7.0, 20.0, 4.0),
)),
..Default::default()
})
.insert_bundle(PickingCameraBundle::default())
// Light
.commands()
.spawn_bundle(LightBundle {
transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)),
..Default::default()
});
}