Compare commits

..

4 commits

Author SHA1 Message Date
cf7c9fcc14 Full Controller Menu Support 2023-04-10 22:46:15 +02:00
02f141a6ef Code Cleaning 2023-04-10 22:19:54 +02:00
b45a090d23 Controler Aim 2023-04-10 22:18:16 +02:00
364ec9a959 Player Movement and Attack Controller support 2023-04-10 22:02:00 +02:00
7 changed files with 143 additions and 18 deletions

View file

@ -4,8 +4,13 @@
[ext_resource type="Script" path="res://Scripts/UI/Remaping/RemapController.gd" id="2_2f8ap"]
[ext_resource type="Script" path="res://Scripts/UI/Remaping/RemapButton.gd" id="2_4asaa"]
[node name="SettingsMenu" type="Node" node_paths=PackedStringArray("display_options_button", "vsync_toggle", "resolutions_options_button", "master_volume_slider", "music_volume_slider", "sfx_volume_slider")]
[node name="SettingsMenu" type="Node" node_paths=PackedStringArray("back_button", "tab_container", "bottom_item_video", "bottom_item_audio", "bottom_item_controls", "display_options_button", "vsync_toggle", "resolutions_options_button", "master_volume_slider", "music_volume_slider", "sfx_volume_slider")]
script = ExtResource("1_2rgd2")
back_button = NodePath("Back Button")
tab_container = NodePath("CenterContainer/SettingsTabs")
bottom_item_video = NodePath("CenterContainer/SettingsTabs/Video/MarginContainer/VideoSettings/ResolutionsOptions")
bottom_item_audio = NodePath("CenterContainer/SettingsTabs/Audio/MarginContainer/AudioSettings/SFXVolSlider")
bottom_item_controls = NodePath("CenterContainer/SettingsTabs/Controls/MarginContainer/ControlSettings/MoveRightRemapButton")
display_options_button = NodePath("CenterContainer/SettingsTabs/Video/MarginContainer/VideoSettings/DisplayModeOptions")
vsync_toggle = NodePath("CenterContainer/SettingsTabs/Video/MarginContainer/VideoSettings/VsyncButton")
resolutions_options_button = NodePath("CenterContainer/SettingsTabs/Video/MarginContainer/VideoSettings/ResolutionsOptions")
@ -113,6 +118,7 @@ vertical_alignment = 1
custom_minimum_size = Vector2(500, 40)
layout_mode = 2
size_flags_horizontal = 10
focus_neighbor_bottom = NodePath("../../../../../../Back Button")
fit_to_longest_item = false
[node name="Audio" type="VBoxContainer" parent="CenterContainer/SettingsTabs"]
@ -175,6 +181,7 @@ vertical_alignment = 1
custom_minimum_size = Vector2(500, 40)
layout_mode = 2
size_flags_horizontal = 10
focus_neighbor_bottom = NodePath("../../../../../../Back Button")
min_value = -72.0
max_value = 0.0
@ -261,6 +268,7 @@ vertical_alignment = 1
custom_minimum_size = Vector2(500, 40)
layout_mode = 2
size_flags_horizontal = 10
focus_neighbor_bottom = NodePath("../../../../../../Back Button")
toggle_mode = true
script = ExtResource("2_4asaa")
input_action_name = "move_right"

View file

@ -1,17 +1,17 @@
[gd_scene load_steps=14 format=3 uid="uid://4fysk8vaw3e1"]
[ext_resource type="Script" path="res://Scripts/UI/MainMenuManager.gd" id="1_qepq0"]
[ext_resource type="Texture2D" uid="uid://tjxkew3m4v8m" path="res://Assets/Sprites/Easter Egg/Shadow.png" id="2_8o6th"]
[ext_resource type="Texture2D" uid="uid://tjxkew3m4v8m" path="res://Assets/Sprites/Start Menu Old/Easter Egg/Shadow.png" id="2_8o6th"]
[ext_resource type="PackedScene" uid="uid://c4btepmue6d7p" path="res://Scenes/Game.tscn" id="2_28004"]
[ext_resource type="Texture2D" uid="uid://daat37cyg0go5" path="res://Assets/Sprites/Easter Egg/Egg 3.png" id="3_1e3fe"]
[ext_resource type="Texture2D" uid="uid://daat37cyg0go5" path="res://Assets/Sprites/Start Menu Old/Easter Egg/Egg 3.png" id="3_1e3fe"]
[ext_resource type="PackedScene" uid="uid://cbfcolm6mjolp" path="res://Prefabs/Settings Menu.tscn" id="3_r3r61"]
[ext_resource type="Texture2D" uid="uid://dhvvw4yckl8x7" path="res://Assets/Sprites/Props/Cake.png" id="5_7ull8"]
[ext_resource type="Texture2D" uid="uid://c3yg6u8yncau3" path="res://Assets/Sprites/Easter Egg/Egg 2.png" id="6_45o7d"]
[ext_resource type="Texture2D" uid="uid://cp84ssaqs3pmp" path="res://Assets/Sprites/UI Elements/Jesus.png" id="6_wnx18"]
[ext_resource type="Texture2D" uid="uid://dkotcqflp3e32" path="res://Assets/Sprites/Easter Egg/Egg 1.png" id="7_285vd"]
[ext_resource type="Texture2D" uid="uid://dhvvw4yckl8x7" path="res://Assets/Sprites/Start Menu Old/Cake.png" id="5_7ull8"]
[ext_resource type="Texture2D" uid="uid://c3yg6u8yncau3" path="res://Assets/Sprites/Start Menu Old/Easter Egg/Egg 2.png" id="6_45o7d"]
[ext_resource type="Texture2D" uid="uid://cp84ssaqs3pmp" path="res://Assets/Sprites/Start Menu Old/Jesus.png" id="6_wnx18"]
[ext_resource type="Texture2D" uid="uid://dkotcqflp3e32" path="res://Assets/Sprites/Start Menu Old/Easter Egg/Egg 1.png" id="7_285vd"]
[ext_resource type="Theme" uid="uid://o3vg845para" path="res://Assets/UI_Theme.tres" id="8_lr748"]
[ext_resource type="Script" path="res://Scripts/UI/MenuButton.gd" id="9_2cu5l"]
[ext_resource type="Texture2D" uid="uid://6snf183fgfo5" path="res://Assets/Sprites/UI Elements/Cross.png" id="12_dhfc0"]
[ext_resource type="Texture2D" uid="uid://6snf183fgfo5" path="res://Assets/Sprites/Start Menu Old/Cross.png" id="12_dhfc0"]
[ext_resource type="AudioStream" uid="uid://c6nf5s6xy2uii" path="res://Assets/Temp Music/omw-to-beat-the-big-bad.wav" id="13_3j724"]
[node name="MainMenu" type="Node" node_paths=PackedStringArray("default_focus")]

View file

@ -10,7 +10,8 @@ func _physics_process(delta : float):
func get_move_input_vector() -> Vector2:
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
return input_direction
var input_direction_controller = Input.get_vector("move_left_controller", "move_right_controller", "move_up_controller", "move_down_controller")
return (input_direction if not input_direction_controller.length() > input_direction.length() else input_direction_controller.normalized())
func update_player_movement(delta : float):
var input = get_move_input_vector()

View file

@ -22,6 +22,7 @@ func _on_play_button_pressed():
func _on_settings_button_pressed():
var settings_scene_instance = load(settings_scene.resource_path).instantiate()
settings_scene_instance.on_back = Callable(func(): default_focus.grab_focus())
get_tree().current_scene.add_child(settings_scene_instance)
pass

View file

@ -1,10 +1,18 @@
extends Node
# Video Settings UI References
@export var back_button : Control
@export var tab_container : TabContainer
@export var bottom_item_video : Control
@export var bottom_item_audio : Control
@export var bottom_item_controls : Control
@export var display_options_button : OptionButton
@export var vsync_toggle : CheckButton
@export var resolutions_options_button : OptionButton
var on_back : Callable
# Audio Settings UI References
@export var master_volume_slider : Slider
@export var music_volume_slider : Slider
@ -12,6 +20,9 @@ extends Node
# Engine Callbacks
func _ready():
back_button.grab_focus()
back_button.focus_neighbor_top = bottom_item_video.get_path()
add_resolution_items()
display_options_button.select(Save.game_data.display_mode)
GlobalSettings.set_display_mode(Save.game_data.display_mode)
@ -27,12 +38,36 @@ func _ready():
GlobalSettings.update_sfx_volume(Save.game_data.sfx_volume)
pass
func _process(delta):
update_change_tab()
pass
func update_change_tab():
var do_left = Input.is_action_just_pressed("ui_tab_left")
var do_right = Input.is_action_just_pressed("ui_tab_right")
if do_left:
var new_rab = tab_container.current_tab - 1
tab_container.current_tab = new_rab if new_rab >= 0 else tab_container.get_tab_count() - 1
if do_right:
var new_rab = tab_container.current_tab + 1
tab_container.current_tab = new_rab if new_rab < tab_container.get_tab_count() else 0
if do_left or do_right:
match tab_container.current_tab:
0: back_button.focus_neighbor_top = bottom_item_video.get_path()
1: back_button.focus_neighbor_top = bottom_item_audio.get_path()
2: back_button.focus_neighbor_top = bottom_item_controls.get_path()
back_button.grab_focus()
pass
func add_resolution_items():
for key in GlobalSettings.resolutions_dictionary.keys():
resolutions_options_button.add_item(key)
# Other Buttons
func _on_back_pressed():
on_back.call()
queue_free()
pass

View file

@ -6,13 +6,16 @@ extends Node2D
func _process(_delta):
rotate_to_pointer()
if Input.is_action_just_pressed("attack"):
if Input.is_action_just_pressed("attack") or Input.is_action_just_pressed("attack_controller"):
spawn_projectile(self.global_position, self.rotation, 350.0, 1)
pass
func get_aim_pos() -> Vector2:
var aim_dir_controller = Input.get_vector("aim_left_controller", "aim_right_controller", "aim_up_controller", "aim_down_controller").normalized()
return get_global_mouse_position() if aim_dir_controller.length() == 0 else self.global_position + aim_dir_controller
func rotate_to_pointer():
look_at(get_global_mouse_position())
#TODO Implement Joystick Aiming
look_at(get_aim_pos())
func spawn_projectile(pos : Vector2, dir : float, speed: float, damage : int):
var projectile = projectilePrefab.instantiate()

View file

@ -41,11 +41,31 @@ theme/custom="res://Assets/UI_Theme.tres"
[input]
ui_accept={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":4194309,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194310,"physical_keycode":0,"key_label":0,"unicode":4194310,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
]
}
ui_select={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
]
}
ui_cancel={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":4194305,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null)
]
}
ui_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":4194319,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
, 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":65,"key_label":0,"unicode":97,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
ui_right={
@ -53,6 +73,7 @@ ui_right={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":4194321,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
, 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":68,"key_label":0,"unicode":100,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
ui_up={
@ -60,6 +81,7 @@ ui_up={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":4194320,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
, 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":87,"key_label":0,"unicode":119,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
ui_down={
@ -67,40 +89,95 @@ ui_down={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":4194322,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
, 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":83,"key_label":0,"unicode":115,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
move_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
, 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":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
move_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
, 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":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
attack={
"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":1,"position":Vector2(139, 6),"global_position":Vector2(143, 49),"factor":1.0,"button_index":1,"pressed":true,"double_click":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
move_left_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
move_right_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
move_up_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
move_down_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
attack_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
]
}
aim_left_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
]
}
aim_right_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
]
}
aim_up_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
]
}
aim_down_controller={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
]
}
ui_tab_left={
"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":65,"key_label":0,"unicode":97,"echo":false,"script":null)
, 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":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null)
]
}
ui_tab_right={
"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":68,"key_label":0,"unicode":100,"echo":false,"script":null)
, 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":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
]
}