adding joypad

This commit is contained in:
AleaJactaEst 2022-05-13 22:02:54 +02:00
parent 5597020a41
commit b94760ffe1
8 changed files with 279 additions and 12 deletions

View file

@ -301,3 +301,27 @@ msgstr "Reverse vertical"
msgid "NO_MOUSE_BUTTON"
msgstr "Nothing"
msgid "INPUT_VIEW_CAMERA_LEFT_JOYPAD"
msgstr "Camera Left (Joypad)"
msgid "INPUT_VIEW_CAMERA_RIGHT_JOYPAD"
msgstr "Camera Right (Joypad)"
msgid "INPUT_VIEW_CAMERA_FORWARD_JOYPAD"
msgstr "camera Up (Joypad)"
msgid "INPUT_VIEW_CAMERA_BACK_JOYPAD"
msgstr "Camera Down (Joypad)"
msgid "INPUT_ACTION_PLAYER_LEFT_JOYPAD"
msgstr "Move Left (Joypad)"
msgid "INPUT_ACTION_PLAYER_RIGHT_JOYPAD"
msgstr "Move Right (Joypad)"
msgid "INPUT_ACTION_PLAYER_FORWARD_JOYPAD"
msgstr "Move Up (Joypad)"
msgid "INPUT_ACTION_PLAYER_BACK_JOYPAD"
msgstr "Move Down (Joypad)"

View file

@ -301,3 +301,27 @@ msgstr "Inversé verticale"
msgid "NO_MOUSE_BUTTON"
msgstr "Rien n'est sélectionné"
msgid "INPUT_VIEW_CAMERA_LEFT_JOYPAD"
msgstr "Caméra à gauche (Manette)"
msgid "INPUT_VIEW_CAMERA_RIGHT_JOYPAD"
msgstr "Caméra à droite (Manette)"
msgid "INPUT_VIEW_CAMERA_FORWARD_JOYPAD"
msgstr "Caméra en haut (Manette)"
msgid "INPUT_VIEW_CAMERA_BACK_JOYPAD"
msgstr "Caméra en bas (Manette)"
msgid "INPUT_ACTION_PLAYER_LEFT_JOYPAD"
msgstr "Déplacer à gauche (Manette)"
msgid "INPUT_ACTION_PLAYER_RIGHT_JOYPAD"
msgstr "Déplacer à droite (Manette)"
msgid "INPUT_ACTION_PLAYER_FORWARD_JOYPAD"
msgstr "Déplacer en haut (Manette)"
msgid "INPUT_ACTION_PLAYER_BACK_JOYPAD"
msgstr "Déplacer en bas (Manette)"

Binary file not shown.

View file

@ -293,5 +293,39 @@ msgstr ""
msgid "NO_MOUSE_BUTTON"
msgstr ""
msgid "INPUT_VIEW_CAMERA_LEFT_JOYPAD"
msgstr ""
msgid "INPUT_VIEW_CAMERA_RIGHT_JOYPAD"
msgstr ""
msgid "INPUT_VIEW_CAMERA_FORWARD_JOYPAD"
msgstr ""
msgid "INPUT_VIEW_CAMERA_BACK_JOYPAD"
msgstr ""
msgid "INPUT_ACTION_PLAYER_LEFT_JOYPAD"
msgstr ""
msgid "INPUT_ACTION_PLAYER_RIGHT_JOYPAD"
msgstr ""
msgid "INPUT_ACTION_PLAYER_FORWARD_JOYPAD"
msgstr ""
msgid "INPUT_ACTION_PLAYER_BACK_JOYPAD"
msgstr ""
msgid "FACTOR_CAMERA_HORIZONTALE_JOYPAD"
msgstr ""
msgid "FACTOR_CAMERA_VERTICALE_JOYPAD"
msgstr ""
msgid "FACTOR_PLAYER_HORIZONTALE_JOYPAD"
msgstr ""
msgid "FACTOR_PLAYER_VERTICALE_JOYPAD"
msgstr ""

View file

@ -793,6 +793,15 @@ func rotate_camera_y(angle_y):
detect_camera_collision_y(-angle_y)
func rotate_player(angle_x, angle_y):
player_rotate_y += angle_y
if player_rotate_y > PI:
player_rotate_y -= TAU
elif player_rotate_y <= -PI:
player_rotate_y += TAU
rotate_y( -angle_y )
func move_camera(angle_x, angle_y):
var new_camera_rotate_x = camera_rotate_x + angle_x
if angle_x != 0.0 and new_camera_rotate_x <= PI_2 and new_camera_rotate_x >= - PI_2:
@ -943,7 +952,10 @@ func _process( delta ):
# Joypad
if tps:
var move_camera:Vector2 = Input.get_vector("INPUT_VIEW_CAMERA_LEFT_JOYPAD", "INPUT_VIEW_CAMERA_RIGHT_JOYPAD", "INPUT_VIEW_CAMERA_FORWARD_JOYPAD", "INPUT_VIEW_CAMERA_BACK_JOYPAD")
move_camera(move_camera.y * 0.04, move_camera.x * 0.04)
move_camera(move_camera.y * Common.get_factor_camera_verticale_joypad() * delta, move_camera.x * Common.get_factor_camera_horizontale_joypad() * delta)
var player_joypad:Vector2 = Input.get_vector("INPUT_ACTION_PLAYER_LEFT_JOYPAD", "INPUT_ACTION_PLAYER_RIGHT_JOYPAD", "INPUT_ACTION_PLAYER_FORWARD_JOYPAD", "INPUT_ACTION_PLAYER_BACK_JOYPAD")
#rotate_player(player_joypad.y * Common.get_factor_player_verticale_joypad() * delta, player_joypad.x * Common.get_factor_player_horizontale_joypad() * delta)
y += player_joypad.x * Common.get_factor_player_verticale_joypad()
if offset_camera_current != offset_camera_target:
var offset_diff = move_camera_y_one_step( offset_camera_target - offset_camera_current, MOVE_CAMERA_Y_OFFSET)

View file

@ -158,6 +158,14 @@ func update_joypad_motion():
$Window/v/Tab/JOYPAD/v/PlayerRight/h1/PlayerRight.set_text(Common.get_input_plus("INPUT_ACTION_PLAYER_RIGHT_JOYPAD"))
$Window/v/Tab/JOYPAD/v/PlayerForward/h1/PlayerForward.set_text(Common.get_input_plus("INPUT_ACTION_PLAYER_FORWARD_JOYPAD"))
$Window/v/Tab/JOYPAD/v/PlayerBack/h1/PlayerBack.set_text(Common.get_input_plus("INPUT_ACTION_PLAYER_BACK_JOYPAD"))
$Window/v/Tab/JOYPAD/v/FactorCameraHorizontale/FactorCameraHorizontale.set_value(Common.get_factor_camera_horizontale_joypad())
$Window/v/Tab/JOYPAD/v/FactorCameraHorizontale/value.set_text(str(Common.get_factor_camera_horizontale_joypad()))
$Window/v/Tab/JOYPAD/v/FactorCameraVerticale/FactorCameraVerticale.set_value(Common.get_factor_camera_verticale_joypad())
$Window/v/Tab/JOYPAD/v/FactorCameraVerticale/value.set_text(str(Common.get_factor_camera_verticale_joypad()))
$Window/v/Tab/JOYPAD/v/FactorPlayerHorizontale/FactorPlayerHorizontale.set_value(Common.get_factor_player_horizontale_joypad())
$Window/v/Tab/JOYPAD/v/FactorPlayerHorizontale/value.set_text(str(Common.get_factor_player_horizontale_joypad()))
$Window/v/Tab/JOYPAD/v/FactorPlayerVerticale/FactorPlayerVerticale.set_value(Common.get_factor_player_verticale_joypad())
$Window/v/Tab/JOYPAD/v/FactorPlayerVerticale/value.set_text(str(Common.get_factor_player_verticale_joypad()))
func configure_control():
@ -502,3 +510,23 @@ func _on_camera_player_move_reverse_horizontal_toggled(button_pressed):
func _on_camera_player_move_reverse_vertical_toggled(button_pressed):
Common.set_mouse_camera_player_move_reverse_vertical(button_pressed)
func _on_factor_camera_horizontale_value_changed(value):
$Window/v/Tab/JOYPAD/v/FactorCameraHorizontale/value.set_text(str(value))
Common.set_factor_camera_horizontale_joypad(value)
func _on_factor_camera_verticale_value_changed(value):
$Window/v/Tab/JOYPAD/v/FactorCameraVerticale/value.set_text(str(value))
Common.set_factor_camera_verticale_joypad(value)
func _on_factor_player_horizontale_value_changed(value):
$Window/v/Tab/JOYPAD/v/FactorPlayerHorizontale/value.set_text(str(value))
Common.set_factor_player_horizontale_joypad(value)
func _on_factor_player_verticale_value_changed(value):
$Window/v/Tab/JOYPAD/v/FactorPlayerVerticale/value.set_text(str(value))
Common.set_factor_player_verticale_joypad(value)

View file

@ -244,8 +244,8 @@ offset_right = 40.0
offset_bottom = 40.0
[node name="v" type="VBoxContainer" parent="Window/v/Tab/JOYPAD"]
offset_right = 318.0
offset_bottom = 572.0
offset_right = 384.0
offset_bottom = 724.0
size_flags_horizontal = 3
size_flags_vertical = 3
@ -303,6 +303,32 @@ text = "SELECT"
offset_right = 40.0
offset_bottom = 4.0
[node name="FactorCameraHorizontale" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 384.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/FactorCameraHorizontale"]
offset_right = 40.0
offset_bottom = 23.0
size_flags_horizontal = 3
text = "FACTOR_CAMERA_HORIZONTALE_JOYPAD"
[node name="FactorCameraHorizontale" type="HSlider" parent="Window/v/Tab/JOYPAD/v/FactorCameraHorizontale"]
offset_right = 8.0
offset_bottom = 16.0
size_flags_horizontal = 3
max_value = 10.0
step = 0.1
[node name="value" type="Label" parent="Window/v/Tab/JOYPAD/v/FactorCameraHorizontale"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="HSeparator3" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
[node name="CameraForward" type="VBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 40.0
@ -326,7 +352,7 @@ offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="HSeparator3" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
[node name="HSeparator4" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
@ -353,7 +379,33 @@ offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="HSeparator4" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
[node name="HSeparator5" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
[node name="FactorCameraVerticale" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 354.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/FactorCameraVerticale"]
offset_right = 40.0
offset_bottom = 23.0
size_flags_horizontal = 3
text = "FACTOR_CAMERA_VERTICALE_JOYPAD"
[node name="FactorCameraVerticale" type="HSlider" parent="Window/v/Tab/JOYPAD/v/FactorCameraVerticale"]
offset_right = 8.0
offset_bottom = 16.0
size_flags_horizontal = 3
max_value = 10.0
step = 0.1
[node name="value" type="Label" parent="Window/v/Tab/JOYPAD/v/FactorCameraVerticale"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="HSeparator6" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
@ -380,7 +432,7 @@ offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="HSeparator5" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
[node name="HSeparator7" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
@ -407,13 +459,39 @@ offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="HSeparator6" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
[node name="HSeparator8" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
[node name="FactorPlayerHorizontale" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 384.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/FactorPlayerHorizontale"]
offset_right = 40.0
offset_bottom = 23.0
size_flags_horizontal = 3
text = "FACTOR_PLAYER_HORIZONTALE_JOYPAD"
[node name="FactorPlayerHorizontale" type="HSlider" parent="Window/v/Tab/JOYPAD/v/FactorPlayerHorizontale"]
offset_right = 8.0
offset_bottom = 16.0
size_flags_horizontal = 3
max_value = 10.0
step = 0.1
[node name="value" type="Label" parent="Window/v/Tab/JOYPAD/v/FactorPlayerHorizontale"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="HSeparator9" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
[node name="PlayerForward" type="VBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 40.0
offset_right = 332.0
offset_bottom = 61.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/PlayerForward"]
offset_right = 40.0
@ -434,13 +512,13 @@ offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="HSeparator7" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
[node name="HSeparator10" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
[node name="PlayerBack" type="VBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 40.0
offset_right = 294.0
offset_bottom = 61.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/PlayerBack"]
offset_right = 40.0
@ -461,6 +539,32 @@ offset_right = 8.0
offset_bottom = 31.0
text = "SELECT"
[node name="HSeparator11" type="HSeparator" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 40.0
offset_bottom = 4.0
[node name="FactorPlayerVerticale" type="HBoxContainer" parent="Window/v/Tab/JOYPAD/v"]
offset_right = 354.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Window/v/Tab/JOYPAD/v/FactorPlayerVerticale"]
offset_right = 40.0
offset_bottom = 23.0
size_flags_horizontal = 3
text = "FACTOR_PLAYER_VERTICALE_JOYPAD"
[node name="FactorPlayerVerticale" type="HSlider" parent="Window/v/Tab/JOYPAD/v/FactorPlayerVerticale"]
offset_right = 8.0
offset_bottom = 16.0
size_flags_horizontal = 3
max_value = 10.0
step = 0.1
[node name="value" type="Label" parent="Window/v/Tab/JOYPAD/v/FactorPlayerVerticale"]
minimum_size = Vector2(50, 0)
offset_right = 40.0
offset_bottom = 23.0
[node name="Quit" type="Button" parent="Window/v"]
anchor_left = 0.5
anchor_top = 1.0
@ -497,10 +601,14 @@ metadata/_edit_use_custom_anchors = false
[connection signal="toggled" from="Window/v/Tab/MOUSE/v/CameraPlayerMove/h2/ReverseVertical" to="." method="_on_camera_player_move_reverse_vertical_toggled"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/CameraLeft/h1/CameraLeft" to="." method="_on_camera_left_pressed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/CameraRight/h1/CameraRight" to="." method="_on_camera_right_pressed"]
[connection signal="value_changed" from="Window/v/Tab/JOYPAD/v/FactorCameraHorizontale/FactorCameraHorizontale" to="." method="_on_factor_camera_horizontale_value_changed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/CameraForward/h1/CameraForward" to="." method="_on_camera_forward_pressed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/CameraBack/h1/CameraBack" to="." method="_on_camera_back_pressed"]
[connection signal="value_changed" from="Window/v/Tab/JOYPAD/v/FactorCameraVerticale/FactorCameraVerticale" to="." method="_on_factor_camera_verticale_value_changed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/PlayerLeft/h1/PlayerLeft" to="." method="_on_player_left_pressed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/PlayerRight/h1/PlayerRight" to="." method="_on_player_right_pressed"]
[connection signal="value_changed" from="Window/v/Tab/JOYPAD/v/FactorPlayerHorizontale/FactorPlayerHorizontale" to="." method="_on_factor_player_horizontale_value_changed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/PlayerForward/h1/PlayerForward" to="." method="_on_player_forward_pressed"]
[connection signal="pressed" from="Window/v/Tab/JOYPAD/v/PlayerBack/h1/PlayerBack" to="." method="_on_player_back_pressed"]
[connection signal="value_changed" from="Window/v/Tab/JOYPAD/v/FactorPlayerVerticale/FactorPlayerVerticale" to="." method="_on_factor_player_verticale_value_changed"]
[connection signal="pressed" from="Window/v/Quit" to="." method="_on_quit_pressed"]

View file

@ -10,6 +10,11 @@ var mouse_camera_only_reverse_vertical:bool = false
var mouse_camera_player_move_reverse_horizontal:bool = false
var mouse_camera_player_move_reverse_vertical:bool = false
var factor_camera_horizontale_joypad:float = 2.0
var factor_camera_verticale_joypad:float = 2.0
var factor_player_horizontale_joypad:float = 2.0
var factor_player_verticale_joypad:float = 2.0
func _ready():
randomize()
@ -291,3 +296,35 @@ func get_mul_mouse_camera_player_move_reverse_vertical() -> float:
return -1.0
else:
return 1.0
func set_factor_camera_horizontale_joypad(value:float):
factor_camera_horizontale_joypad = value
func get_factor_camera_horizontale_joypad() -> float:
return factor_camera_horizontale_joypad
func set_factor_camera_verticale_joypad(value:float):
factor_camera_verticale_joypad = value
func get_factor_camera_verticale_joypad() -> float:
return factor_camera_verticale_joypad
func set_factor_player_horizontale_joypad(value:float):
factor_player_horizontale_joypad = value
func get_factor_player_horizontale_joypad() -> float:
return factor_player_horizontale_joypad
func set_factor_player_verticale_joypad(value:float):
factor_player_verticale_joypad = value
func get_factor_player_verticale_joypad() -> float:
return factor_player_verticale_joypad