From 1c640fcd39cc2abdddf42bbbed79b30e4ba34e1e Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 27 Sep 2020 16:42:40 -0400 Subject: [PATCH] Added a main menu. - Controls section still not implemented. Dont thing we need it at all - Need to add last best score + player name Maybe... --- assets/HUD/fonts.png | Bin 855 -> 0 bytes assets/HUD/fonts.png.import | 34 ------ assets/HUD/new_bitmapfont.tres | 3 - assets/Theme/menu_font.tres | 9 ++ project.godot | 1 - src/HUD/PopupMessage.gd | 9 ++ src/HUD/PopupMessage.tscn | 43 ++++++++ src/Intro/Intro.tscn | 2 +- src/Menu/MainMenu.gd | 20 ++++ src/Menu/MainMenu.tscn | 188 +++++++++++++++++++++++++++++++++ 10 files changed, 270 insertions(+), 39 deletions(-) delete mode 100644 assets/HUD/fonts.png delete mode 100644 assets/HUD/fonts.png.import delete mode 100644 assets/HUD/new_bitmapfont.tres create mode 100644 assets/Theme/menu_font.tres create mode 100644 src/HUD/PopupMessage.gd create mode 100644 src/HUD/PopupMessage.tscn create mode 100644 src/Menu/MainMenu.gd create mode 100644 src/Menu/MainMenu.tscn diff --git a/assets/HUD/fonts.png b/assets/HUD/fonts.png deleted file mode 100644 index 7f8cc44c2a6aee74ce247b620b26f14f7d5e826f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 855 zcmV-d1E~CoP)BH0{GKtjj^2>8NmfQoH5-8~)- z*yS`Ot=8jmx7%&(vfWE5)o@T%RSy87HvcPnDW!TkU*ON*pXbW$=78DcC2Pnwl8fw0 zxY2No)p~hTpSR)$0L}yhl?}C_EX(9+yNF|XwO(HMl(A?;9Q$kXX~n{N*>-TzgAeGv{4}8wFoC)AG^PCOV@xLyw*2^sO)A=H+EA^@USp8|A5>cF%9plt( zdyiJ7XYm;(=GNfe^Qius5XCb9?k|I^XAs&B_+0;wJ_2~LHp=zCax72hi*qm~l5FuD zxCNbPFBbXDiIP%JE>k5>&LrmrX6^1x>LNE-}+8r}XnlG`-U zTANgf-D++}_uMfGAaFOiWtG1G1X!wMb#4T9Wl(rw2|cP=77;~Y|63Mc~d{qu1S79XkJQubarBWCf77>BXyMF z+2rM>@)^l>WM_>*9^yEWR{zrGTV3ib+)D)`zg1QBZjzX(9~NxA0uv}xUkqN4+k1s=~ttkz5O z{-x3Q=Gz4B^4|N3^&N3QzFAs!-rKF`PbP(2xQtNn>`?N~YQei{M-s_))_V void: + $CanvasLayer/Control/TextureRect/RichTextLabel.text = text + +func dismiss(): + queue_free() diff --git a/src/HUD/PopupMessage.tscn b/src/HUD/PopupMessage.tscn new file mode 100644 index 0000000..bf8f2d3 --- /dev/null +++ b/src/HUD/PopupMessage.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://assets/HUD/hud_stats_bg.png" type="Texture" id=1] +[ext_resource path="res://src/HUD/PopupMessage.gd" type="Script" id=2] +[ext_resource path="res://assets/Theme/Theme.tres" type="Theme" id=3] + +[node name="PopupMessage" type="Node2D"] +script = ExtResource( 2 ) + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="Control" type="Control" parent="CanvasLayer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TextureRect" type="TextureRect" parent="CanvasLayer/Control"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -139.5 +margin_top = -71.0 +margin_right = 139.5 +margin_bottom = 71.0 +texture = ExtResource( 1 ) +expand = true + +[node name="RichTextLabel" type="RichTextLabel" parent="CanvasLayer/Control/TextureRect"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -20.0 +margin_top = -20.0 +margin_right = 20.0 +margin_bottom = 20.0 +theme = ExtResource( 3 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/src/Intro/Intro.tscn b/src/Intro/Intro.tscn index 6df13d8..fd7e1a7 100644 --- a/src/Intro/Intro.tscn +++ b/src/Intro/Intro.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://src/Intro/Intro.gd" type="Script" id=2] [ext_resource path="res://assets/SplashScreen/SAGI.png" type="Texture" id=3] [ext_resource path="res://sound/SAGI.ogg" type="AudioStream" id=4] -[ext_resource path="res://src/Levels/LevelTemplate/LevelTemplate.tscn" type="PackedScene" id=5] +[ext_resource path="res://src/Menu/MainMenu.tscn" type="PackedScene" id=5] [ext_resource path="res://assets/Tiles/background_0.png" type="Texture" id=6] [ext_resource path="res://assets/SplashScreen/Title.png" type="Texture" id=7] [ext_resource path="res://assets/Items/torch_ligt_texture.png" type="Texture" id=8] diff --git a/src/Menu/MainMenu.gd b/src/Menu/MainMenu.gd new file mode 100644 index 0000000..f7f6e7e --- /dev/null +++ b/src/Menu/MainMenu.gd @@ -0,0 +1,20 @@ +extends Node2D + +func _ready() -> void: + $CanvasLayer/Control/VBoxContainer/NewGameBtn.grab_focus() + + +func _on_ExitGameBtn_pressed() -> void: + get_tree().quit(0) + pass # Replace with function body. + + +func _on_ControlsBtn_pressed() -> void: + print("Not working yet") + pass # Replace with function body. + + +func _on_NewGameBtn_pressed() -> void: + var next_scene = load("res://src/Levels/LevelTemplate/LevelTemplate.tscn") + get_tree().change_scene_to(next_scene) + queue_free() diff --git a/src/Menu/MainMenu.tscn b/src/Menu/MainMenu.tscn new file mode 100644 index 0000000..9e27ce1 --- /dev/null +++ b/src/Menu/MainMenu.tscn @@ -0,0 +1,188 @@ +[gd_scene load_steps=9 format=2] + +[ext_resource path="res://assets/Tiles/background_0.png" type="Texture" id=1] +[ext_resource path="res://assets/Tiles/background_2.png" type="Texture" id=2] +[ext_resource path="res://assets/Items/torch_ligt_texture.png" type="Texture" id=3] +[ext_resource path="res://assets/Tiles/background_1.png" type="Texture" id=4] +[ext_resource path="res://assets/SplashScreen/Title.png" type="Texture" id=5] +[ext_resource path="res://src/Menu/MainMenu.gd" type="Script" id=6] +[ext_resource path="res://assets/Theme/menu_font.tres" type="DynamicFont" id=7] + +[sub_resource type="Animation" id=1] +resource_name = "main" +length = 6.0 +loop = true +step = 1.0 +tracks/0/type = "value" +tracks/0/path = NodePath("Sprite/Light2D:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 3, 6 ), +"transitions": PoolRealArray( 1, 0.277392, 0.435275 ), +"update": 0, +"values": [ Vector2( 73, 131 ), Vector2( 63.25, 154.25 ), Vector2( 73, 131 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Sprite2/Light2D2:position") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 3, 6 ), +"transitions": PoolRealArray( 1, 0.277392, 0.554785 ), +"update": 0, +"values": [ Vector2( 105, 154.5 ), Vector2( 95.25, 177.75 ), Vector2( 105, 154.5 ) ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("Sprite3:position") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 3, 6 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Vector2( 0, 0 ), Vector2( 0, -13.5 ), Vector2( 0, 0 ) ] +} +tracks/3/type = "value" +tracks/3/path = NodePath("Sprite2:position") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0, 3, 6 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Vector2( 0, 0 ), Vector2( 0, -8 ), Vector2( 0, 0 ) ] +} +tracks/4/type = "value" +tracks/4/path = NodePath("Sprite2/Light2D2:color") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/keys = { +"times": PoolRealArray( 0, 3, 6 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Color( 0.65098, 0.964706, 0.588235, 1 ), Color( 0.984314, 0.811765, 0.0196078, 1 ), Color( 0.65098, 0.964706, 0.588235, 1 ) ] +} +tracks/5/type = "value" +tracks/5/path = NodePath("Sprite/Light2D:color") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/keys = { +"times": PoolRealArray( 0, 2, 4, 6 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 1 ), Color( 0.952941, 0.341176, 0.00784314, 1 ), Color( 0.952941, 0.0313726, 0.0117647, 1 ), Color( 1, 1, 1, 1 ) ] +} + +[node name="MainMenu" type="Node2D"] +script = ExtResource( 6 ) + +[node name="Node2D" type="Node2D" parent="."] +position = Vector2( -51, -39 ) +scale = Vector2( 2, 2 ) + +[node name="Sprite" type="Sprite" parent="Node2D"] +texture = ExtResource( 1 ) +centered = false + +[node name="Light2D" type="Light2D" parent="Node2D/Sprite"] +position = Vector2( 72.8142, 131.443 ) +scale = Vector2( 12.3889, 12.3889 ) +texture = ExtResource( 3 ) +color = Color( 0.976471, 0.515686, 0.505882, 1 ) + +[node name="Sprite2" type="Sprite" parent="Node2D"] +light_mask = -2147483646 +position = Vector2( 0, -2.66667 ) +texture = ExtResource( 4 ) +centered = false + +[node name="Light2D2" type="Light2D" parent="Node2D/Sprite2"] +position = Vector2( 104.814, 154.943 ) +scale = Vector2( 12.3889, 12.3889 ) +texture = ExtResource( 3 ) +color = Color( 0.762092, 0.913725, 0.398693, 1 ) +range_item_cull_mask = 3 +shadow_enabled = true + +[node name="Sprite3" type="Sprite" parent="Node2D"] +light_mask = 4 +position = Vector2( 0, -4.5 ) +texture = ExtResource( 2 ) +centered = false + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Node2D"] +autoplay = "main" +anims/main = SubResource( 1 ) + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="Control" type="NinePatchRect" parent="CanvasLayer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 15.0 +margin_top = 15.0 +margin_right = -15.0 +margin_bottom = -15.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control"] +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -125.0 +alignment = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="NewGameBtn" type="Button" parent="CanvasLayer/Control/VBoxContainer"] +margin_top = 151.0 +margin_right = 125.0 +margin_bottom = 178.0 +focus_neighbour_bottom = NodePath("../ControlsBtn") +custom_fonts/font = ExtResource( 7 ) +text = "New Game" + +[node name="ControlsBtn" type="Button" parent="CanvasLayer/Control/VBoxContainer"] +margin_top = 182.0 +margin_right = 125.0 +margin_bottom = 209.0 +focus_neighbour_top = NodePath("../NewGameBtn") +focus_neighbour_bottom = NodePath("../ExitGameBtn") +custom_fonts/font = ExtResource( 7 ) +text = "Controls" + +[node name="ExitGameBtn" type="Button" parent="CanvasLayer/Control/VBoxContainer"] +margin_top = 213.0 +margin_right = 125.0 +margin_bottom = 240.0 +focus_neighbour_top = NodePath("../ControlsBtn") +custom_fonts/font = ExtResource( 7 ) +text = "Exit" + +[node name="TextureRect" type="TextureRect" parent="CanvasLayer"] +margin_left = 38.0 +margin_top = 35.0 +margin_right = 237.0 +margin_bottom = 147.0 +texture = ExtResource( 5 ) +expand = true +stretch_mode = 5 +__meta__ = { +"_edit_use_anchors_": false +} +[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/NewGameBtn" to="." method="_on_NewGameBtn_pressed"] +[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/ControlsBtn" to="." method="_on_ControlsBtn_pressed"] +[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/ExitGameBtn" to="." method="_on_ExitGameBtn_pressed"]