diff options
Diffstat (limited to 'client/player/controllable_player.gd')
| -rw-r--r-- | client/player/controllable_player.gd | 21 | 
1 files changed, 10 insertions, 11 deletions
| diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd index f83a08f6..8361ca6a 100644 --- a/client/player/controllable_player.gd +++ b/client/player/controllable_player.gd @@ -28,7 +28,6 @@ var onscreen_controls = preload("res://player/onscreen_controls/controls.tscn").  var facing = Vector2(1, 0)  var velocity_ = Vector2(0, 0)  var stamina = 0 -var was_boosting := false  var chat_open := false  var target: Vector2i = Vector2i(0, 0) @@ -85,7 +84,7 @@ func _process_movement(delta):  func update(dt: float, input: Vector2, boost: bool):  	input = input.limit_length(1.);  	if input.length() > 0.1: -		self.facing = input + (self.facing - input) * exp( - dt * 10.); +		self.facing = input + (self.facing - input) * exp( - dt * 10.)  	rotation_ = atan2(self.facing.x, self.facing.y);  	boost = boost and input.length() > 0.1  	boosting = boost and (boosting or stamina >= 1.0) and stamina > 0 @@ -93,23 +92,23 @@ func update(dt: float, input: Vector2, boost: bool):  	else: stamina += dt / BOOST_RESTORE  	stamina = max(min(stamina, 1.0), 0.0)  	var speed = PLAYER_SPEED * (BOOST_FACTOR if boosting else 1.) -	self.velocity_ += input * dt * speed; -	self.position_ += self.velocity_ * dt; -	self.velocity_ = self.velocity_ * exp( - dt * 15.); -	collide(dt); +	self.velocity_ += input * dt * speed +	self.position_ += self.velocity_ * dt +	self.velocity_ = self.velocity_ * exp( - dt * 15.) +	collide(dt)  func collide(dt: float):  	for xo in range( - 1, 2):  		for yo in range( - 1, 2): -			var tile = Vector2i(xo, yo) + Vector2i(self.position_); +			var tile = Vector2i(xo, yo) + Vector2i(self.position_)  			if !game.get_tile_collision(tile): continue  			tile = Vector2(tile) -			var d = aabb_point_distance(tile, tile + Vector2.ONE, self.position_); +			var d = aabb_point_distance(tile, tile + Vector2.ONE, self.position_)  			if d > PLAYER_SIZE: continue  			var h = 0.01; -			var d_sample_x = aabb_point_distance(tile, tile + Vector2.ONE, self.position_ + Vector2(h, 0)); -			var d_sample_y = aabb_point_distance(tile, tile + Vector2.ONE, self.position_ + Vector2(0, h)); -			var grad = (Vector2(d_sample_x - d, d_sample_y - d)) / h; +			var d_sample_x = aabb_point_distance(tile, tile + Vector2.ONE, self.position_ + Vector2(h, 0)) +			var d_sample_y = aabb_point_distance(tile, tile + Vector2.ONE, self.position_ + Vector2(0, h)) +			var grad = (Vector2(d_sample_x - d, d_sample_y - d)) / h  			self.position_ += (PLAYER_SIZE - d) * grad;  			self.velocity_ -= grad * grad.dot(self.velocity_) | 
