Add menu system and scene navigation
The changes include: - Moving script files to scripts/ directory - Creating Start menu scene with Play/Quit buttons - Adding scene switching between menu and gameplay - Creating theme for menu buttons - Adding ESC key to return to menu
This commit is contained in:
parent
83ff6ef14d
commit
49988ae674
14 changed files with 202 additions and 6 deletions
110
scenes/gameplay.tscn
Normal file
110
scenes/gameplay.tscn
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://ct7v3x7imstlk"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dd0cxfceqwxca" path="res://prefabs/paddle.tscn" id="1_80nbo"]
|
||||
[ext_resource type="Script" uid="uid://8lo33im7wrya" path="res://scripts/gameplay.gd" id="1_oe8ih"]
|
||||
[ext_resource type="Script" uid="uid://wrequpaalk7f" path="res://scripts/ball.gd" id="2_e2o6t"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mwb40"]
|
||||
size = Vector2(1200, 20)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_feb5d"]
|
||||
|
||||
[node name="Gameplay" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_oe8ih")
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = 2.0
|
||||
offset_bottom = 2.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.184063, 0.191379, 0.203873, 1)
|
||||
|
||||
[node name="MiddleLine" type="ColorRect" parent="."]
|
||||
custom_minimum_size = Vector2(4, 0)
|
||||
layout_mode = 1
|
||||
anchors_preset = 13
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.938114, 0.940897, 0.945648, 1)
|
||||
|
||||
[node name="TopWall" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TopWall"]
|
||||
position = Vector2(571, 0)
|
||||
shape = SubResource("RectangleShape2D_mwb40")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="TopWall"]
|
||||
polygon = PackedVector2Array(-30, -10, -30, 10, 1172, 10, 1172, -10)
|
||||
|
||||
[node name="BottomWall" type="StaticBody2D" parent="."]
|
||||
position = Vector2(0, 649)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BottomWall"]
|
||||
position = Vector2(571, 0)
|
||||
shape = SubResource("RectangleShape2D_mwb40")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="BottomWall"]
|
||||
polygon = PackedVector2Array(-30, -10, -30, 10, 1172, 10, 1172, -10)
|
||||
|
||||
[node name="Paddle-0" parent="." node_paths=PackedStringArray("score_label") instance=ExtResource("1_80nbo")]
|
||||
position = Vector2(40, 273)
|
||||
score_label = NodePath("../HBoxContainer/Score-0")
|
||||
|
||||
[node name="Paddle-1" parent="." node_paths=PackedStringArray("score_label") instance=ExtResource("1_80nbo")]
|
||||
position = Vector2(1078, 273)
|
||||
player_id = 1
|
||||
score_label = NodePath("../HBoxContainer/Score-1")
|
||||
|
||||
[node name="Ball" type="CharacterBody2D" parent="." node_paths=PackedStringArray("paddle_0", "paddle_1")]
|
||||
position = Vector2(134, 72)
|
||||
motion_mode = 1
|
||||
script = ExtResource("2_e2o6t")
|
||||
paddle_0 = NodePath("../Paddle-0")
|
||||
paddle_1 = NodePath("../Paddle-1")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="Ball"]
|
||||
polygon = PackedVector2Array(100, 75, 120, 75, 120, 95, 100, 95)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ball"]
|
||||
position = Vector2(110, 85)
|
||||
shape = SubResource("RectangleShape2D_feb5d")
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="Ball"]
|
||||
position = Vector2(110, 85)
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_top = 20.0
|
||||
offset_bottom = 75.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="Score-0" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 40
|
||||
text = "00"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Score-1" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 40
|
||||
text = "00"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[connection signal="screen_exited" from="Ball/VisibleOnScreenNotifier2D" to="Ball" method="_on_screen_exited"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue