diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/map/items/burned.gd | 8 | ||||
| -rw-r--r-- | client/map/items/burned_pot.gd | 4 | ||||
| -rw-r--r-- | client/menu/menu_manager.gd | 2 | ||||
| -rw-r--r-- | client/player/character/character.gd | 20 | ||||
| -rw-r--r-- | client/player/character/character.tscn | 41 | ||||
| -rw-r--r-- | client/player/controllable_player.gd | 3 | ||||
| -rw-r--r-- | client/player/follow_camera.gd | 45 | ||||
| -rw-r--r-- | client/project.godot | 18 | 
8 files changed, 113 insertions, 28 deletions
| diff --git a/client/map/items/burned.gd b/client/map/items/burned.gd index 5c98817a..ad7b4505 100644 --- a/client/map/items/burned.gd +++ b/client/map/items/burned.gd @@ -16,13 +16,17 @@  class_name Burned  extends Item +var steam: CPUParticles3D = load("res://map/items/steam.tscn").instantiate() +  func _init(owned_by_: Node3D):  	super(owned_by_) -	var steam: CPUParticles3D = load("res://map/items/steam.tscn").instantiate() -	steam.emitting = true  	steam.color = Color(0., 0., 0.)  	add_child(load("res://map/items/burned.tscn").instantiate())  	base.add_child(steam) + +func _ready(): +	steam.emitting = true +  static func base_position() -> Vector3:  	return Vector3(0., .2, 0.) diff --git a/client/map/items/burned_pot.gd b/client/map/items/burned_pot.gd index dc749259..d38cae6e 100644 --- a/client/map/items/burned_pot.gd +++ b/client/map/items/burned_pot.gd @@ -18,6 +18,8 @@ extends PotFill  func _init(owned_by_: Node3D):  	super(owned_by_) -	steam.emitting = true  	steam.color = Color(0., 0., 0.)  	set_color(Color(.1, .1, .1)) + +func _ready(): +	steam.emitting = true diff --git a/client/menu/menu_manager.gd b/client/menu/menu_manager.gd index 079f6e44..2d196d71 100644 --- a/client/menu/menu_manager.gd +++ b/client/menu/menu_manager.gd @@ -17,7 +17,7 @@ func _ready():  		Global.fade_next = false  		transition.fade_in() -func _input(event): +func _input(_event):  	if Input.is_action_just_pressed("ui_cancel") && menu_stack.size() > 1:  		go_back() diff --git a/client/player/character/character.gd b/client/player/character/character.gd index 820cba74..36ff1323 100644 --- a/client/player/character/character.gd +++ b/client/player/character/character.gd @@ -1,18 +1,18 @@  # Undercooked - a game about cooking  # Copyright 2024 tpart -#  +#  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU Affero General Public License as published by  # the Free Software Foundation, version 3 of the License only. -#  +#  # This program is distributed in the hope that it will be useful,  # but WITHOUT ANY WARRANTY; without even the implied warranty of  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  # GNU Affero General Public License for more details. -#  +#  # You should have received a copy of the GNU Affero General Public License  # along with this program.  If not, see <https://www.gnu.org/licenses/>. -#  +#  extends Node3D  class_name Character @@ -21,6 +21,8 @@ const WALK_ANIM_SPEED:= 15.0  var walking := false  var holding := false +var boosting := false +var was_boosting := boosting  var current_animation := "idle" @@ -28,6 +30,8 @@ var current_animation := "idle"  @onready var main = $Main  @onready var default_height = main.position.y  @onready var main_height_target = default_height +@onready var walking_particles = $Walking +@onready var boosting_particles = $Boosting  @onready var hairstyles = {  	"Brown": $Main/Head/Hair, @@ -46,7 +50,7 @@ func _process(delta):  	else:  		t = 0  	main.position.y = main_height_target -	 +  	# Update animation:  	var next_animation: String  	if holding: @@ -55,7 +59,11 @@ func _process(delta):  		next_animation = "walk"  	else:  		next_animation = "idle" -	 + +	walking_particles.emitting = walking +	boosting_particles.emitting = boosting and walking and not was_boosting +	was_boosting = boosting and walking +  	if current_animation != next_animation:  		play_animation(next_animation) diff --git a/client/player/character/character.tscn b/client/player/character/character.tscn index 033135cd..cb5aa988 100644 --- a/client/player/character/character.tscn +++ b/client/player/character/character.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://b3hhir2fvnunu"] +[gd_scene load_steps=18 format=3 uid="uid://b3hhir2fvnunu"]  [ext_resource type="Script" path="res://player/character/character.gd" id="1_12lbh"]  [ext_resource type="ArrayMesh" uid="uid://bnmm01yjwultj" path="res://player/character/main.res" id="2_lxdbd"] @@ -565,6 +565,16 @@ _data = {  "walk": SubResource("Animation_7kiho")  } +[sub_resource type="SphereMesh" id="SphereMesh_xr0ql"] +radius = 0.1 +height = 0.2 + +[sub_resource type="SphereMesh" id="SphereMesh_qqngc"] + +[sub_resource type="Curve" id="Curve_7ml8g"] +_data = [Vector2(0, 0.054945), 0.0, 0.0, 0, 0, Vector2(0.174157, 1), 0.0, 0.0, 0, 0, Vector2(0.573034, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 4 +  [node name="guy" type="Node3D"]  script = ExtResource("1_12lbh") @@ -615,4 +625,33 @@ libraries = {  "": SubResource("AnimationLibrary_xtrfe")  } +[node name="Walking" type="CPUParticles3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.2) +amount = 2 +lifetime = 0.5 +lifetime_randomness = 0.5 +mesh = SubResource("SphereMesh_xr0ql") +direction = Vector3(0, 0.5, -1) +initial_velocity_min = 1.0 +initial_velocity_max = 3.0 +scale_amount_min = 0.4 +scale_amount_max = 0.75 + +[node name="Boosting" type="CPUParticles3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.2) +emitting = false +amount = 30 +lifetime = 0.3 +one_shot = true +explosiveness = 0.75 +lifetime_randomness = 0.5 +mesh = SubResource("SphereMesh_qqngc") +direction = Vector3(0, 0.5, -1) +gravity = Vector3(0, -0.1, 0) +initial_velocity_min = 1.0 +initial_velocity_max = 5.0 +scale_amount_min = 0.5 +scale_amount_max = 0.75 +scale_amount_curve = SubResource("Curve_7ml8g") +  [connection signal="animation_finished" from="HandAnimations" to="." method="_on_hand_animations_animation_finished"] diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd index a677fdb3..32fa3135 100644 --- a/client/player/controllable_player.gd +++ b/client/player/controllable_player.gd @@ -58,6 +58,7 @@ func _process(delta):  	update(delta, input, boost)  	super(delta)  	character.walking = input.length_squared() > 0.1 +	character.boosting = boosting  func update(dt: float, input: Vector2, boost: bool):  	input = input.limit_length(1.); @@ -69,7 +70,7 @@ func update(dt: float, input: Vector2, boost: bool):  	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) +	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.); diff --git a/client/player/follow_camera.gd b/client/player/follow_camera.gd index 74355688..f0d5700d 100644 --- a/client/player/follow_camera.gd +++ b/client/player/follow_camera.gd @@ -1,19 +1,19 @@  # Undercooked - a game about cooking  # Copyright 2024 nokoe  # Copyright 2024 metamuffin -#  +#  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU Affero General Public License as published by  # the Free Software Foundation, version 3 of the License only. -#  +#  # This program is distributed in the hope that it will be useful,  # but WITHOUT ANY WARRANTY; without even the implied warranty of  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  # GNU Affero General Public License for more details. -#  +#  # You should have received a copy of the GNU Affero General Public License  # along with this program.  If not, see <https://www.gnu.org/licenses/>. -#  +#  class_name FollowCamera  extends Camera3D @@ -25,7 +25,10 @@ const ANGLE_UP_MIN: float = 0.5  const ANGLE_UP_MAX: float = 1.2  const LOOK_WEIGHT: float = 8.0  const MOVE_WEIGHT: float = 2.0 -const CAMERA_DISTANCE: float = 10 +const ZOOM_SPEED: float = 10.0 +const ZOOM_WEIGHT: float = 10.0 +const MAX_ZOOM: float = 20.0 +const MIN_ZOOM: float = 2.0  @export var target: Node3D @@ -34,6 +37,8 @@ var angle: float = 0  var angle_up_target: float = 1  var angle_up: float = 1  var ground: Vector3 +var camera_distance: float = 10. +var camera_distance_target: float = camera_distance  func _ready():  	if target == null: @@ -46,14 +51,6 @@ func _process(delta):  		follow(delta)  func follow(delta): -	var new_transform = transform.looking_at(target.position) - -	transform.basis = Basis.from_euler(Vector3( -		lerp_angle(transform.basis.get_euler().x, new_transform.basis.get_euler().x, delta * LOOK_WEIGHT), -		lerp_angle(transform.basis.get_euler().y, new_transform.basis.get_euler().y, delta * LOOK_WEIGHT), -		lerp_angle(transform.basis.get_euler().z, new_transform.basis.get_euler().z, delta * LOOK_WEIGHT) -	)) -  	angle_target += Input.get_axis("rotate_left", "rotate_right") * ROTATE_SPEED * delta  	angle = lerp_angle(angle, angle_target, delta * ROTATE_WEIGHT) @@ -61,5 +58,25 @@ func follow(delta):  	angle_up_target = clamp(angle_up_target, ANGLE_UP_MIN, ANGLE_UP_MAX)  	angle_up = lerp_angle(angle_up, angle_up_target, delta * ROTATE_UP_WEIGHT) +	var offset = Vector3(0, sin(angle_up) * camera_distance, cos(angle_up) * camera_distance).rotated(Vector3.UP, angle) + +	var new_transform = transform +	new_transform.origin = target.position + offset +	new_transform = new_transform.looking_at(target.position) + +	if Global.settings["interpolate_camera_rotation"]["value"]: +		transform.basis = Basis.from_euler(Vector3( +			lerp_angle(transform.basis.get_euler().x, new_transform.basis.get_euler().x, delta * LOOK_WEIGHT), +			lerp_angle(transform.basis.get_euler().y, new_transform.basis.get_euler().y, delta * LOOK_WEIGHT), +			lerp_angle(transform.basis.get_euler().z, new_transform.basis.get_euler().z, delta * LOOK_WEIGHT) +		)) +	else: +		transform.basis = new_transform.basis  	ground = ground.lerp(target.position, delta * MOVE_WEIGHT) -	position = ground + Vector3(0, sin(angle_up) * CAMERA_DISTANCE, cos(angle_up) * CAMERA_DISTANCE).rotated(Vector3.UP, angle) + +	camera_distance_target += Input.get_axis("zoom_in", "zoom_out") * ZOOM_SPEED * delta +	camera_distance_target = clamp(camera_distance_target, MIN_ZOOM, MAX_ZOOM) + +	camera_distance = lerp(camera_distance, camera_distance_target, delta * ZOOM_WEIGHT) + +	position = ground + offset diff --git a/client/project.godot b/client/project.godot index 5bbc3f15..ec7780f3 100644 --- a/client/project.godot +++ b/client/project.godot @@ -77,13 +77,13 @@ rotate_right={  rotate_up={  "deadzone": 0.1,  "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)  ]  }  rotate_down={  "deadzone": 0.1,  "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)  ]  }  interact={ @@ -104,6 +104,20 @@ boost={  , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)  ]  } +zoom_in={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194323,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194437,"key_label":0,"unicode":43,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null) +] +} +zoom_out={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194324,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194435,"key_label":0,"unicode":45,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null) +] +}  [internationalization] | 
