diff --git a/entities/player/movement_component.gd b/entities/player/movement_component.gd index ac7fed0..e397128 100644 --- a/entities/player/movement_component.gd +++ b/entities/player/movement_component.gd @@ -165,7 +165,7 @@ func handle_joypad_movement(): if controller_look_vector.length() > 0: mouse_motion += controller_look_vector - mouse_motion_delta += controller_look_vector + mouse_motion_delta = controller_look_vector func toggle_movement(): _move_toggled = !_move_toggled @@ -178,10 +178,6 @@ func _input(event: InputEvent) -> void: if not UiManager.in_game_menu.visible: if event is InputEventMouseMotion: if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: - #so it doesnt yank - if event.relative.length() > 400: - return - mouse_motion += event.relative mouse_motion_delta = event.relative diff --git a/entities/player/procedural_animator.gd b/entities/player/procedural_animator.gd index 3b29478..2daf385 100644 --- a/entities/player/procedural_animator.gd +++ b/entities/player/procedural_animator.gd @@ -61,7 +61,7 @@ func ui_movement_handling(delta: float, cam_local_vel: Vector3): if Console.toggled: return - var mouse_offset = -movement.mouse_motion_delta * PlayerConsts.UI_MOVEMENT_SENSITIVITY + var mouse_offset = -(movement.mouse_motion_delta * .005 / delta) * PlayerConsts.UI_MOVEMENT_SENSITIVITY _smoothed_mouse_offset = _smoothed_mouse_offset.lerp(mouse_offset, 1.0 - exp(-15.0 * delta)) @@ -73,7 +73,7 @@ func ui_movement_handling(delta: float, cam_local_vel: Vector3): cam_local_vel.y ) * PlayerConsts.CAMERA_VELOCITY_MULTIPLIER - var camera_velocity = (camera.position - _last_camera_position) / delta + var camera_velocity = (camera.position - _last_camera_position) var bob_offset: Vector2 = Vector2(-camera_velocity.x, camera_velocity.y) @@ -82,7 +82,7 @@ func ui_movement_handling(delta: float, cam_local_vel: Vector3): ui.position = ui.position.lerp(ui_base_position + target_offset, weighted_lerp) - var target_scale = -cam_local_vel.z * PlayerConsts.UI_MOVEMENT_SENSITIVITY * .01 + 1 + var target_scale = -cam_local_vel.z * PlayerConsts.UI_MOVEMENT_SCALE_SENSITIVITY + 1 var ui_scaling_target = Vector2(target_scale, target_scale) ui.offset_transform_scale = ui.offset_transform_scale.lerp(Vector2.ONE * ui_scaling_target, weighted_lerp) diff --git a/entities/usable/button/button.gd b/entities/usable/button/button_3d.gd similarity index 100% rename from entities/usable/button/button.gd rename to entities/usable/button/button_3d.gd diff --git a/entities/usable/button/button.gd.uid b/entities/usable/button/button_3d.gd.uid similarity index 100% rename from entities/usable/button/button.gd.uid rename to entities/usable/button/button_3d.gd.uid diff --git a/entities/usable/button/button.tscn b/entities/usable/button/button_3d.tscn similarity index 98% rename from entities/usable/button/button.tscn rename to entities/usable/button/button_3d.tscn index e3f39c6..eea2809 100644 --- a/entities/usable/button/button.tscn +++ b/entities/usable/button/button_3d.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://cbpl3s326ok8d"] -[ext_resource type="Script" uid="uid://d0n5sjpvtitix" path="res://entities/usable/button/button.gd" id="1_r4dn2"] +[ext_resource type="Script" uid="uid://d0n5sjpvtitix" path="res://entities/usable/button/button_3d.gd" id="1_r4dn2"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_f58a4"] albedo_color = Color(0.48374587, 0.48374587, 0.4837458, 1) diff --git a/entities/usable/music_player.tscn b/entities/usable/music_player.tscn index 4545d50..2dfc2a4 100644 --- a/entities/usable/music_player.tscn +++ b/entities/usable/music_player.tscn @@ -1,7 +1,7 @@ [gd_scene format=3 uid="uid://clr8dvbm56jn8"] [ext_resource type="Script" uid="uid://dw22i7cf5ekjx" path="res://entities/usable/music_player.gd" id="1_johh1"] -[ext_resource type="PackedScene" uid="uid://cbpl3s326ok8d" path="res://entities/usable/button/button.tscn" id="1_t1vpp"] +[ext_resource type="PackedScene" uid="uid://cbpl3s326ok8d" path="res://entities/usable/button/button_3d.tscn" id="1_t1vpp"] [ext_resource type="Script" uid="uid://v7j6ovrub5cp" path="res://scenes/changable_sound_emitter.gd" id="3_johh1"] [ext_resource type="AudioStream" uid="uid://b14wn4nntykxv" path="res://assets/sounds/music/Bach_ Toccata and Fugue in D Minor, BWV 565.mp3" id="3_rf3au"] diff --git a/project.godot b/project.godot index c091666..3839124 100644 --- a/project.godot +++ b/project.godot @@ -29,12 +29,12 @@ driver/output_latency=30 Console="*uid://bojihx1fwf426" PlayerConsts="*uid://l2rc674shj03" Sounds="*uid://c4vhdhbi2yu8i" -LoadingScreen="*uid://br8pa51piwxuy" GrabbableBase="*uid://csj6ipagcwmeu" Report="*uid://c76y0hv0jqdr3" UiManager="*uid://dtrfb3xosj32r" GameState="*uid://drxx0ny7uim8k" GlobalSignals="*uid://cky5rk5obojex" +SceneLoader="*uid://bniwncdtbehd3" [display] @@ -43,7 +43,6 @@ window/size/viewport_height=1080 window/size/resizable=false window/stretch/mode="canvas_items" window/stretch/aspect="expand" -window/vsync/vsync_mode=0 window/max_fps=60 [editor] diff --git a/scenes/main_menu/button.gd b/scenes/main_menu/button.gd new file mode 100644 index 0000000..493be14 --- /dev/null +++ b/scenes/main_menu/button.gd @@ -0,0 +1,48 @@ +extends Button + +var tween: Tween +var _mouse_in: bool = false +var _original_position := Vector2.ZERO + +func _ready() -> void: + mouse_entered.connect(_on_mouse_entered) + mouse_exited.connect(_on_mouse_exited) + pivot_offset = size / 2 + offset_transform_enabled = true + _original_position = offset_transform_position + + +func _process(_delta: float) -> void: + if _mouse_in: + track_mouse() + +func track_mouse() -> void: + var _mouse_adjusted = get_viewport().get_mouse_position() - global_position - size / 2 + offset_transform_position = _mouse_adjusted / 10 + +func reset_tween(): + if tween: + tween.kill() + tween = create_tween() + +func _on_mouse_entered() -> void: + reset_tween() + tween.set_ease(Tween.EASE_OUT)\ + .set_trans(Tween.TRANS_ELASTIC)\ + .tween_property(self, "scale", Vector2(1.1,1.1), .5) + + _mouse_in = true + +func _on_mouse_exited() -> void: + reset_tween() + + tween.set_parallel(true) + tween.set_ease(Tween.EASE_OUT)\ + .set_trans(Tween.TRANS_ELASTIC)\ + .tween_property(self, "scale", Vector2.ONE, .5) + + tween.set_ease(Tween.EASE_IN_OUT)\ + .set_trans(Tween.TRANS_BOUNCE)\ + .tween_property(self, "offset_transform_position", _original_position, .5) + + _mouse_in = false diff --git a/scenes/main_menu/button.gd.uid b/scenes/main_menu/button.gd.uid new file mode 100644 index 0000000..4664c8b --- /dev/null +++ b/scenes/main_menu/button.gd.uid @@ -0,0 +1 @@ +uid://bt4l7skxjvc3i diff --git a/scenes/main_menu/main_menu.gd b/scenes/main_menu/main_menu.gd index 0936151..7f3dbc2 100644 --- a/scenes/main_menu/main_menu.gd +++ b/scenes/main_menu/main_menu.gd @@ -11,7 +11,7 @@ func _ready() -> void: UiManager.hide() - %AnimationPlayer.play("camera_init") + #%AnimationPlayer.play("camera_init") func _process(delta: float) -> void: move_camera_based_on_mouse(delta) diff --git a/scenes/main_menu/main_menu.tscn b/scenes/main_menu/main_menu.tscn index 23a6b50..cdc6c50 100644 --- a/scenes/main_menu/main_menu.tscn +++ b/scenes/main_menu/main_menu.tscn @@ -152,7 +152,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.1375935, 0, -1.2356517) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.2707429, 1.2013705, -1.9347405) amount = 80 trail_enabled = true -trail_lifetime = 0.09999999999999999 +trail_lifetime = 0.1 process_material = SubResource("ParticleProcessMaterial_5seab") draw_pass_1 = SubResource("RibbonTrailMesh_x2yjq") @@ -162,7 +162,7 @@ amount = 30 lifetime = 3.0 speed_scale = 0.8 collision_base_size = 0.1 -trail_lifetime = 0.09999999999999999 +trail_lifetime = 0.1 process_material = SubResource("ParticleProcessMaterial_5seab") draw_pass_1 = SubResource("SphereMesh_wem23") diff --git a/scenes/main_menu/main_menu_control.gd b/scenes/main_menu/main_menu_control.gd index 66e6f07..f28782c 100644 --- a/scenes/main_menu/main_menu_control.gd +++ b/scenes/main_menu/main_menu_control.gd @@ -12,11 +12,11 @@ func _process(delta: float) -> void: func _on_button_pressed() -> void: UiManager.toggle_self() - get_tree().change_scene_to_file("uid://c5p2fbgi8co1c") + SceneLoader.load_scene("uid://c5p2fbgi8co1c") func _on_button_2_pressed() -> void: UiManager.toggle_self() - get_tree().change_scene_to_file("uid://chykk2a3opu0d") + SceneLoader.load_scene("uid://chykk2a3opu0d") func _on_button_3_pressed() -> void: print("options") diff --git a/scenes/main_menu/main_menu_control.tscn b/scenes/main_menu/main_menu_control.tscn index 17b87df..109736e 100644 --- a/scenes/main_menu/main_menu_control.tscn +++ b/scenes/main_menu/main_menu_control.tscn @@ -2,6 +2,7 @@ [ext_resource type="Script" uid="uid://cpn3afv0mkf3s" path="res://scenes/main_menu/main_menu_control.gd" id="1_yt8vf"] [ext_resource type="Theme" uid="uid://bspxrgwuidr02" path="res://resources/styles/menu_theme.tres" id="2_bglv6"] +[ext_resource type="Script" uid="uid://bt4l7skxjvc3i" path="res://scenes/main_menu/button.gd" id="3_ork3k"] [node name="MainMenuControl" type="Control" unique_id=2137273835] layout_mode = 3 @@ -30,36 +31,42 @@ theme_override_font_sizes/font_size = 128 text = "BREADWINNER" horizontal_alignment = 1 -[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer2" unique_id=477444179] +[node name="ButtonContainer" type="VBoxContainer" parent="VBoxContainer2" unique_id=477444179] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 3 -[node name="Button" type="Button" parent="VBoxContainer2/VBoxContainer" unique_id=1811326054] +[node name="Button" type="Button" parent="VBoxContainer2/ButtonContainer" unique_id=1811326054] unique_name_in_owner = true layout_mode = 2 theme = ExtResource("2_bglv6") text = "Start random gen" +script = ExtResource("3_ork3k") -[node name="Button2" type="Button" parent="VBoxContainer2/VBoxContainer" unique_id=2118140035] +[node name="Button2" type="Button" parent="VBoxContainer2/ButtonContainer" unique_id=2118140035] unique_name_in_owner = true layout_mode = 2 +offset_transform_enabled = true theme = ExtResource("2_bglv6") text = "Start dev" +script = ExtResource("3_ork3k") -[node name="Button3" type="Button" parent="VBoxContainer2/VBoxContainer" unique_id=331418230] +[node name="Button3" type="Button" parent="VBoxContainer2/ButtonContainer" unique_id=331418230] unique_name_in_owner = true layout_mode = 2 theme = ExtResource("2_bglv6") text = "Options" +script = ExtResource("3_ork3k") -[node name="Button4" type="Button" parent="VBoxContainer2/VBoxContainer" unique_id=1238756529] +[node name="Button4" type="Button" parent="VBoxContainer2/ButtonContainer" unique_id=1238756529] unique_name_in_owner = true layout_mode = 2 theme = ExtResource("2_bglv6") text = "Exit" +script = ExtResource("3_ork3k") -[connection signal="pressed" from="VBoxContainer2/VBoxContainer/Button" to="." method="_on_button_pressed"] -[connection signal="pressed" from="VBoxContainer2/VBoxContainer/Button2" to="." method="_on_button_2_pressed"] -[connection signal="pressed" from="VBoxContainer2/VBoxContainer/Button3" to="." method="_on_button_3_pressed"] -[connection signal="pressed" from="VBoxContainer2/VBoxContainer/Button4" to="." method="_on_button_4_pressed"] +[connection signal="pressed" from="VBoxContainer2/ButtonContainer/Button" to="." method="_on_button_pressed"] +[connection signal="pressed" from="VBoxContainer2/ButtonContainer/Button2" to="." method="_on_button_2_pressed"] +[connection signal="pressed" from="VBoxContainer2/ButtonContainer/Button3" to="." method="_on_button_3_pressed"] +[connection signal="pressed" from="VBoxContainer2/ButtonContainer/Button4" to="." method="_on_button_4_pressed"] diff --git a/scenes/ui/in_game_menu/in_game_menu_manager.gd b/scenes/ui/in_game_menu/in_game_menu_manager.gd index 074f287..5e168d5 100644 --- a/scenes/ui/in_game_menu/in_game_menu_manager.gd +++ b/scenes/ui/in_game_menu/in_game_menu_manager.gd @@ -5,7 +5,7 @@ func toggle_menu(): visible = !visible func _on_exit_pressed() -> void: - get_tree().change_scene_to_file("res://scenes/main_menu/main_menu.tscn") + SceneLoader.load_scene("uid://cerpwmavwn8t") visible = false func _on_options_pressed() -> void: diff --git a/scenes/ui/loading_screen/loading_screen.gd b/scenes/ui/loading_screen/loading_screen.gd index 573fe63..e4d37e0 100644 --- a/scenes/ui/loading_screen/loading_screen.gd +++ b/scenes/ui/loading_screen/loading_screen.gd @@ -1,26 +1,18 @@ -extends PanelContainer +extends CanvasLayer +signal loading_screen_ready -var done: bool = false +@export var animation_player: AnimationPlayer +@onready var progress_bar: ProgressBar = %ProgressBar -func sound_loading(): - print("loading screen shown") - show() - -func sound_loading_done(): - print("loading screen hidden") - #hide() - %Label.text = "Done!" - done = true - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - Sounds.loading.connect(sound_loading) - Sounds.loading_done.connect(sound_loading_done) - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - if done and %ColorRect.color != Color(0,0,0,0): - %ColorRect.color = lerp(%ColorRect.color, Color(0,0,0,0), delta) +func _ready() -> void: + await animation_player.animation_finished + loading_screen_ready.emit() + +func _on_progress_changed(new_value: float) -> void: + progress_bar.value = new_value + +func _on_load_finished() -> void: + animation_player.play_backwards("transition") + await animation_player.animation_finished + queue_free() diff --git a/scenes/ui/loading_screen/loading_screen.tscn b/scenes/ui/loading_screen/loading_screen.tscn index 53a25a5..9276a5d 100644 --- a/scenes/ui/loading_screen/loading_screen.tscn +++ b/scenes/ui/loading_screen/loading_screen.tscn @@ -2,50 +2,64 @@ [ext_resource type="Script" uid="uid://br8pa51piwxuy" path="res://scenes/ui/loading_screen/loading_screen.gd" id="1_rqdcv"] -[node name="LoadingScreen" type="PanelContainer" unique_id=1023721034] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_g4v7s"] +bg_color = Color(0, 0, 0, 1) + +[sub_resource type="Animation" id="Animation_vwscl"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Panel:theme_override_styles/panel:bg_color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(0, 0, 0, 1)] +} + +[sub_resource type="Animation" id="Animation_dd6wa"] +resource_name = "transition" +length = 0.5 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Panel:theme_override_styles/panel:bg_color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.5), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_urqlm"] +_data = { +&"RESET": SubResource("Animation_vwscl"), +&"transition": SubResource("Animation_dd6wa") +} + +[node name="LoadingScreen" type="CanvasLayer" unique_id=138834705 node_paths=PackedStringArray("animation_player")] script = ExtResource("1_rqdcv") +animation_player = NodePath("AnimationPlayer") -[node name="Control" type="Control" parent="." unique_id=2009868353] -layout_mode = 2 +[node name="Panel" type="Panel" parent="." unique_id=1829994343] +offset_right = 1920.0 +offset_bottom = 1080.0 +theme_override_styles/panel = SubResource("StyleBoxFlat_g4v7s") -[node name="ColorRect" type="ColorRect" parent="Control" unique_id=1237635531] +[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1601298347] +libraries/ = SubResource("AnimationLibrary_urqlm") +autoplay = &"transition" + +[node name="ProgressBar" type="ProgressBar" parent="." unique_id=2107914636] unique_name_in_owner = true -layout_mode = 1 -anchors_preset = 15 +anchors_preset = -1 +anchor_top = 0.916 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 -grow_vertical = 2 -color = Color(0, 0, 0, 1) - -[node name="ProgressBar" type="ProgressBar" parent="Control" unique_id=1865933389] -unique_name_in_owner = true -layout_mode = 1 -anchors_preset = -1 -anchor_top = 0.96 -anchor_right = 1.0 -anchor_bottom = 0.98 -offset_top = -27.0 -grow_horizontal = 2 grow_vertical = 0 -show_percentage = false - -[node name="Label" type="Label" parent="Control" unique_id=1444927305] -unique_name_in_owner = true -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.9 -anchor_top = 0.9 -anchor_right = 0.9 -anchor_bottom = 0.9 -offset_left = -219.0 -offset_top = -69.0 -grow_horizontal = 0 -grow_vertical = 0 -theme_override_font_sizes/font_size = 50 -text = "loading..." diff --git a/scripts/autoload/player_consts.gd b/scripts/autoload/player_consts.gd index 1ee650f..9b81fd9 100644 --- a/scripts/autoload/player_consts.gd +++ b/scripts/autoload/player_consts.gd @@ -21,8 +21,9 @@ extends Node @export_category("UI") @export var UI_SCALE: float = 1 ##rational scale of the ui -@export var UI_MOVEMENT_SENSITIVITY = 0.5 ##how much the UI moves when you move the camera +@export var UI_MOVEMENT_SENSITIVITY = 2 ##how much the UI moves when you move the camera @export var UI_MOVEMENT_SPEED = 15.0 ##how fast the UI moves when you move the camera +@export var UI_MOVEMENT_SCALE_SENSITIVITY = 0.01 @export var UI_MOVEMENT_VELOCITY_MULTIPLIER = 2.0 ##how much the ui leans when walking or strafing @export_category("Inventory") diff --git a/scripts/autoload/scene_loader.gd b/scripts/autoload/scene_loader.gd new file mode 100644 index 0000000..5dee25a --- /dev/null +++ b/scripts/autoload/scene_loader.gd @@ -0,0 +1,41 @@ +extends Node + +signal progress_changed(progress) +signal load_finished + +var loading_screen: PackedScene = preload("uid://046i0offx3w8") +var loaded_resource: PackedScene +var scene_path: String +var progress: Array = [] +var use_sub_threads: bool = true + +func _ready() -> void: + set_process(false) + +func load_scene(_scene_path: String) -> void: + scene_path = _scene_path + + var new_load_screen = loading_screen.instantiate() + add_child(new_load_screen) + progress_changed.connect(new_load_screen._on_progress_changed) + load_finished.connect(new_load_screen._on_load_finished) + + await new_load_screen.loading_screen_ready + + start_load() + +func start_load() -> void: + var state = ResourceLoader.load_threaded_request(scene_path, "", use_sub_threads) + if state == OK: + set_process(true) + +func _process(delta: float) -> void: + var load_status = ResourceLoader.load_threaded_get_status(scene_path, progress) + progress_changed.emit(progress[0]) + match load_status: + ResourceLoader.THREAD_LOAD_INVALID_RESOURCE, ResourceLoader.THREAD_LOAD_FAILED: + set_process(false) + ResourceLoader.THREAD_LOAD_LOADED: + loaded_resource = ResourceLoader.load_threaded_get(scene_path) + get_tree().change_scene_to_packed(loaded_resource) + load_finished.emit() diff --git a/scripts/autoload/scene_loader.gd.uid b/scripts/autoload/scene_loader.gd.uid new file mode 100644 index 0000000..1db0f44 --- /dev/null +++ b/scripts/autoload/scene_loader.gd.uid @@ -0,0 +1 @@ +uid://bniwncdtbehd3 diff --git a/scripts/autoload/sounds.gd b/scripts/autoload/sounds.gd index b9ee097..8f0fd5f 100644 --- a/scripts/autoload/sounds.gd +++ b/scripts/autoload/sounds.gd @@ -182,7 +182,7 @@ func load_jumping_sounds(): #load_jumping_sounds() #load_step_sounds() -signal loading_sounds +signal loading_sounds_progress(progress) signal loading_sounds_done var is_loading:bool = false @@ -233,8 +233,33 @@ func load_sounds(): # Because load() is synchronous, by the time the code reaches this line, # every single audio file is guaranteed to be 100% loaded. loading_done.emit() - -func _ready() -> void: - #for now always call his ass - load_sounds() +func unload_sounds(): + NORMAL_FOOTSTEP_SOUNDS = [] ##normal footsteps -- walking + HEAVY_FOOTSTEP_SOUNDS = [] ##heavy footsteps -- running + LIGHT_FOOTSTEP_SOUNDS = [] ##light footsteps -- crouching + SHUFFLE_FOOTSTEP_SOUNDS = [] ##shuffling -- random chance of playing while running + + FLASHLIGHT_CLICK_SOUNDS = [] ##flashlight click + + JUMP_LANDING_SOUNDS = [] + JUMP_STARTING_SOUNDS = [] + JUMP_LANDING_BREATH_SOUNDS = [] + JUMP_STARTING_BREATH_SOUNDS = [] + + BREATHE_IN_CALM = [] + BREATHE_IN_LOW = [] + BREATHE_IN_MID = [] + BREATHE_IN_HEAVY = [] + BREATHE_IN_MAX = [] + BREATHE_IN_EXHAUSTED = [] + + BREATHE_OUT_CALM = [] + BREATHE_OUT_LOW = [] + BREATHE_OUT_MID = [] + BREATHE_OUT_HEAVY = [] + BREATHE_OUT_MAX = [] + BREATHE_OUT_EXHAUSTED = [] + +func _ready(): + load_sounds()