init
This commit is contained in:
commit
2f798e5cbc
15 changed files with 23755 additions and 0 deletions
2
assets/levels/Scene.assets.ron
Normal file
2
assets/levels/Scene.assets.ron
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
({
|
||||||
|
})
|
BIN
assets/levels/Scene.glb
Normal file
BIN
assets/levels/Scene.glb
Normal file
Binary file not shown.
5
assets/levels/Scene.meta.ron
Normal file
5
assets/levels/Scene.meta.ron
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
(
|
||||||
|
assets:
|
||||||
|
[
|
||||||
|
]
|
||||||
|
)
|
BIN
assets/materials/Dots Stroke.glb
Normal file
BIN
assets/materials/Dots Stroke.glb
Normal file
Binary file not shown.
BIN
assets/materials/Material.glb
Normal file
BIN
assets/materials/Material.glb
Normal file
Binary file not shown.
17922
assets/registry.json
Normal file
17922
assets/registry.json
Normal file
File diff suppressed because it is too large
Load diff
BIN
blend/main.blend
Normal file
BIN
blend/main.blend
Normal file
Binary file not shown.
BIN
blend/main.blend1
Normal file
BIN
blend/main.blend1
Normal file
Binary file not shown.
12
rust/.cargo/config.toml
Normal file
12
rust/.cargo/config.toml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 0
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
opt-level = 3
|
||||||
|
codegen-units = 1
|
||||||
|
incremental = false
|
||||||
|
debug = false
|
1
rust/.gitignore
vendored
Normal file
1
rust/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
5713
rust/Cargo.lock
generated
Normal file
5713
rust/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
11
rust/Cargo.toml
Normal file
11
rust/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "d6"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = { version = "0.14.2", features = ["dynamic_linking"] }
|
||||||
|
blenvy = "0.1.0-alpha.1"
|
||||||
|
rand = "0.8.5"
|
||||||
|
avian3d = "0.1.2"
|
||||||
|
bevy_editor_pls = "0.10.0"
|
1
rust/assets
Symbolic link
1
rust/assets
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../assets
|
2
rust/rustfmt.toml
Normal file
2
rust/rustfmt.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
hard_tabs = true
|
||||||
|
max_width = 120
|
86
rust/src/main.rs
Normal file
86
rust/src/main.rs
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#![allow(clippy::type_complexity)]
|
||||||
|
|
||||||
|
use avian3d::prelude::*;
|
||||||
|
use bevy::{
|
||||||
|
input::mouse::MouseMotion,
|
||||||
|
prelude::*,
|
||||||
|
window::{CursorGrabMode, PrimaryWindow},
|
||||||
|
};
|
||||||
|
use bevy_editor_pls::prelude::*;
|
||||||
|
use blenvy::{BlenvyPlugin, BlueprintInfo, GameWorldTag, SpawnBlueprint};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
App::new()
|
||||||
|
.register_type::<PlayerController>()
|
||||||
|
.add_plugins((
|
||||||
|
DefaultPlugins.set(AssetPlugin::default()),
|
||||||
|
PhysicsPlugins::default(),
|
||||||
|
BlenvyPlugin::default(),
|
||||||
|
EditorPlugin::default(),
|
||||||
|
))
|
||||||
|
.add_systems(Startup, startup)
|
||||||
|
.add_systems(Update, (update_player_mouse, update_player_keyboard))
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn startup(mut commands: Commands) {
|
||||||
|
commands.spawn((
|
||||||
|
BlueprintInfo::from_path("levels/Scene.glb"),
|
||||||
|
SpawnBlueprint,
|
||||||
|
GameWorldTag,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Component, Reflect, Default)]
|
||||||
|
#[reflect(Component)]
|
||||||
|
pub struct PlayerController;
|
||||||
|
|
||||||
|
const SENSITIVITY: f32 = 3.;
|
||||||
|
const SPEED: f32 = 10.;
|
||||||
|
|
||||||
|
fn update_player_mouse(
|
||||||
|
mut evr_motion: EventReader<MouseMotion>,
|
||||||
|
mut window: Query<&mut Window, With<PrimaryWindow>>,
|
||||||
|
mut players: Query<&mut Transform, (With<PlayerController>, With<RigidBody>)>,
|
||||||
|
) {
|
||||||
|
if let Ok(mut window) = window.get_single_mut() {
|
||||||
|
window.cursor.grab_mode = CursorGrabMode::Locked;
|
||||||
|
window.cursor.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ev in evr_motion.read() {
|
||||||
|
let x = ev.delta.x * (0.000_1 * SENSITIVITY);
|
||||||
|
let y = ev.delta.y * (0.000_1 * SENSITIVITY);
|
||||||
|
|
||||||
|
for mut transform in &mut players {
|
||||||
|
transform.rotate_local_x(-y);
|
||||||
|
transform.rotate_y(-x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_player_keyboard(
|
||||||
|
keyboard: Res<ButtonInput<KeyCode>>,
|
||||||
|
mut window: Query<&mut Window, With<PrimaryWindow>>,
|
||||||
|
mut players: Query<(&mut LinearVelocity, &Transform), (With<PlayerController>, With<RigidBody>)>,
|
||||||
|
) {
|
||||||
|
if let Ok(mut window) = window.get_single_mut() {
|
||||||
|
window.cursor.grab_mode = CursorGrabMode::Locked;
|
||||||
|
window.cursor.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut direction = Vec3::ZERO;
|
||||||
|
direction += keyboard.pressed(KeyCode::KeyW).then_some(-Vec3::Z).unwrap_or_default();
|
||||||
|
direction += keyboard.pressed(KeyCode::KeyS).then_some(Vec3::Z).unwrap_or_default();
|
||||||
|
direction += keyboard.pressed(KeyCode::KeyD).then_some(Vec3::X).unwrap_or_default();
|
||||||
|
direction += keyboard.pressed(KeyCode::KeyA).then_some(-Vec3::X).unwrap_or_default();
|
||||||
|
|
||||||
|
for (mut velocity, transform) in &mut players {
|
||||||
|
let local_forw = transform.local_z();
|
||||||
|
let local_side = transform.local_x();
|
||||||
|
let new_vel = (local_side * direction.x) + (local_forw * direction.z);
|
||||||
|
let mut new_vel = new_vel * SPEED;
|
||||||
|
new_vel.y = velocity.y;
|
||||||
|
velocity.0 = new_vel;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue