prep
pending rapier update to bevy 0.16
This commit is contained in:
71
src/plugins/game.rs
Normal file
71
src/plugins/game.rs
Normal file
@@ -0,0 +1,71 @@
|
||||
use bevy::prelude::*;
|
||||
// use bevy_rapier3d::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct GamePlugin {}
|
||||
|
||||
impl Plugin for GamePlugin {
|
||||
fn build(&self, app: &mut bevy::app::App) {
|
||||
// Todo: Pending update to bevy 0.16.0
|
||||
// app.add_plugins(RapierPhysicsPlugin::<NoUserData>::default());
|
||||
|
||||
app.add_systems(Startup, (setup_scene, spawn_ship));
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_scene(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
commands.spawn((Camera3d::default(), Transform::from_xyz(0.0, 1.3, 0.0)));
|
||||
|
||||
commands.spawn((
|
||||
DirectionalLight {
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
Transform::default().looking_to(
|
||||
Dir3::from_xyz(-1.0, -1.0, -1.0).expect("Invaid Direction for light"),
|
||||
Dir3::Y,
|
||||
),
|
||||
));
|
||||
|
||||
let cube = meshes.add(Cuboid::new(100.0, 0.1, 100.0));
|
||||
let material = materials.add(Color::WHITE);
|
||||
commands.spawn((Mesh3d(cube), MeshMaterial3d(material), Transform::default()));
|
||||
}
|
||||
|
||||
fn spawn_ship(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
let material = materials.add(Color::BLACK);
|
||||
commands.spawn((
|
||||
Mesh3d(meshes.add(Cuboid::new(3.0, 0.1, 6.0))),
|
||||
MeshMaterial3d(material.clone()),
|
||||
Name::new("Ship"),
|
||||
Transform::from_xyz(0.0, 1.0, 0.0),
|
||||
children![
|
||||
(
|
||||
Name::new("Back Wall"),
|
||||
Mesh3d(meshes.add(Cuboid::new(3.0, 2.0, 0.1))),
|
||||
MeshMaterial3d(material.clone()),
|
||||
Transform::from_xyz(0.0, 0.0, 6.0 / 2.0),
|
||||
),
|
||||
(
|
||||
Name::new("Front Wall"),
|
||||
Mesh3d(meshes.add(Cuboid::new(0.1, 2.0, 6.0))),
|
||||
MeshMaterial3d(material.clone()),
|
||||
Transform::from_xyz(3.0 / 2.0, 0.0, 0.0),
|
||||
),
|
||||
(
|
||||
Name::new("Roof"),
|
||||
Mesh3d(meshes.add(Cuboid::new(3.0, 0.1, 6.0))),
|
||||
MeshMaterial3d(material.clone()),
|
||||
Transform::from_xyz(0.0, 2.0, 0.0),
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
Reference in New Issue
Block a user