Added initial gamepad menu support
This commit is contained in:
parent
99b8c777c7
commit
9d19dc41ee
@ -15,5 +15,5 @@ Pong made poorly in godot. Just trying to make a some what complete projoct and
|
|||||||
- CPU logic for single player (or CPU only) 🤖
|
- CPU logic for single player (or CPU only) 🤖
|
||||||
- A settings menu that persists between launches 📓
|
- A settings menu that persists between launches 📓
|
||||||
- Some form of network multiplayer 💻
|
- Some form of network multiplayer 💻
|
||||||
- Select menu options via gamepad 🎮
|
- ~Select menu options via gamepad 🎮~
|
||||||
- More sprite effects or fx in general 🔥
|
- More sprite effects or fx in general 🔥
|
||||||
|
@ -45,6 +45,79 @@ window=false
|
|||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
ui_accept={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777222,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_select={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_cancel={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_focus_next={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":5,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_focus_prev={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":4,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_page_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777235,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_page_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777236,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":7,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
P1_Up={
|
P1_Up={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
6
src/Screens/MainMenu.gd
Normal file
6
src/Screens/MainMenu.gd
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
onready var play_button: Button = $MenuButtons/PlayButton
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
play_button.grab_focus()
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=9 format=2]
|
[gd_scene load_steps=10 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://assets-raw/BBB_Simulator_Black.otf" type="DynamicFontData" id=1]
|
[ext_resource path="res://assets-raw/BBB_Simulator_Black.otf" type="DynamicFontData" id=1]
|
||||||
[ext_resource path="res://assets/Background.png" type="Texture" id=2]
|
[ext_resource path="res://assets/Background.png" type="Texture" id=2]
|
||||||
@ -6,6 +6,7 @@
|
|||||||
[ext_resource path="res://src/UI/QuitButton.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://src/UI/QuitButton.tscn" type="PackedScene" id=4]
|
||||||
[ext_resource path="res://src/UI/ChangeScene.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://src/UI/ChangeScene.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://src/UI/Title.tscn" type="PackedScene" id=6]
|
[ext_resource path="res://src/UI/Title.tscn" type="PackedScene" id=6]
|
||||||
|
[ext_resource path="res://src/Screens/MainMenu.gd" type="Script" id=7]
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
[sub_resource type="DynamicFont" id=1]
|
||||||
font_data = ExtResource( 1 )
|
font_data = ExtResource( 1 )
|
||||||
@ -17,6 +18,7 @@ default_font = SubResource( 1 )
|
|||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
theme = ExtResource( 3 )
|
theme = ExtResource( 3 )
|
||||||
|
script = ExtResource( 7 )
|
||||||
|
|
||||||
[node name="Background" type="TextureRect" parent="."]
|
[node name="Background" type="TextureRect" parent="."]
|
||||||
modulate = Color( 0, 0, 0, 1 )
|
modulate = Color( 0, 0, 0, 1 )
|
||||||
@ -51,6 +53,8 @@ alignment = 1
|
|||||||
[node name="PlayButton" parent="MenuButtons" instance=ExtResource( 5 )]
|
[node name="PlayButton" parent="MenuButtons" instance=ExtResource( 5 )]
|
||||||
margin_right = 171.0
|
margin_right = 171.0
|
||||||
margin_bottom = 47.0
|
margin_bottom = 47.0
|
||||||
|
focus_next = NodePath("../QuitButton")
|
||||||
|
focus_previous = NodePath("../QuitButton")
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
text = "Play"
|
text = "Play"
|
||||||
next_scene_path = "res://src/Screens/Game.tscn"
|
next_scene_path = "res://src/Screens/Game.tscn"
|
||||||
@ -59,4 +63,6 @@ next_scene_path = "res://src/Screens/Game.tscn"
|
|||||||
margin_top = 51.0
|
margin_top = 51.0
|
||||||
margin_right = 171.0
|
margin_right = 171.0
|
||||||
margin_bottom = 99.0
|
margin_bottom = 99.0
|
||||||
|
focus_next = NodePath("../PlayButton")
|
||||||
|
focus_previous = NodePath("../PlayButton")
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
@ -52,6 +52,8 @@ alignment = 1
|
|||||||
[node name="Restart" parent="MenuButtons" instance=ExtResource( 5 )]
|
[node name="Restart" parent="MenuButtons" instance=ExtResource( 5 )]
|
||||||
margin_right = 171.0
|
margin_right = 171.0
|
||||||
margin_bottom = 40.0
|
margin_bottom = 40.0
|
||||||
|
focus_next = NodePath("../MainMenuButton")
|
||||||
|
focus_previous = NodePath("../QuitButton")
|
||||||
text = "Restart"
|
text = "Restart"
|
||||||
next_scene_path = "res://src/Screens/Game.tscn"
|
next_scene_path = "res://src/Screens/Game.tscn"
|
||||||
|
|
||||||
@ -59,6 +61,8 @@ next_scene_path = "res://src/Screens/Game.tscn"
|
|||||||
margin_top = 44.0
|
margin_top = 44.0
|
||||||
margin_right = 171.0
|
margin_right = 171.0
|
||||||
margin_bottom = 84.0
|
margin_bottom = 84.0
|
||||||
|
focus_next = NodePath("../QuitButton")
|
||||||
|
focus_previous = NodePath("../Restart")
|
||||||
text = "Main Menu"
|
text = "Main Menu"
|
||||||
next_scene_path = "res://src/Screens/MainMenu.tscn"
|
next_scene_path = "res://src/Screens/MainMenu.tscn"
|
||||||
|
|
||||||
@ -66,3 +70,5 @@ next_scene_path = "res://src/Screens/MainMenu.tscn"
|
|||||||
margin_top = 88.0
|
margin_top = 88.0
|
||||||
margin_right = 171.0
|
margin_right = 171.0
|
||||||
margin_bottom = 128.0
|
margin_bottom = 128.0
|
||||||
|
focus_next = NodePath("../Restart")
|
||||||
|
focus_previous = NodePath("../MainMenuButton")
|
||||||
|
@ -4,6 +4,7 @@ onready var scene_tree = get_tree()
|
|||||||
onready var p1_score: Label = $P1Score
|
onready var p1_score: Label = $P1Score
|
||||||
onready var p2_score: Label = $P2Score
|
onready var p2_score: Label = $P2Score
|
||||||
onready var pause_overlay: ColorRect = $PauseOverlay
|
onready var pause_overlay: ColorRect = $PauseOverlay
|
||||||
|
onready var main_menu_button: Button = $PauseOverlay/MenuButtons/MainMenuButton
|
||||||
|
|
||||||
var paused: = false setget set_paused
|
var paused: = false setget set_paused
|
||||||
|
|
||||||
@ -28,3 +29,5 @@ func set_paused(value: bool) -> void:
|
|||||||
paused = value
|
paused = value
|
||||||
scene_tree.paused = value
|
scene_tree.paused = value
|
||||||
pause_overlay.visible = value
|
pause_overlay.visible = value
|
||||||
|
if value:
|
||||||
|
main_menu_button.grab_focus()
|
||||||
|
@ -66,6 +66,8 @@ alignment = 1
|
|||||||
margin_top = 7.0
|
margin_top = 7.0
|
||||||
margin_right = 171.0
|
margin_right = 171.0
|
||||||
margin_bottom = 47.0
|
margin_bottom = 47.0
|
||||||
|
focus_next = NodePath("../QuitButton")
|
||||||
|
focus_previous = NodePath("../QuitButton")
|
||||||
text = "Main Menu"
|
text = "Main Menu"
|
||||||
next_scene_path = "res://src/Screens/MainMenu.tscn"
|
next_scene_path = "res://src/Screens/MainMenu.tscn"
|
||||||
|
|
||||||
@ -73,3 +75,5 @@ next_scene_path = "res://src/Screens/MainMenu.tscn"
|
|||||||
margin_top = 51.0
|
margin_top = 51.0
|
||||||
margin_right = 171.0
|
margin_right = 171.0
|
||||||
margin_bottom = 91.0
|
margin_bottom = 91.0
|
||||||
|
focus_next = NodePath("../MainMenuButton")
|
||||||
|
focus_previous = NodePath("../MainMenuButton")
|
||||||
|
Loading…
Reference in New Issue
Block a user