prep
pending rapier update to bevy 0.16
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/target
|
||||||
6126
Cargo.lock
generated
Normal file
6126
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
Cargo.toml
Normal file
20
Cargo.toml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[package]
|
||||||
|
name = "space-game"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = { version = "0.16.0", features = ["file_watcher"] }
|
||||||
|
# bevy_rapier3d = { version = "0.29.0", features = ["simd-stable", "parallel"] }
|
||||||
|
bevy-inspector-egui = "0.31.0"
|
||||||
|
|
||||||
|
# Enable a small amount of optimization in debug mode
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 1
|
||||||
|
|
||||||
|
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
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