mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
improvement: char speed
This commit is contained in:
parent
aa52c6fd4f
commit
aeb37a1f33
@ -27,19 +27,13 @@ impl StateHandler for State {
|
||||
};
|
||||
|
||||
// If no wall is in front of character ...
|
||||
if let None = ecs_data.physics.on_wall {
|
||||
if ecs_data.physics.on_wall.is_none() || ecs_data.physics.on_ground {
|
||||
if ecs_data.inputs.jump.is_pressed() {
|
||||
// They've climbed atop something, give them a boost
|
||||
//TODO: JUMP EVENT
|
||||
} else {
|
||||
// Just fall off
|
||||
update.character = CharacterState::Idle(None);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove climb state on ground, otherwise character will get stuck
|
||||
if ecs_data.physics.on_ground {
|
||||
update.character = CharacterState::Idle(None);
|
||||
return update;
|
||||
}
|
||||
|
||||
// Move player
|
||||
|
@ -6,23 +6,24 @@ use vek::vec::{Vec2, Vec3};
|
||||
|
||||
pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) {
|
||||
let (accel, speed): (f32, f32) = if ecs_data.physics.on_ground {
|
||||
let accel = 50.0;
|
||||
let speed = 120.0;
|
||||
let accel = 100.0;
|
||||
let speed = 8.0;
|
||||
(accel, speed)
|
||||
} else {
|
||||
let accel = 10.0;
|
||||
let speed = 100.0;
|
||||
let accel = 100.0;
|
||||
let speed = 8.0;
|
||||
(accel, speed)
|
||||
};
|
||||
|
||||
// Move player according to move_dir
|
||||
update.vel.0 += Vec2::broadcast(ecs_data.dt.0)
|
||||
* ecs_data.inputs.move_dir
|
||||
* if update.vel.0.magnitude_squared() < speed.powf(2.0) {
|
||||
accel
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
if update.vel.0.magnitude_squared() < speed.powf(2.0) {
|
||||
update.vel.0 =
|
||||
update.vel.0 + Vec2::broadcast(ecs_data.dt.0) * ecs_data.inputs.move_dir * accel;
|
||||
let mag2 = update.vel.0.magnitude_squared();
|
||||
if mag2 > speed.powf(2.0) {
|
||||
update.vel.0 = update.vel.0.normalized() * speed;
|
||||
}
|
||||
}
|
||||
|
||||
// Set direction based on move direction
|
||||
let ori_dir = if update.character.is_attack() || update.character.is_block() {
|
||||
@ -56,8 +57,10 @@ pub fn handle_sit(ecs_data: &EcsStateData, update: &mut StateUpdate) {
|
||||
}
|
||||
|
||||
pub fn handle_climb(ecs_data: &EcsStateData, update: &mut StateUpdate) {
|
||||
if (ecs_data.inputs.climb.is_pressed() || ecs_data.inputs.climb_down.is_pressed())
|
||||
if (ecs_data.inputs.climb.is_just_pressed() || ecs_data.inputs.climb_down.is_pressed())
|
||||
&& ecs_data.physics.on_wall.is_some()
|
||||
&& !ecs_data.physics.on_ground
|
||||
//&& update.vel.0.z < 0.0
|
||||
&& ecs_data.body.is_humanoid()
|
||||
{
|
||||
update.character = CharacterState::Climb(None);
|
||||
|
@ -11,7 +11,7 @@ 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
|
||||
|
@ -27,7 +27,7 @@ impl Animation for RunAnimation {
|
||||
|
||||
let constant = 1.0;
|
||||
let wave = (((5.0)
|
||||
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32)))
|
||||
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 4.2).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * constant as f32 * 1.2).sin());
|
||||
let wave_cos = (((5.0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user