main.rs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. use bevy::prelude::*;
  2. use bevy_mod_picking::*;
  3. mod pieces;
  4. use pieces::*;
  5. mod board;
  6. use board::*;
  7. fn main() {
  8. App::build()
  9. // antialiasing at 4 samples
  10. .insert_resource(Msaa { samples: 4})
  11. // change title and size of window
  12. .insert_resource(WindowDescriptor {
  13. title: "Chess!".to_string(),
  14. width: 1600.0,
  15. height: 1000.0,
  16. ..Default::default()
  17. })
  18. .add_plugins(DefaultPlugins)
  19. .add_plugin(PickingPlugin)
  20. .add_plugin(BoardPlugin)
  21. .add_startup_system(setup.system())
  22. .add_startup_system(create_pieces.system())
  23. .run();
  24. }
  25. fn setup(
  26. mut commands: Commands,
  27. mut meshes: ResMut<Assets<Mesh>>,
  28. mut materials: ResMut<Assets<StandardMaterial>>,
  29. ) {
  30. // Camera
  31. commands.spawn_bundle(PerspectiveCameraBundle {
  32. transform: Transform::from_matrix(Mat4::from_rotation_translation(
  33. Quat::from_xyzw(-0.3, -0.5, -0.3, 0.5).normalize(),
  34. Vec3::new(-7.0, 20.0, 4.0),
  35. )),
  36. ..Default::default()
  37. })
  38. .insert_bundle(PickingCameraBundle::default());
  39. // Light
  40. commands.spawn_bundle(LightBundle {
  41. transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)),
  42. ..Default::default()
  43. });
  44. }