generated from krampus/template-godot4
Added logic for next/prev club select in shot setup
This commit is contained in:
parent
7d9c6997bc
commit
8dd9e0b4c5
|
@ -17,6 +17,7 @@ run/main_scene="res://src/game/game.tscn"
|
||||||
config/use_custom_user_dir=true
|
config/use_custom_user_dir=true
|
||||||
config/project_settings_override="user://settings.godot"
|
config/project_settings_override="user://settings.godot"
|
||||||
config/features=PackedStringArray("4.3", "Forward Plus")
|
config/features=PackedStringArray("4.3", "Forward Plus")
|
||||||
|
run/max_fps=60
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
|
@ -186,22 +187,22 @@ select_putter={
|
||||||
}
|
}
|
||||||
club_next={
|
club_next={
|
||||||
"deadzone": 0.5,
|
"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={
|
club_previous={
|
||||||
"deadzone": 0.5,
|
"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={
|
ball_next={
|
||||||
"deadzone": 0.5,
|
"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={
|
ball_previous={
|
||||||
"deadzone": 0.5,
|
"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={
|
pause={
|
||||||
|
|
|
@ -53,6 +53,10 @@ const NICE_THRESHOLD := 0.2
|
||||||
## Force by which explosions knock the ball away
|
## Force by which explosions knock the ball away
|
||||||
const EXPLOSIVE_FORCE_FACTOR := 0.12
|
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.
|
## In Driving Range mode, the ball can be retrieved in the shot phase.
|
||||||
@export var driving_range := false
|
@export var driving_range := false
|
||||||
|
|
||||||
|
@ -534,6 +538,20 @@ func _on_game_ball_changed(ball: GameBall) -> void:
|
||||||
player_offset.position.z = z_offset
|
player_offset.position.z = z_offset
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
func _process(_delta: float) -> void:
|
||||||
# REMOVEME
|
# REMOVEME
|
||||||
if Input.is_action_just_pressed("ui_menu"):
|
if Input.is_action_just_pressed("ui_menu"):
|
||||||
|
@ -587,6 +605,10 @@ func _process(_delta: float) -> void:
|
||||||
camera_distance = min(camera_distance + 1.0, ZOOM_MAX)
|
camera_distance = min(camera_distance + 1.0, ZOOM_MAX)
|
||||||
|
|
||||||
# Club select
|
# Club select
|
||||||
|
if Input.is_action_just_pressed("club_next"):
|
||||||
|
club_type = _get_relative_club(1)
|
||||||
|
if Input.is_action_just_pressed("club_previous"):
|
||||||
|
club_type = _get_relative_club(-1)
|
||||||
if Input.is_action_just_pressed("select_driver"):
|
if Input.is_action_just_pressed("select_driver"):
|
||||||
club_type = Club.Type.DRIVER
|
club_type = Club.Type.DRIVER
|
||||||
if Input.is_action_just_pressed("select_iron"):
|
if Input.is_action_just_pressed("select_iron"):
|
||||||
|
|
Loading…
Reference in New Issue