diff --git a/prefabs/paddle.tscn b/prefabs/paddle.tscn index 923cb05..c21fd8b 100644 --- a/prefabs/paddle.tscn +++ b/prefabs/paddle.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://dd0cxfceqwxca"] -[ext_resource type="Script" uid="uid://d0dti6pba80ci" path="res://Paddle.gd" id="1_q73f6"] +[ext_resource type="Script" uid="uid://d0dti6pba80ci" path="res://scripts/Paddle.gd" id="1_q73f6"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_e2o6t"] size = Vector2(33, 105) diff --git a/project.godot b/project.godot index 5994a63..ddeffd4 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="2025-08-23 Learning" -run/main_scene="uid://ct7v3x7imstlk" +run/main_scene="uid://d04c3lqwj6a5h" config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" @@ -37,3 +37,8 @@ down-1={ "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":75,"key_label":0,"unicode":107,"location":0,"echo":false,"script":null) ] } +key_exit={ +"deadzone": 0.2, +"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":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} diff --git a/resources/pong_theme.tres b/resources/pong_theme.tres new file mode 100644 index 0000000..5b737b1 --- /dev/null +++ b/resources/pong_theme.tres @@ -0,0 +1,101 @@ +[gd_resource type="Theme" load_steps=7 format=3 uid="uid://cga6aww0tbilq"] + +[sub_resource type="SystemFont" id="SystemFont_svo66"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_svo66"] +content_margin_left = 4.0 +content_margin_top = 4.0 +content_margin_right = 4.0 +content_margin_bottom = 4.0 +bg_color = Color(0.35417196, 0.23284352, 0.33606362, 1) +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 +corner_detail = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_u7j1g"] +content_margin_left = 4.0 +content_margin_top = 4.0 +content_margin_right = 4.0 +content_margin_bottom = 4.0 +bg_color = Color(0.35417196, 0.23284352, 0.33606362, 1) +draw_center = false +border_width_left = 2 +border_width_top = 2 +border_width_right = 2 +border_width_bottom = 2 +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 +corner_detail = 5 +expand_margin_left = 2.0 +expand_margin_top = 2.0 +expand_margin_right = 2.0 +expand_margin_bottom = 2.0 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gwd0w"] +content_margin_left = 136.0 +content_margin_right = 136.0 +bg_color = Color(0.42745098, 0.59607846, 0.7411765, 1) +border_width_left = 7 +border_width_top = 7 +border_width_right = 7 +border_width_bottom = 7 +expand_margin_left = 52.0 +expand_margin_top = 52.0 +expand_margin_right = 52.0 +expand_margin_bottom = 52.0 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gq8b7"] +content_margin_left = 136.0 +content_margin_right = 136.0 +bg_color = Color(0.20784314, 0.23921569, 0.2901961, 1) +border_width_left = 7 +border_width_top = 7 +border_width_right = 7 +border_width_bottom = 7 +expand_margin_left = 52.0 +expand_margin_top = 52.0 +expand_margin_right = 52.0 +expand_margin_bottom = 52.0 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5f4su"] +content_margin_left = 4.0 +content_margin_top = 4.0 +content_margin_right = 4.0 +content_margin_bottom = 4.0 +bg_color = Color(0.3529412, 0.23137255, 0.3372549, 1) +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 +corner_detail = 5 + +[resource] +Button/colors/font_color = Color(0.875, 0.875, 0.875, 1) +Button/colors/font_disabled_color = Color(0.875, 0.875, 0.875, 0.5) +Button/colors/font_focus_color = Color(0.95, 0.95, 0.95, 1) +Button/colors/font_hover_color = Color(0.95, 0.95, 0.95, 1) +Button/colors/font_hover_pressed_color = Color(1, 1, 1, 1) +Button/colors/font_outline_color = Color(0, 0, 0, 1) +Button/colors/font_pressed_color = Color(1, 1, 1, 1) +Button/colors/icon_disabled_color = Color(1, 1, 1, 0.4) +Button/colors/icon_focus_color = Color(1, 1, 1, 1) +Button/colors/icon_hover_color = Color(1, 1, 1, 1) +Button/colors/icon_hover_pressed_color = Color(1, 1, 1, 1) +Button/colors/icon_normal_color = Color(1, 1, 1, 1) +Button/colors/icon_pressed_color = Color(1, 1, 1, 1) +Button/constants/align_to_largest_stylebox = 0 +Button/constants/h_separation = 10 +Button/constants/icon_max_width = 0 +Button/constants/line_spacing = 6 +Button/constants/outline_size = 4 +Button/font_sizes/font_size = 72 +Button/fonts/font = SubResource("SystemFont_svo66") +Button/styles/disabled = SubResource("StyleBoxFlat_svo66") +Button/styles/focus = SubResource("StyleBoxFlat_u7j1g") +Button/styles/hover = SubResource("StyleBoxFlat_gwd0w") +Button/styles/normal = SubResource("StyleBoxFlat_gq8b7") +Button/styles/pressed = SubResource("StyleBoxFlat_5f4su") diff --git a/scenes/Main.tscn b/scenes/Main.tscn new file mode 100644 index 0000000..ad4a186 --- /dev/null +++ b/scenes/Main.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=4 format=3 uid="uid://dy4s4as4b07s8"] + +[ext_resource type="Script" uid="uid://bi1hbvswrw6yr" path="res://scripts/main.gd" id="1_0bbpv"] +[ext_resource type="PackedScene" uid="uid://d04c3lqwj6a5h" path="res://scenes/Start.tscn" id="2_rarhs"] +[ext_resource type="PackedScene" uid="uid://ct7v3x7imstlk" path="res://scenes/gameplay.tscn" id="3_vcsgt"] + +[node name="Main" type="Node2D"] +script = ExtResource("1_0bbpv") + +[node name="Start" parent="." instance=ExtResource("2_rarhs")] +z_index = 5 + +[node name="Gameplay" parent="." instance=ExtResource("3_vcsgt")] diff --git a/scenes/Start.tscn b/scenes/Start.tscn new file mode 100644 index 0000000..f36f169 --- /dev/null +++ b/scenes/Start.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=4 format=3 uid="uid://d04c3lqwj6a5h"] + +[ext_resource type="Script" uid="uid://d3rocjpvkb3te" path="res://scripts/start.gd" id="1_r305v"] +[ext_resource type="Theme" uid="uid://cga6aww0tbilq" path="res://resources/pong_theme.tres" id="3_gx2gx"] + +[sub_resource type="GDScript" id="GDScript_fx3ca"] +script/source = "extends VBoxContainer +" + +[node name="Start" 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_r305v") + +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.29000002, 0.402, 0.5, 1) + +[node name="CenterContainer" type="CenterContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] +layout_mode = 2 +theme_override_constants/separation = 175 +script = SubResource("GDScript_fx3ca") + +[node name="Button_Play" type="Button" parent="CenterContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +theme = ExtResource("3_gx2gx") +theme_override_colors/font_color = Color(0.87, 0.87, 0.87, 1) +theme_override_constants/outline_size = 2 +text = "Play" + +[node name="Button_Quit" type="Button" parent="CenterContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +theme = ExtResource("3_gx2gx") +theme_override_colors/font_color = Color(0.87, 0.87, 0.87, 1) +theme_override_constants/outline_size = 2 +text = "Quit" diff --git a/game.tscn b/scenes/gameplay.tscn similarity index 92% rename from game.tscn rename to scenes/gameplay.tscn index 3c52721..1d00c4e 100644 --- a/game.tscn +++ b/scenes/gameplay.tscn @@ -1,20 +1,22 @@ -[gd_scene load_steps=5 format=3 uid="uid://ct7v3x7imstlk"] +[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://wrequpaalk7f" path="res://ball.gd" id="2_e2o6t"] +[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="Root" type="Control"] +[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 @@ -88,7 +90,7 @@ layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 offset_top = 20.0 -offset_bottom = 43.0 +offset_bottom = 75.0 grow_horizontal = 2 [node name="Score-0" type="Label" parent="HBoxContainer"] diff --git a/Paddle.gd b/scripts/Paddle.gd similarity index 100% rename from Paddle.gd rename to scripts/Paddle.gd diff --git a/Paddle.gd.uid b/scripts/Paddle.gd.uid similarity index 100% rename from Paddle.gd.uid rename to scripts/Paddle.gd.uid diff --git a/ball.gd b/scripts/ball.gd similarity index 100% rename from ball.gd rename to scripts/ball.gd diff --git a/ball.gd.uid b/scripts/ball.gd.uid similarity index 100% rename from ball.gd.uid rename to scripts/ball.gd.uid diff --git a/scripts/gameplay.gd b/scripts/gameplay.gd new file mode 100644 index 0000000..2dc2421 --- /dev/null +++ b/scripts/gameplay.gd @@ -0,0 +1,8 @@ +extends Control + +func _ready(): + set_process(true) + +func _process(_delta): + if Input.is_action_pressed("key_exit"): + get_tree().change_scene_to_file("res://scenes/Start.tscn") diff --git a/scripts/gameplay.gd.uid b/scripts/gameplay.gd.uid new file mode 100644 index 0000000..d69a9e2 --- /dev/null +++ b/scripts/gameplay.gd.uid @@ -0,0 +1 @@ +uid://8lo33im7wrya diff --git a/scripts/start.gd b/scripts/start.gd new file mode 100644 index 0000000..c34a9d9 --- /dev/null +++ b/scripts/start.gd @@ -0,0 +1,10 @@ +extends Control +func _ready(): + %Button_Play.pressed.connect(play) + %Button_Quit.pressed.connect(quit_game) + +func play(): + get_tree().change_scene_to_file('res://scenes/gameplay.tscn') + +func quit_game(): + get_tree().quit() diff --git a/scripts/start.gd.uid b/scripts/start.gd.uid new file mode 100644 index 0000000..0e340f6 --- /dev/null +++ b/scripts/start.gd.uid @@ -0,0 +1 @@ +uid://d3rocjpvkb3te