aboutsummaryrefslogtreecommitdiff
path: root/client/player
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-07-07 15:55:05 +0200
committermetamuffin <metamuffin@disroot.org>2024-07-07 15:55:05 +0200
commit13ea66d8832fbede8563e66a4bc25e32b594ab30 (patch)
tree413b058b532e743a6522050725435d11bfe86c14 /client/player
parente31828f3431b9e79cee726fadbcbbef9cc65c916 (diff)
downloadhurrycurry-13ea66d8832fbede8563e66a4bc25e32b594ab30.tar
hurrycurry-13ea66d8832fbede8563e66a4bc25e32b594ab30.tar.bz2
hurrycurry-13ea66d8832fbede8563e66a4bc25e32b594ab30.tar.zst
remove gdscript warnings
Diffstat (limited to 'client/player')
-rw-r--r--client/player/controllable_player.gd21
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_)