From 90814db16ea23c6a0311d48244a5a207dc88c3a0 Mon Sep 17 00:00:00 2001 From: TechieDamien Date: Fri, 1 Aug 2025 13:53:45 +0100 Subject: [PATCH] Adds rules to main menu --- Scenes/main_menu.tscn | 134 +++++++++++++++++++++++++++++++++++++++++- Scripts/main_menu.gd | 13 ++++ 2 files changed, 146 insertions(+), 1 deletion(-) diff --git a/Scenes/main_menu.tscn b/Scenes/main_menu.tscn index 10bfe21..ebb4920 100644 --- a/Scenes/main_menu.tscn +++ b/Scenes/main_menu.tscn @@ -1,9 +1,14 @@ -[gd_scene load_steps=10 format=3 uid="uid://bu5cwjawsnb1q"] +[gd_scene load_steps=17 format=3 uid="uid://bu5cwjawsnb1q"] [ext_resource type="Script" uid="uid://bomw4j2mmerry" path="res://Scripts/main_menu.gd" id="1_28flt"] [ext_resource type="Texture2D" uid="uid://dxdtqv4do4x31" path="res://Sprites/background.png" id="2_48xlc"] [ext_resource type="Texture2D" uid="uid://c6kno4vjbvu28" path="res://Sprites/ouroboros.png" id="3_ce3w2"] [ext_resource type="Script" uid="uid://dp3dc6g76g8wq" path="res://Scripts/menu_ouroboros.gd" id="4_n45e2"] +[ext_resource type="Texture2D" uid="uid://bbutodjdye61j" path="res://Sprites/cherry.png" id="5_trj04"] +[ext_resource type="FontFile" uid="uid://cupgp2iqxdun5" path="res://Fonts/Kings-Regular.ttf" id="6_16hvj"] +[ext_resource type="Texture2D" uid="uid://dr3y3mvyrecxn" path="res://Sprites/lemon.png" id="7_vr1f0"] +[ext_resource type="Texture2D" uid="uid://csu4d06po6r6x" path="res://Sprites/apple.png" id="8_t1dhk"] +[ext_resource type="Texture2D" uid="uid://ccqroki031ou" path="res://Sprites/watermelon.png" id="9_5egv6"] [sub_resource type="LabelSettings" id="LabelSettings_ce3w2"] font_size = 160 @@ -25,6 +30,15 @@ font_color = Color(0.545098, 0, 0, 1) font_size = 160 font_color = Color(1, 1, 0, 1) +[sub_resource type="LabelSettings" id="LabelSettings_vtepg"] +line_spacing = -1.0 +paragraph_spacing = 1.0 + +[sub_resource type="LabelSettings" id="LabelSettings_8dnnj"] +font = ExtResource("6_16hvj") +font_size = 18 +font_color = Color(0, 0, 0, 1) + [node name="MainMenu" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -58,7 +72,12 @@ grow_vertical = 2 layout_mode = 2 text = "Start Game" +[node name="Help" type="Button" parent="Buttons"] +layout_mode = 2 +text = "How to Play" + [node name="Options" type="Button" parent="Buttons"] +visible = false layout_mode = 2 text = "Options" @@ -145,5 +164,118 @@ offset_bottom = 291.0 text = "s" label_settings = SubResource("LabelSettings_yhxw7") +[node name="HelpPanel" type="Panel" parent="."] +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.25 +anchor_top = 0.375 +anchor_right = 0.75 +anchor_bottom = 0.8 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="HelpPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +text = "A game of Ouroboros is about creating loops of snakes, called an Ouroboros. The aim is to create as many Ouroboroses as you can. + +To control your snake, you can use, WASD, arrow keys or Vi direction keys. + +Eating a fruit does not give you any points, but will increase the length of your snake according the type of fruit as shown below. + + +Each time you achieve an Ouroboros, you get one score and start as a new snake inside the old Ouroboros, making the arena smaller." +label_settings = SubResource("LabelSettings_vtepg") +autowrap_mode = 3 + +[node name="FruitExamples" type="HBoxContainer" parent="HelpPanel"] +layout_mode = 1 +anchors_preset = -1 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -107.0 +offset_bottom = -60.0 +grow_horizontal = 2 +grow_vertical = 0 + +[node name="Separator4" type="Control" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TextureRect" type="TextureRect" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +texture = ExtResource("5_trj04") +stretch_mode = 2 + +[node name="Label" type="Label" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +text = "=1" +label_settings = SubResource("LabelSettings_8dnnj") + +[node name="Separator" type="Control" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TextureRect2" type="TextureRect" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +texture = ExtResource("7_vr1f0") +stretch_mode = 2 + +[node name="Label2" type="Label" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +text = "=3" +label_settings = SubResource("LabelSettings_8dnnj") + +[node name="Separator2" type="Control" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TextureRect3" type="TextureRect" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +texture = ExtResource("8_t1dhk") +stretch_mode = 2 + +[node name="Label3" type="Label" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +text = "=5" +label_settings = SubResource("LabelSettings_8dnnj") + +[node name="Separator3" type="Control" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TextureRect4" type="TextureRect" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +texture = ExtResource("9_5egv6") +stretch_mode = 2 + +[node name="Label4" type="Label" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +text = "=10" +label_settings = SubResource("LabelSettings_8dnnj") + +[node name="Separator5" type="Control" parent="HelpPanel/FruitExamples"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Button" type="Button" parent="HelpPanel"] +layout_mode = 1 +anchors_preset = -1 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_bottom = 27.0 +grow_horizontal = 2 +grow_vertical = 0 +text = "OK" + [connection signal="pressed" from="Buttons/Start" to="." method="start_game"] +[connection signal="pressed" from="Buttons/Help" to="." method="show_help"] [connection signal="pressed" from="Buttons/Quit" to="." method="quit"] +[connection signal="pressed" from="HelpPanel/Button" to="." method="hide_help"] diff --git a/Scripts/main_menu.gd b/Scripts/main_menu.gd index 83f202e..164b0c5 100644 --- a/Scripts/main_menu.gd +++ b/Scripts/main_menu.gd @@ -2,8 +2,21 @@ extends Control var main_scene : PackedScene = preload("res://Scenes/main.tscn") +@onready +var help_panel : Panel = $HelpPanel + +func _ready() -> void: + if OS.has_feature("web"): + $Buttons/Quit.visible = false + func start_game() -> void: get_tree().change_scene_to_packed(main_scene) func quit() -> void: get_tree().quit(0) + +func show_help() -> void: + help_panel.visible = true + +func hide_help() -> void: + help_panel.visible = false