improvement: better movement

This commit is contained in:
timokoesters 2020-01-17 21:08:27 +01:00 committed by Pfauenauge90
parent c10c31043c
commit 8064b51ee2
6 changed files with 13 additions and 17 deletions

View File

@ -39,7 +39,7 @@ pub struct DeltaTime(pub f32);
/// upper limit. If delta time exceeds this value, the game's physics will begin to produce time
/// lag. Ideally, we'd avoid such a situation.
const MAX_DELTA_TIME: f32 = 1.0;
const HUMANOID_JUMP_ACCEL: f32 = 16.0;
const HUMANOID_JUMP_ACCEL: f32 = 26.0;
#[derive(Default)]
pub struct BlockChange {

View File

@ -16,7 +16,7 @@ use specs::{
use std::time::Duration;
use vek::*;
const CHARGE_COST: i32 = 50;
const CHARGE_COST: i32 = 200;
/// # Controller System
/// #### Responsible for validating controller inputs and setting new Character States

View File

@ -15,13 +15,13 @@ use vek::*;
pub const ROLL_DURATION: Duration = Duration::from_millis(600);
const HUMANOID_ACCEL: f32 = 50.0;
const HUMANOID_ACCEL: f32 = 100.0;
const HUMANOID_SPEED: f32 = 120.0;
const HUMANOID_AIR_ACCEL: f32 = 10.0;
const HUMANOID_AIR_ACCEL: f32 = 15.0;
const HUMANOID_AIR_SPEED: f32 = 100.0;
const HUMANOID_WATER_ACCEL: f32 = 70.0;
const HUMANOID_WATER_SPEED: f32 = 120.0;
const HUMANOID_CLIMB_ACCEL: f32 = 5.0;
const HUMANOID_CLIMB_ACCEL: f32 = 10.0;
const ROLL_SPEED: f32 = 17.0;
const CHARGE_SPEED: f32 = 20.0;
const GLIDE_ACCEL: f32 = 15.0;
@ -221,14 +221,9 @@ impl<'a> System<'a> for Sys {
if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() {
vel.0 -= dt.0 * vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0);
} else if inputs.climb.is_pressed() && !inputs.climb_down.is_pressed() {
vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED);
vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED).max(0.0);
} else {
vel.0.z = vel.0.z + dt.0 * GRAVITY * 1.5;
vel.0 = Lerp::lerp(
vel.0,
Vec3::zero(),
30.0 * dt.0 / (1.0 - vel.0.z.min(0.0) * 5.0),
);
vel.0.z = (vel.0.z - dt.0 * GRAVITY * 0.01).min(CLIMB_SPEED);
}
}

View File

@ -11,14 +11,14 @@ use {
vek::*,
};
pub const GRAVITY: f32 = 9.81 * 4.0;
pub const GRAVITY: f32 = 9.81 * 7.0;
const BOUYANCY: f32 = 0.0;
// Friction values used for linear damping. They are unitless quantities. The
// value of these quantities must be between zero and one. They represent the
// amount an object will slow down within 1/60th of a second. Eg. if the frction
// is 0.01, and the speed is 1.0, then after 1/60th of a second the speed will
// be 0.99. after 1 second the speed will be 0.54, which is 0.99 ^ 60.
const FRIC_GROUND: f32 = 0.08;
const FRIC_GROUND: f32 = 0.15;
const FRIC_AIR: f32 = 0.0125;
const FRIC_FLUID: f32 = 0.2;
@ -275,6 +275,7 @@ impl<'a> System<'a> for Sys {
{
// ...block-hop!
pos.0.z = (pos.0.z + 0.1).ceil();
vel.0.z = 0.0;
on_ground = true;
break;
} else {

View File

@ -5,7 +5,7 @@ use crate::{
};
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
const ENERGY_REGEN_ACCEL: f32 = 1.0;
const ENERGY_REGEN_ACCEL: f32 = 0.5;
/// This system kills players, levels them up, and regenerates energy.
pub struct Sys;

View File

@ -258,7 +258,7 @@ impl Server {
state.write_component(entity, body);
state.write_component(entity, comp::Stats::new(name, main));
state.write_component(entity, comp::Energy::new(200));
state.write_component(entity, comp::Energy::new(1000));
state.write_component(entity, comp::Controller::default());
state.write_component(entity, comp::Pos(spawn_point));
state.write_component(entity, comp::Vel(Vec3::zero()));
@ -1185,7 +1185,7 @@ impl StateExt for State {
.with(comp::Controller::default())
.with(body)
.with(stats)
.with(comp::Energy::new(100))
.with(comp::Energy::new(500))
.with(comp::Gravity(1.0))
.with(comp::CharacterState::default())
}