diff options
Diffstat (limited to 'client/player')
| -rw-r--r-- | client/player/controllable_player.gd | 22 | 
1 files changed, 16 insertions, 6 deletions
| diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd index 142d5f47..9e7ce2b2 100644 --- a/client/player/controllable_player.gd +++ b/client/player/controllable_player.gd @@ -58,10 +58,11 @@ func _process(delta):  	super(delta)  	update_touch_scrolls() +var moving_duration = 0  func _process_movement(delta):  	var input = Input.get_vector("left", "right", "forwards", "backwards") if is_input_enabled() else Vector2.ZERO  	var boost = Input.is_action_pressed("boost") or (Global.get_setting("gameplay.latch_boost") and boosting) -	input = input.rotated( - game.camera.angle_target) +	input = input.rotated(-game.camera.angle_target)  	if Input.is_action_pressed("interact") or Input.is_action_just_released("interact"):  		input *= 0  	else: @@ -69,6 +70,13 @@ func _process_movement(delta):  			int(floor(movement_base.position.x + sin(movement_base.rotation.y))),  			int(floor(movement_base.position.z + cos(movement_base.rotation.y)))  		) + +	if Global.get_setting("gameplay.accessible_movement"):  +		if input.length() < 0.5: moving_duration -= delta * 2 +		else: moving_duration += delta +		moving_duration = clamp(moving_duration, 0, 1) +		input *= min(1, moving_duration) +  	interact()  	var was_boosting = boosting  	direction = input @@ -81,8 +89,10 @@ func _process_movement(delta):  func update(dt: float, boost: bool):  	direction = direction.limit_length(1.); -	if direction.length() > 0.1: -		self.facing = direction + (self.facing - direction) * exp( - dt * 10.) +	if direction.length() > 0.05: +		self.facing = direction + (self.facing - direction) * exp(-dt * 10.) +	if direction.length() < 0.5: +		direction *= 0  	rotation_ = atan2(self.facing.x, self.facing.y);  	boost = boost and direction.length() > 0.1  	boosting = boost and (boosting or stamina >= 1.0) and stamina > 0 @@ -92,12 +102,12 @@ func update(dt: float, boost: bool):  	var speed = PLAYER_SPEED * (BOOST_FACTOR if boosting else 1.)  	self.velocity_ += direction * dt * speed  	self.position_ += self.velocity_ * dt -	self.velocity_ = self.velocity_ * exp( - dt * PLAYER_FRICTION) +	self.velocity_ = self.velocity_ * exp(-dt * PLAYER_FRICTION)  	collide(dt)  func collide(dt: float): -	for xo in range( - 1, 2): -		for yo in range( - 1, 2): +	for xo in range(-1, 2): +		for yo in range(-1, 2):  			var tile = Vector2i(xo, yo) + Vector2i(self.position_)  			if !game.get_tile_collision(tile): continue  			tile = Vector2(tile) | 
