generated from krampus/template-godot4
Compare commits
3 Commits
0fc25d753f
...
b633ceb0c4
Author | SHA1 | Date |
---|---|---|
Rob Kelly | b633ceb0c4 | |
Rob Kelly | 8dd9e0b4c5 | |
Rob Kelly | 7d9c6997bc |
|
@ -187,22 +187,22 @@ select_putter={
|
|||
}
|
||||
club_next={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(105, 13),"global_position":Vector2(114, 59),"factor":1.0,"button_index":8,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
"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":4194306,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
club_previous={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(277, 2),"global_position":Vector2(286, 48),"factor":1.0,"button_index":9,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194306,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
ball_next={
|
||||
"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":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
"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":71,"key_label":0,"unicode":103,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
ball_previous={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":71,"key_label":0,"unicode":71,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
pause={
|
||||
|
|
|
@ -53,6 +53,10 @@ const NICE_THRESHOLD := 0.2
|
|||
## Force by which explosions knock the ball away
|
||||
const EXPLOSIVE_FORCE_FACTOR := 0.12
|
||||
|
||||
const CLUB_SELECT_ORDER: Array[Club.Type] = [
|
||||
Club.Type.DRIVER, Club.Type.IRON, Club.Type.WEDGE, Club.Type.SPECIAL, Club.Type.PUTTER
|
||||
]
|
||||
|
||||
## In Driving Range mode, the ball can be retrieved in the shot phase.
|
||||
@export var driving_range := false
|
||||
|
||||
|
@ -534,7 +538,21 @@ func _on_game_ball_changed(ball: GameBall) -> void:
|
|||
player_offset.position.z = z_offset
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
func _get_relative_club(delta: int, from: int = -1) -> Club.Type:
|
||||
from = from if from != -1 else club_type
|
||||
var old_idx := CLUB_SELECT_ORDER.find(from)
|
||||
var new_idx := wrapi(old_idx + delta, 0, len(CLUB_SELECT_ORDER))
|
||||
var new_club := CLUB_SELECT_ORDER[new_idx]
|
||||
|
||||
# UX behavior: if there is not club in the next slot, get the NEXT next slot, etc etc
|
||||
# NOTE: this will enter a loop if the player has no clubs!
|
||||
if not player.get_club(new_club):
|
||||
return _get_relative_club(delta, new_club)
|
||||
|
||||
return new_club
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
# REMOVEME
|
||||
if Input.is_action_just_pressed("ui_menu"):
|
||||
print("Debugging...")
|
||||
|
@ -544,24 +562,24 @@ func _process(delta: float) -> void:
|
|||
## Visual updates
|
||||
# Rotation
|
||||
direction.rotation.y = lerp_angle(
|
||||
direction.rotation.y, _target_rotation.y, delta * Game.settings.x_acceleration
|
||||
direction.rotation.y, _target_rotation.y, Game.settings.x_acceleration / 60.0
|
||||
)
|
||||
pitch.rotation.x = lerp_angle(
|
||||
pitch.rotation.x, _target_rotation.x, delta * Game.settings.y_acceleration
|
||||
pitch.rotation.x, _target_rotation.x, Game.settings.y_acceleration / 60.0
|
||||
)
|
||||
|
||||
# Arrow lags behind camera control
|
||||
arrow_pivot.rotation.y = lerp_angle(
|
||||
arrow_pivot.rotation.y, _target_rotation.y, delta * ARROW_ACCELERATION
|
||||
arrow_pivot.rotation.y, _target_rotation.y, ARROW_ACCELERATION / 60.0
|
||||
)
|
||||
# Player lags further behind
|
||||
player_pivot.rotation.y = lerp_angle(
|
||||
player_pivot.rotation.y, _target_rotation.y, delta * PLAYER_ACCELERATION
|
||||
player_pivot.rotation.y, _target_rotation.y, PLAYER_ACCELERATION / 60.0
|
||||
)
|
||||
|
||||
## Input Handling
|
||||
if control_disabled:
|
||||
if Input.is_action_just_pressed("camera_cancel"):
|
||||
if Input.is_action_just_pressed("camera_cancel", true):
|
||||
if is_instance_valid(_free_camera) and not _returning_free_camera:
|
||||
_returning_free_camera = true
|
||||
var tween := get_tree().create_tween()
|
||||
|
@ -581,72 +599,76 @@ func _process(delta: float) -> void:
|
|||
match phase:
|
||||
Phase.AIM:
|
||||
# Camera zoom
|
||||
if Input.is_action_just_pressed("shot_zoom_in"):
|
||||
if Input.is_action_just_pressed("shot_zoom_in", true):
|
||||
camera_distance = max(camera_distance - 1.0, ZOOM_MIN)
|
||||
if Input.is_action_just_pressed("shot_zoom_out"):
|
||||
if Input.is_action_just_pressed("shot_zoom_out", true):
|
||||
camera_distance = min(camera_distance + 1.0, ZOOM_MAX)
|
||||
|
||||
# Club select
|
||||
if Input.is_action_just_pressed("select_driver"):
|
||||
if Input.is_action_just_pressed("club_next", true):
|
||||
club_type = _get_relative_club(1)
|
||||
if Input.is_action_just_pressed("club_previous", true):
|
||||
club_type = _get_relative_club(-1)
|
||||
if Input.is_action_just_pressed("select_driver", true):
|
||||
club_type = Club.Type.DRIVER
|
||||
if Input.is_action_just_pressed("select_iron"):
|
||||
if Input.is_action_just_pressed("select_iron", true):
|
||||
club_type = Club.Type.IRON
|
||||
if Input.is_action_just_pressed("select_wedge"):
|
||||
if Input.is_action_just_pressed("select_wedge", true):
|
||||
club_type = Club.Type.WEDGE
|
||||
if Input.is_action_just_pressed("select_special"):
|
||||
if Input.is_action_just_pressed("select_special", true):
|
||||
club_type = Club.Type.SPECIAL
|
||||
if Input.is_action_just_pressed("select_putter"):
|
||||
if Input.is_action_just_pressed("select_putter", true):
|
||||
club_type = Club.Type.PUTTER
|
||||
|
||||
# Ball select
|
||||
if Input.is_action_just_pressed("ball_next"):
|
||||
if Input.is_action_just_pressed("ball_next", true):
|
||||
ball_type = player.next_ball(ball_type)
|
||||
if Input.is_action_just_pressed("ball_previous"):
|
||||
if Input.is_action_just_pressed("ball_previous", true):
|
||||
ball_type = player.prev_ball(ball_type)
|
||||
|
||||
# Switch to free cam
|
||||
if (
|
||||
Input.is_action_just_pressed("camera_back")
|
||||
or Input.is_action_just_pressed("camera_forward")
|
||||
or Input.is_action_just_pressed("camera_left")
|
||||
or Input.is_action_just_pressed("camera_right")
|
||||
Input.is_action_just_pressed("camera_back", true)
|
||||
or Input.is_action_just_pressed("camera_forward", true)
|
||||
or Input.is_action_just_pressed("camera_left", true)
|
||||
or Input.is_action_just_pressed("camera_right", true)
|
||||
):
|
||||
insert_free_cam()
|
||||
|
||||
# Advance to next phase
|
||||
if Input.is_action_just_pressed("shot_accept"):
|
||||
if Input.is_action_just_pressed("shot_accept", true):
|
||||
if player.get_balls(ball_type) != 0:
|
||||
# Check that player has enough of the selected ball (<0 means unlimited)
|
||||
phase = Phase.POWER_ADJUST
|
||||
# TODO play UI bonk if player doesn't have balls (lmao)
|
||||
Phase.POWER_ADJUST:
|
||||
if Input.is_action_just_pressed("shot_accept"):
|
||||
if Input.is_action_just_pressed("shot_accept", true):
|
||||
# TODO set power gauge parameters if needed
|
||||
character.start_upswing()
|
||||
hud.start_power_bar()
|
||||
if Input.is_action_just_pressed("shot_cancel"):
|
||||
if Input.is_action_just_pressed("shot_cancel", true):
|
||||
hud.reset_power_bar()
|
||||
phase = Phase.AIM
|
||||
if Input.is_action_just_released("shot_accept") and shot_power > 0:
|
||||
if Input.is_action_just_released("shot_accept", true) and shot_power > 0:
|
||||
hud.stop_power_bar()
|
||||
phase = Phase.CURVE_ADJUST
|
||||
Phase.CURVE_ADJUST:
|
||||
if Input.is_action_just_pressed("shot_cancel"):
|
||||
if Input.is_action_just_pressed("shot_cancel", true):
|
||||
hud.reset_curve_bar()
|
||||
phase = Phase.POWER_ADJUST
|
||||
if Input.is_action_just_pressed("shot_accept"):
|
||||
if Input.is_action_just_pressed("shot_accept", true):
|
||||
hud.stop_curve_bar()
|
||||
phase = Phase.DOWNSWING
|
||||
Phase.SHOT:
|
||||
if reset_enabled and Input.is_action_just_pressed("shot_reset"):
|
||||
if reset_enabled and Input.is_action_just_pressed("shot_reset", true):
|
||||
phase = Phase.SHOT_RESET
|
||||
reset_enabled = false
|
||||
return_ball()
|
||||
|
||||
if Input.is_action_just_pressed("activate_ball"):
|
||||
if Input.is_action_just_pressed("activate_ball", true):
|
||||
game_ball.activate_ability()
|
||||
|
||||
if driving_range and Input.is_action_just_pressed("shot_accept"):
|
||||
if driving_range and Input.is_action_just_pressed("shot_accept", true):
|
||||
phase = Phase.AIM
|
||||
return_ball()
|
||||
Phase.FINISHED:
|
||||
|
|
|
@ -31,10 +31,10 @@ func camera_motion(motion: Vector2) -> void:
|
|||
)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
func _physics_process(_delta: float) -> void:
|
||||
# Rotation
|
||||
rotation.y = lerp_angle(rotation.y, _target.y, delta * Game.settings.x_acceleration)
|
||||
rotation.x = lerp_angle(rotation.x, _target.x, delta * Game.settings.y_acceleration)
|
||||
rotation.y = lerp_angle(rotation.y, _target.y, Game.settings.x_acceleration / 60.0)
|
||||
rotation.x = lerp_angle(rotation.x, _target.x, Game.settings.y_acceleration / 60.0)
|
||||
|
||||
# Handle spatial movement
|
||||
var xz_input := Input.get_vector("camera_left", "camera_right", "camera_forward", "camera_back")
|
||||
|
@ -42,7 +42,7 @@ func _physics_process(delta: float) -> void:
|
|||
var direction := (transform.basis * Vector3(xz_input.x, y_input.y, xz_input.y)).normalized()
|
||||
|
||||
var speed := Game.settings.free_camera_speed
|
||||
if Input.is_action_pressed("camera_sprint"):
|
||||
if Input.is_action_pressed("camera_sprint", true):
|
||||
speed *= SPRINT_MULT
|
||||
|
||||
if direction:
|
||||
|
|
|
@ -1482,7 +1482,7 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
|
||||
[node name="PressStart" type="Label" parent="Menu"]
|
||||
modulate = Color(1, 1, 1, 0.98649)
|
||||
modulate = Color(1, 1, 1, 0.899996)
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
|
|
Loading…
Reference in New Issue