Made building with dynamic linking (mold + clang) optional, testing code's framerate dependency
This commit is contained in:
parent
68c30e369d
commit
d20f208bf7
5 changed files with 29 additions and 12 deletions
9
.vscode/launch.json
vendored
9
.vscode/launch.json
vendored
|
|
@ -12,7 +12,14 @@
|
||||||
"name": "Build and Run program",
|
"name": "Build and Run program",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"type": "node-terminal"
|
"type": "node-terminal"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"command": "nix-shell --run 'cargo run --features bevy/dynamic_linking'",
|
||||||
|
"name": "Mold build and run program",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
},
|
||||||
|
|
||||||
],
|
],
|
||||||
"compounds": []
|
"compounds": []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -313,7 +313,6 @@ version = "0.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea370412c322af887c9115442d8f2ec991b652f163a1d8920ecaf08cae63f2bc"
|
checksum = "ea370412c322af887c9115442d8f2ec991b652f163a1d8920ecaf08cae63f2bc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy_dylib",
|
|
||||||
"bevy_internal",
|
"bevy_internal",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ opt-level = 3
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.13.1", features = ["wayland", "dynamic_linking"]}
|
bevy = { version = "0.13.1", features = ["wayland"]}
|
||||||
bevy_dylib = "0.13.1"
|
bevy_dylib = "0.13.1"
|
||||||
bevy_editor_pls = "0.8.1"
|
bevy_editor_pls = "0.8.1"
|
||||||
bevy_xpbd_3d = {git = "https://git.opencodebox.com/MikolajG/bevy_xpbd", branch = "reflect-serialize"}
|
bevy_xpbd_3d = {git = "https://git.opencodebox.com/MikolajG/bevy_xpbd", branch = "reflect-serialize"}
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,11 @@ pub struct CharacterControllerPlugin;
|
||||||
impl Plugin for CharacterControllerPlugin{
|
impl Plugin for CharacterControllerPlugin{
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(Update,(
|
app.add_systems(Update,(
|
||||||
update_grounded,
|
|
||||||
keyboard_input,
|
keyboard_input,
|
||||||
move_character,
|
)
|
||||||
dampen_movement)
|
|
||||||
);
|
);
|
||||||
|
app.add_systems(FixedUpdate, (move_character,
|
||||||
|
dampen_movement,update_grounded));
|
||||||
app.add_event::<MovementAction>();
|
app.add_event::<MovementAction>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -164,16 +164,16 @@ pub fn move_character(
|
||||||
let angle = rotation.rotate(-hit.normal2).angle_between(Vector::Y).abs();
|
let angle = rotation.rotate(-hit.normal2).angle_between(Vector::Y).abs();
|
||||||
if angle <= character_controller.max_slope_angle {
|
if angle <= character_controller.max_slope_angle {
|
||||||
slope_factor *= (angle / character_controller.max_slope_angle).cos();
|
slope_factor *= (angle / character_controller.max_slope_angle).cos();
|
||||||
|
velocity.x += direction.x * character_controller.movement_acceleration * slope_factor * delta_time;
|
||||||
|
velocity.z -= direction.y * character_controller.movement_acceleration * slope_factor * delta_time;
|
||||||
} else {
|
} else {
|
||||||
velocity.x = 0.0;
|
velocity.x = 0.0;
|
||||||
velocity.z = 0.0;
|
velocity.z = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
velocity.x += direction.x * character_controller.movement_acceleration * delta_time * slope_factor;
|
|
||||||
velocity.z -= direction.y * character_controller.movement_acceleration * delta_time * slope_factor;
|
|
||||||
} else {
|
} else {
|
||||||
velocity.x += direction.x * character_controller.movement_acceleration * delta_time * character_controller.air_control_factor;
|
velocity.x += direction.x * character_controller.movement_acceleration * character_controller.air_control_factor * delta_time ;
|
||||||
velocity.z -= direction.y * character_controller.movement_acceleration * delta_time * character_controller.air_control_factor;
|
velocity.z -= direction.y * character_controller.movement_acceleration * character_controller.air_control_factor * delta_time ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MovementAction::Jump => {
|
MovementAction::Jump => {
|
||||||
|
|
|
||||||
15
src/main.rs
15
src/main.rs
|
|
@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::{diagnostic::FrameTimeDiagnosticsPlugin, prelude::*, window::Cursor};
|
||||||
use bevy_xpbd_3d::prelude::*;
|
use bevy_xpbd_3d::prelude::*;
|
||||||
use bevy_editor_pls::prelude::*;
|
use bevy_editor_pls::prelude::*;
|
||||||
mod charcacter_controller;
|
mod charcacter_controller;
|
||||||
|
|
@ -26,9 +26,20 @@ fn main() {
|
||||||
|
|
||||||
app
|
app
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins,
|
DefaultPlugins.set(WindowPlugin {
|
||||||
|
primary_window: Some(Window {
|
||||||
|
cursor: Cursor::default(),
|
||||||
|
present_mode: bevy::window::PresentMode::AutoNoVsync,
|
||||||
|
mode: bevy::window::WindowMode::Windowed,
|
||||||
|
title: "Trouble in Terror Town: Community Edition".to_string(),
|
||||||
|
resizable: true,
|
||||||
|
..default()
|
||||||
|
}),
|
||||||
|
..default()
|
||||||
|
}),
|
||||||
PhysicsPlugins::default(),
|
PhysicsPlugins::default(),
|
||||||
EditorPlugin::default(),
|
EditorPlugin::default(),
|
||||||
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
CharacterControllerPlugin,
|
CharacterControllerPlugin,
|
||||||
))
|
))
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue