diff options
-rw-r--r-- | client/multiplayer.gd | 2 | ||||
-rw-r--r-- | client/player/controllable_player.gd | 21 |
2 files changed, 11 insertions, 12 deletions
diff --git a/client/multiplayer.gd b/client/multiplayer.gd index 30346263..af80fc0f 100644 --- a/client/multiplayer.gd +++ b/client/multiplayer.gd @@ -264,7 +264,7 @@ func send_tile_interact(pos: Vector2i, edge: bool): "edge": edge }) -func set_player_interact(player: int, edge: bool): +func set_player_interact(_player: int, _edge: bool): push_error("not yet implemented") func send_chat(message: String): 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_) |