diff options
| author | nokoe <nokoe@mailbox.org> | 2024-06-23 15:21:53 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:32:56 +0200 | 
| commit | f01b67030386f2d85df5d5fd6487ca5277bd7e83 (patch) | |
| tree | a5fede105580fe3fe6c89c06343b5a6d75371e4b /client/scripts | |
| parent | d55a419ed26db4213b18424fbaae7fff182eb2ae (diff) | |
| download | hurrycurry-f01b67030386f2d85df5d5fd6487ca5277bd7e83.tar hurrycurry-f01b67030386f2d85df5d5fd6487ca5277bd7e83.tar.bz2 hurrycurry-f01b67030386f2d85df5d5fd6487ca5277bd7e83.tar.zst | |
stop when interacting, error
Diffstat (limited to 'client/scripts')
| -rw-r--r-- | client/scripts/controllable_player.gd | 9 | ||||
| -rw-r--r-- | client/scripts/multiplayer.gd | 7 | ||||
| -rw-r--r-- | client/scripts/tiles/floor.gd | 4 | 
3 files changed, 14 insertions, 6 deletions
| diff --git a/client/scripts/controllable_player.gd b/client/scripts/controllable_player.gd index fa22ba02..12925f60 100644 --- a/client/scripts/controllable_player.gd +++ b/client/scripts/controllable_player.gd @@ -20,11 +20,13 @@ func _ready():  func _process(delta):  	var input = Vector2(Input.get_axis("left", "right"), Input.get_axis("forward", "backwards")).normalized()  	input = input.rotated(-game.camera.angle_target) -	update(delta, input)  	position_anim = position_  	rotation_anim = rotation_  	if not Input.is_action_pressed("interact")||Input.is_action_just_pressed("interact"):  		interact() +	else: +		input *= 0 +	update(delta, input)  	super(delta)  func update(dt: float, input: Vector2): @@ -66,8 +68,9 @@ func collide(dt: float):  func aabb_point_distance(mi: Vector2, ma: Vector2, p: Vector2) -> float:  	return (p - p.clamp(mi, ma)).length() -func update_position(_new_position: Vector2, _new_rotation: float): -	pass +func update_position(new_position: Vector2, _new_rotation: float): +	if (new_position - position_).length() > 3.: +		position_ = new_position  func interact():  	var target = Vector2i( diff --git a/client/scripts/multiplayer.gd b/client/scripts/multiplayer.gd index 3d360cf8..1645ab45 100644 --- a/client/scripts/multiplayer.gd +++ b/client/scripts/multiplayer.gd @@ -130,6 +130,9 @@ func handle_packet(bytes: PackedByteArray):  					push_error("neither text nor item provided")  			else:  				emit_signal("clear_message", player) +		"error": +			var message = decoded["message"] +			push_warning("server error: %s" % message)  		_:  			push_error("Unrecognized packet type: %s" % packet_type) @@ -175,11 +178,11 @@ func pos_to_vec2i(pos: Array) -> Vector2i:  	return Vector2i(pos[0], pos[1])  func get_tile_collision(pos: Vector2i) -> bool: -	var t = tileid_by_pos[str(pos)] +	var t = tileid_by_pos.get(str(pos))  	if t == null: return false  	else: return tile_collide[t]  func get_tile_interactive(pos: Vector2i) -> bool: -	var t = tileid_by_pos[str(pos)] +	var t = tileid_by_pos.get(str(pos))  	if t == null: return false  	else: return tile_interact[t] diff --git a/client/scripts/tiles/floor.gd b/client/scripts/tiles/floor.gd index ba352bde..f7c39244 100644 --- a/client/scripts/tiles/floor.gd +++ b/client/scripts/tiles/floor.gd @@ -13,7 +13,9 @@ enum Facing {  }  func _init(rename: String, _neighbors: Array): -	add_child(load("res://models/prefabs/map/floor_kitchen_small.tscn").instantiate()) +	var floor_tile = load("res://models/prefabs/map/floor_kitchen_small.tscn").instantiate() +	floor_tile.position += Vector3(0.5, 0, 0.5) +	add_child(floor_tile)  	base.name = "Base"  	base.position += Vector3(0.5, 0, 0.5)  	add_child(base) | 
