diff options
author | tpart <tpart120@proton.me> | 2024-09-27 20:36:32 +0200 |
---|---|---|
committer | tpart <tpart120@proton.me> | 2024-09-27 20:36:32 +0200 |
commit | 177aae8b15bc4ff909dd771d9be3486b5a5ba49e (patch) | |
tree | 16624e8d05ac44e98f6ecf470047caf787d4beef | |
parent | df2b0841d27034629ae00f55c98d0cbc40011d7a (diff) | |
download | hurrycurry-177aae8b15bc4ff909dd771d9be3486b5a5ba49e.tar hurrycurry-177aae8b15bc4ff909dd771d9be3486b5a5ba49e.tar.bz2 hurrycurry-177aae8b15bc4ff909dd771d9be3486b5a5ba49e.tar.zst |
Remove unnecessary "self.*" in controllable player to improve readability
-rw-r--r-- | client/player/controllable_player.gd | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd index 8dcdc6f0..07450bab 100644 --- a/client/player/controllable_player.gd +++ b/client/player/controllable_player.gd @@ -94,46 +94,46 @@ func _process_movement(delta): func update(dt: float, boost: bool): direction = direction.limit_length(1.) if direction.length() > 0.05: - self.facing = direction + (self.facing - direction) * exp(-dt * 10.) + facing = direction + (facing - direction) * exp(-dt * 10.) if direction.length() < 0.5: direction *= 0 - rotation_ = atan2(self.facing.x, self.facing.y); + rotation_ = atan2(facing.x, facing.y); boost = boost and direction.length() > 0.1 boosting = boost and (boosting or stamina >= 1.0) and stamina > 0 if boosting: stamina -= dt / BOOST_DURATION 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_ += direction * dt * speed - self.position_ += self.velocity_ * dt - self.velocity_ = self.velocity_ * exp(-dt * PLAYER_FRICTION) + velocity_ += direction * dt * speed + position_ += velocity_ * dt + velocity_ = velocity_ * exp(-dt * PLAYER_FRICTION) 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(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, 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 d_sample_x = aabb_point_distance(tile, tile + Vector2.ONE, position_ + Vector2(h, 0)) + var d_sample_y = aabb_point_distance(tile, tile + Vector2.ONE, 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_) + position_ += (PLAYER_SIZE - d) * grad; + velocity_ -= grad * grad.dot(velocity_) for player: Player in game.players.values(): - var diff = self.position_ - player.position_ + var diff = position_ - player.position_ var d = diff.length() if d < 0.01: continue if d >= PLAYER_SIZE * 2: continue var norm = diff.normalized(); var f = 100 / (1 + d) - self.velocity_.x += norm.x * f * dt - self.velocity_.y += norm.y * f * dt + velocity_.x += norm.x * f * dt + velocity_.y += norm.y * f * dt func is_input_enabled() -> bool: return not game.menu.covered and enable_input |