diff --git a/project.godot b/project.godot index ac04dd8..81512dd 100644 --- a/project.godot +++ b/project.godot @@ -55,6 +55,8 @@ config/controls/camera/y_axis_sensitivity=0.45 config/controls/camera/x_axis_acceleration=30.0 config/controls/camera/y_axis_acceleration=30.0 config/controls/camera/invert_pitch=false +config/accessibility/enable_screen_shake=true +config/accessibility/enable_hit_lag=true [global_group] @@ -147,6 +149,26 @@ select_putter={ "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":53,"key_label":0,"unicode":53,"location":0,"echo":false,"script":null) ] } +debug_1={ +"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":4194332,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +debug_2={ +"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":4194333,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +debug_3={ +"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":4194334,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +debug_4={ +"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":4194335,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} [layer_names] diff --git a/src/characters/player_characters/gfolf_girl/gfolf_girl.tscn b/src/characters/player_characters/gfolf_girl/gfolf_girl.tscn index 755b46d..34cc7cd 100644 --- a/src/characters/player_characters/gfolf_girl/gfolf_girl.tscn +++ b/src/characters/player_characters/gfolf_girl/gfolf_girl.tscn @@ -169,7 +169,7 @@ bones/23/scale = Vector3(1, 1, 1) visible = false [node name="BoneAttachment3D" type="BoneAttachment3D" parent="Armature/Skeleton3D" index="6"] -transform = Transform3D(-0.947388, 0.307308, -0.089546, -0.319114, -0.928605, 0.189367, -0.0249588, 0.207979, 0.977815, -0.157835, 3.16355, 0.865627) +transform = Transform3D(0.60239, -0.744503, 0.28782, 0.687246, 0.667162, 0.287382, -0.405979, 0.0246872, 0.913549, -1.05514, 5.19617, 0.0989584) bone_name = "Hand.R" bone_idx = 11 diff --git a/src/game/game.gd b/src/game/game.gd index d62245b..0fb09ce 100644 --- a/src/game/game.gd +++ b/src/game/game.gd @@ -79,6 +79,16 @@ func _finish_scene_load(instance: Node) -> void: func _process(_delta: float) -> void: + # REMOVEME + if Input.is_action_just_pressed("debug_1"): + viewport.hit_lag(1) + if Input.is_action_just_pressed("debug_2"): + viewport.hit_lag_small() + if Input.is_action_just_pressed("debug_3"): + viewport.hit_lag_big() + if Input.is_action_just_pressed("debug_4"): + viewport.hit_lag_huge() + if _loading_resources and not loading_screen.visible: loader_transition.play("fade_in") diff --git a/src/player/shot_setup/shot_setup.gd b/src/player/shot_setup/shot_setup.gd index 58ea3f2..20c1f35 100644 --- a/src/player/shot_setup/shot_setup.gd +++ b/src/player/shot_setup/shot_setup.gd @@ -28,6 +28,8 @@ const CAMERA_SNAP_TIME := 0.3 const WASTED_BALL_RETURN_DELAY := 3.5 +const BIG_POWER_THRESHOLD := 0.7 + ## In Driving Range mode, the ball can be retrieved in the shot phase. @export var driving_range := false @@ -142,6 +144,7 @@ var _tracking_camera: OrbitalCamera @onready var phys_ball_scene := preload("res://src/equipment/balls/physics_ball/physics_ball.tscn") @onready var world: World = get_tree().get_first_node_in_group(World.group) +@onready var game: Game = get_tree().get_first_node_in_group(Game.group) @onready var _target_rotation := Vector2(pitch.rotation.x, direction.rotation.y) @@ -206,6 +209,17 @@ func get_shot_impulse(meter_pct: float) -> Vector3: func take_shot() -> void: + # Impact screenshake & hitlag + if game: + if shot_power > BIG_POWER_THRESHOLD: + game.viewport.hit_lag_big() + var shake_intensity: float = ( + 10.0 * (shot_power - BIG_POWER_THRESHOLD) / (1.0 - BIG_POWER_THRESHOLD) + ) + game.viewport.screen_shake(shake_intensity, 1.0) + else: + game.viewport.hit_lag_small() + print_debug("WHACK!\nPower: ", shot_power, "\nCurve: ", shot_curve) var impulse := get_shot_impulse(shot_power) diff --git a/src/player/shot_setup/shot_setup.tscn b/src/player/shot_setup/shot_setup.tscn index 7503bb3..cb8f37d 100644 --- a/src/player/shot_setup/shot_setup.tscn +++ b/src/player/shot_setup/shot_setup.tscn @@ -179,7 +179,7 @@ tracks/2/keys = { [sub_resource type="Animation" id="Animation_u8k07"] resource_name = "swing_delay" -length = 0.2 +length = 0.0667 step = 0.01 tracks/0/type = "method" tracks/0/imported = false @@ -188,7 +188,7 @@ tracks/0/path = NodePath("%Direction/..") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { -"times": PackedFloat32Array(0.18), +"times": PackedFloat32Array(0.0667), "transitions": PackedFloat32Array(1), "values": [{ "args": [], diff --git a/src/ui/game_viewport_container.gd b/src/ui/game_viewport_container.gd index 1fb3bb0..51b6d60 100644 --- a/src/ui/game_viewport_container.gd +++ b/src/ui/game_viewport_container.gd @@ -1,13 +1,22 @@ class_name GameViewportContainer extends SubViewportContainer ## SubViewportContainer with game-specific special effects -var _screen_shake_intensity: float = 0.0 +const SMALL_HIT_LAG_FRAMES := 5 +const BIG_HIT_LAG_FRAMES := 10 +const HUGE_HIT_LAG_FRAMES := 20 + +var _screen_shake_intensity := 0.0 +var _hit_lag_frames := -1 @onready var root_control: Control = %RootControl +@onready var content: Node = %Content ## Start playing a screen shake effect. func screen_shake(intensity: float, duration: float = 0.2) -> void: + if not ProjectSettings.get_setting("game/config/accessibility/enable_screen_shake"): + return + var tween := get_tree().create_tween() _screen_shake_intensity = intensity tween.tween_property(self, "_screen_shake_intensity", 0.0, duration).set_trans( @@ -16,6 +25,29 @@ func screen_shake(intensity: float, duration: float = 0.2) -> void: tween.tween_callback(_reset_position) +## Hit lag for a small impact. +func hit_lag_small() -> void: + hit_lag(SMALL_HIT_LAG_FRAMES) + + +## Hit lag for a big impact. +func hit_lag_big() -> void: + hit_lag(BIG_HIT_LAG_FRAMES) + + +## Hit lag for a huge impact. +func hit_lag_huge() -> void: + hit_lag(HUGE_HIT_LAG_FRAMES) + + +## Stop processing for some number of frames. +func hit_lag(frames: int = 1) -> void: + if not ProjectSettings.get_setting("game/config/accessibility/enable_hit_lag"): + return + + _hit_lag_frames = frames + + func _reset_position() -> void: position = Vector2.ZERO @@ -24,3 +56,10 @@ func _process(_delta: float) -> void: if _screen_shake_intensity > 0: position.x = randfn(0, _screen_shake_intensity) position.y = randfn(0, _screen_shake_intensity) + + if _hit_lag_frames >= 0: + if _hit_lag_frames == 0: + content.process_mode = Node.PROCESS_MODE_INHERIT + else: + content.process_mode = Node.PROCESS_MODE_DISABLED + _hit_lag_frames -= 1