prep
pending rapier update to bevy 0.16
This commit is contained in:
35
src/main.rs
Normal file
35
src/main.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
mod plugins;
|
||||
use bevy::{prelude::*, window::PresentMode};
|
||||
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
|
||||
use plugins::game::GamePlugin;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins
|
||||
.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
title: "Phos".into(),
|
||||
name: Some("phos".into()),
|
||||
#[cfg(debug_assertions)]
|
||||
resolution: (1920., 1080.).into(),
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
#[cfg(not(debug_assertions))]
|
||||
mode: bevy::window::WindowMode::BorderlessFullscreen,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
})
|
||||
.set(AssetPlugin {
|
||||
#[cfg(not(debug_assertions))]
|
||||
watch_for_changes_override: Some(true),
|
||||
..Default::default()
|
||||
}),
|
||||
EguiPlugin {
|
||||
enable_multipass_for_primary_context: true,
|
||||
},
|
||||
WorldInspectorPlugin::new(),
|
||||
GamePlugin::default(),
|
||||
))
|
||||
.run();
|
||||
}
|
||||
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),
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
1
src/plugins/mod.rs
Normal file
1
src/plugins/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod game;
|
||||
Reference in New Issue
Block a user