summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/player/controllable_player.gd28
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