From e366cfdf9133c0da798352c474580d329c6a0f33 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 22 Jun 2024 18:10:07 +0200 Subject: player collisions and better movement code --- client/scripts/player.gd | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'client/scripts/player.gd') diff --git a/client/scripts/player.gd b/client/scripts/player.gd index 3ad77322..8f53b790 100644 --- a/client/scripts/player.gd +++ b/client/scripts/player.gd @@ -4,13 +4,21 @@ extends Node3D const PLAYER_SIZE: float = 0.4 const SPEED: float = 25. +var game: Game +var position_ = Vector2(0, 0) + var mesh = preload("res://scenes/player.tscn").instantiate() -func _init(id: int, new_name: String, pos: Vector2, _character: int): +func _init(id: int, new_name: String, pos: Vector2, _character: int, new_game: Game): add_child(mesh) - position = Vector3(pos.x, 0, pos.y) + position_ = pos name = new_name + game = new_game func update_position(new_position: Vector2, new_rotation: float): - position = Vector3(new_position.x, 0, new_position.y) + position_ = new_position rotation.y = new_rotation + +func _process(delta): + position.x = position_.x + position.z = position_.y -- cgit v1.2.3-70-g09d2