From 2c98c112bdb7473cadacbe658640d89e2f0f9651 Mon Sep 17 00:00:00 2001 From: VoidTwo Date: Mon, 15 Nov 2021 22:29:42 -0600 Subject: [PATCH] New features and plenty of code still in testing. This includes a level select, basic inventory, and a basic HUD. --- Enemies/Enemy.tscn | 19 +++++ GUI/HUD.gd | 18 +++++ GUI/HUD.tscn | 40 ++++++++++ GUI/Level Select Menu.gd | 33 ++++++++ GUI/Level Select Menu.tscn | 74 ++++++++++++++++++ Main Menu.gd => GUI/Main Menu.gd | 0 Main Menu.tscn => GUI/Main Menu.tscn | 4 +- Splash Screen.gd => GUI/Splash Screen.gd | 0 Splash Screen.tscn => GUI/Splash Screen.tscn | 2 +- Item.gd | 14 ++++ World.gd => Levels/Hub World.gd | 1 + Levels/Hub World.tscn | 21 +++++ Levels/Hub_World_Button_Normal.png | Bin 0 -> 141 bytes Levels/Hub_World_Button_Normal.png.import | 35 +++++++++ Levels/Level_1_Button_Normal.png | Bin 0 -> 121 bytes Levels/Level_1_Button_Normal.png.import | 35 +++++++++ Levels/Level_2_Button_Normal.png | Bin 0 -> 150 bytes Levels/Level_2_Button_Normal.png.import | 35 +++++++++ Levels/Level_3_Button_Normal.png | Bin 0 -> 160 bytes Levels/Level_3_Button_Normal.png.import | 35 +++++++++ Levels/Level_4_Button_Normal.png | Bin 0 -> 158 bytes Levels/Level_4_Button_Normal.png.import | 35 +++++++++ Levels/Level_5_Button_Normal.png | Bin 0 -> 148 bytes Levels/Level_5_Button_Normal.png.import | 35 +++++++++ Main.gd | 38 +++++++-- Main.tscn | 7 +- Player.gd | 24 ------ Player/Inventory.gd | 45 +++++++++++ Player/Inventory.tscn | 6 ++ Player/Player.gd | 59 ++++++++++++++ {Sprites => Player}/Player.png | Bin {Sprites => Player}/Player.png.import | 7 +- Player.tscn => Player/Player.tscn | 24 ++++-- {Sprites => Player}/Player_Down.png | Bin Player/Player_Down.png.import | 35 +++++++++ {Sprites => Player}/Player_Up.png | Bin {Sprites => Player}/Player_Up.png.import | 7 +- Sprites/Enemy.png | Bin 0 -> 141 bytes ...layer_Down.png.import => Enemy.png.import} | 7 +- Sprites/Health_Bar_Over.png | Bin 0 -> 138 bytes Sprites/Health_Bar_Over.png.import | 35 +++++++++ Sprites/Health_Bar_Progress.png | Bin 0 -> 83 bytes Sprites/Health_Bar_Progress.png.import | 35 +++++++++ Sprites/Health_Bar_Under.png | Bin 0 -> 83 bytes Sprites/Health_Bar_Under.png.import | 35 +++++++++ World.tscn | 12 --- project.godot | 9 ++- 47 files changed, 753 insertions(+), 68 deletions(-) create mode 100644 Enemies/Enemy.tscn create mode 100644 GUI/HUD.gd create mode 100644 GUI/HUD.tscn create mode 100644 GUI/Level Select Menu.gd create mode 100644 GUI/Level Select Menu.tscn rename Main Menu.gd => GUI/Main Menu.gd (100%) rename Main Menu.tscn => GUI/Main Menu.tscn (97%) rename Splash Screen.gd => GUI/Splash Screen.gd (100%) rename Splash Screen.tscn => GUI/Splash Screen.tscn (81%) create mode 100644 Item.gd rename World.gd => Levels/Hub World.gd (76%) create mode 100644 Levels/Hub World.tscn create mode 100644 Levels/Hub_World_Button_Normal.png create mode 100644 Levels/Hub_World_Button_Normal.png.import create mode 100644 Levels/Level_1_Button_Normal.png create mode 100644 Levels/Level_1_Button_Normal.png.import create mode 100644 Levels/Level_2_Button_Normal.png create mode 100644 Levels/Level_2_Button_Normal.png.import create mode 100644 Levels/Level_3_Button_Normal.png create mode 100644 Levels/Level_3_Button_Normal.png.import create mode 100644 Levels/Level_4_Button_Normal.png create mode 100644 Levels/Level_4_Button_Normal.png.import create mode 100644 Levels/Level_5_Button_Normal.png create mode 100644 Levels/Level_5_Button_Normal.png.import delete mode 100644 Player.gd create mode 100644 Player/Inventory.gd create mode 100644 Player/Inventory.tscn create mode 100644 Player/Player.gd rename {Sprites => Player}/Player.png (100%) rename {Sprites => Player}/Player.png.import (68%) rename Player.tscn => Player/Player.tscn (86%) rename {Sprites => Player}/Player_Down.png (100%) create mode 100644 Player/Player_Down.png.import rename {Sprites => Player}/Player_Up.png (100%) rename {Sprites => Player}/Player_Up.png.import (66%) create mode 100644 Sprites/Enemy.png rename Sprites/{Player_Down.png.import => Enemy.png.import} (68%) create mode 100644 Sprites/Health_Bar_Over.png create mode 100644 Sprites/Health_Bar_Over.png.import create mode 100644 Sprites/Health_Bar_Progress.png create mode 100644 Sprites/Health_Bar_Progress.png.import create mode 100644 Sprites/Health_Bar_Under.png create mode 100644 Sprites/Health_Bar_Under.png.import delete mode 100644 World.tscn diff --git a/Enemies/Enemy.tscn b/Enemies/Enemy.tscn new file mode 100644 index 0000000..c6c044a --- /dev/null +++ b/Enemies/Enemy.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://Sprites/Enemy.png" type="Texture" id=1] + +[sub_resource type="CapsuleShape2D" id=2] +radius = 3.0 +height = 2.0 + +[node name="Enemy" type="KinematicBody2D" groups=["enemies"]] +collision_mask = 0 + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 0, -3 ) +texture = ExtResource( 1 ) + +[node name="Hitbox" type="CollisionShape2D" parent="."] +visible = false +position = Vector2( 0, -3 ) +shape = SubResource( 2 ) diff --git a/GUI/HUD.gd b/GUI/HUD.gd new file mode 100644 index 0000000..b825515 --- /dev/null +++ b/GUI/HUD.gd @@ -0,0 +1,18 @@ +extends CanvasLayer + +signal add_currency(amount) + + +func _on_Add_Currency_pressed() -> void: + emit_signal('add_currency', 1) + return + + +func update_currency(amount: int) -> void: + $Currency.set_text(String(amount)) + return + + +func update_health(value: int) -> void: + $'Health Bar'.value = value + return diff --git a/GUI/HUD.tscn b/GUI/HUD.tscn new file mode 100644 index 0000000..04f8c2b --- /dev/null +++ b/GUI/HUD.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://GUI/HUD.gd" type="Script" id=1] +[ext_resource path="res://Sprites/Health_Bar_Under.png" type="Texture" id=2] +[ext_resource path="res://Sprites/Health_Bar_Progress.png" type="Texture" id=3] +[ext_resource path="res://Sprites/Health_Bar_Over.png" type="Texture" id=4] + +[node name="HUD" type="CanvasLayer"] +script = ExtResource( 1 ) + +[node name="Health Bar" type="TextureProgress" parent="."] +margin_right = 104.0 +margin_bottom = 18.0 +rect_min_size = Vector2( 104, 18 ) +texture_under = ExtResource( 2 ) +texture_over = ExtResource( 4 ) +texture_progress = ExtResource( 3 ) +tint_progress = Color( 0.431373, 1, 0.737255, 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Currency" type="Label" parent="."] +margin_left = 220.0 +margin_right = 320.0 +align = 2 +valign = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Add Currency" type="Button" parent="."] +margin_left = 300.0 +margin_top = 20.0 +margin_right = 320.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="pressed" from="Add Currency" to="." method="_on_Add_Currency_pressed"] diff --git a/GUI/Level Select Menu.gd b/GUI/Level Select Menu.gd new file mode 100644 index 0000000..acfb8c4 --- /dev/null +++ b/GUI/Level Select Menu.gd @@ -0,0 +1,33 @@ +extends Node + +signal complete(option) + + +func _on_hub_world_button_pressed() -> void: + emit_signal('complete', 'H') + return + + +func _on_level_1_button_pressed() -> void: + emit_signal('complete', '1') + return + + +func _on_level_2_button_pressed() -> void: + emit_signal('complete', '2') + return + + +func _on_level_3_button_pressed() -> void: + emit_signal('complete', '3') + return + + +func _on_level_4_button_pressed() -> void: + emit_signal('complete', '4') + return + + +func _on_level_5_button_pressed() -> void: + emit_signal('complete', '5') + return diff --git a/GUI/Level Select Menu.tscn b/GUI/Level Select Menu.tscn new file mode 100644 index 0000000..76ab6dd --- /dev/null +++ b/GUI/Level Select Menu.tscn @@ -0,0 +1,74 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://Levels/Level_3_Button_Normal.png" type="Texture" id=1] +[ext_resource path="res://Levels/Level_1_Button_Normal.png" type="Texture" id=2] +[ext_resource path="res://Levels/Level_4_Button_Normal.png" type="Texture" id=3] +[ext_resource path="res://Levels/Level_2_Button_Normal.png" type="Texture" id=4] +[ext_resource path="res://Levels/Level_5_Button_Normal.png" type="Texture" id=5] +[ext_resource path="res://Levels/Hub_World_Button_Normal.png" type="Texture" id=6] +[ext_resource path="res://GUI/Level Select Menu.gd" type="Script" id=7] + +[node name="Level Select Menu" type="Node"] +script = ExtResource( 7 ) + +[node name="MarginContainer" type="MarginContainer" parent="."] +margin_left = 10.0 +margin_top = 10.0 +margin_right = 310.0 +margin_bottom = 170.0 +rect_min_size = Vector2( 300, 160 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer"] +margin_right = 300.0 +margin_bottom = 160.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/CenterContainer"] +margin_left = 20.0 +margin_top = 60.0 +margin_right = 280.0 +margin_bottom = 100.0 + +[node name="Hub World" type="TextureButton" parent="MarginContainer/CenterContainer/HBoxContainer"] +margin_right = 40.0 +margin_bottom = 40.0 +texture_normal = ExtResource( 6 ) + +[node name="Level 1" type="TextureButton" parent="MarginContainer/CenterContainer/HBoxContainer"] +margin_left = 44.0 +margin_right = 84.0 +margin_bottom = 40.0 +texture_normal = ExtResource( 2 ) + +[node name="Level 2" type="TextureButton" parent="MarginContainer/CenterContainer/HBoxContainer"] +margin_left = 88.0 +margin_right = 128.0 +margin_bottom = 40.0 +texture_normal = ExtResource( 4 ) + +[node name="Level 3" type="TextureButton" parent="MarginContainer/CenterContainer/HBoxContainer"] +margin_left = 132.0 +margin_right = 172.0 +margin_bottom = 40.0 +texture_normal = ExtResource( 1 ) + +[node name="Level 4" type="TextureButton" parent="MarginContainer/CenterContainer/HBoxContainer"] +margin_left = 176.0 +margin_right = 216.0 +margin_bottom = 40.0 +texture_normal = ExtResource( 3 ) + +[node name="Level 5" type="TextureButton" parent="MarginContainer/CenterContainer/HBoxContainer"] +margin_left = 220.0 +margin_right = 260.0 +margin_bottom = 40.0 +texture_normal = ExtResource( 5 ) + +[connection signal="pressed" from="MarginContainer/CenterContainer/HBoxContainer/Hub World" to="." method="_on_hub_world_button_pressed"] +[connection signal="pressed" from="MarginContainer/CenterContainer/HBoxContainer/Level 1" to="." method="_on_level_1_button_pressed"] +[connection signal="pressed" from="MarginContainer/CenterContainer/HBoxContainer/Level 2" to="." method="_on_level_2_button_pressed"] +[connection signal="pressed" from="MarginContainer/CenterContainer/HBoxContainer/Level 3" to="." method="_on_level_3_button_pressed"] +[connection signal="pressed" from="MarginContainer/CenterContainer/HBoxContainer/Level 4" to="." method="_on_level_4_button_pressed"] +[connection signal="pressed" from="MarginContainer/CenterContainer/HBoxContainer/Level 5" to="." method="_on_level_5_button_pressed"] diff --git a/Main Menu.gd b/GUI/Main Menu.gd similarity index 100% rename from Main Menu.gd rename to GUI/Main Menu.gd diff --git a/Main Menu.tscn b/GUI/Main Menu.tscn similarity index 97% rename from Main Menu.tscn rename to GUI/Main Menu.tscn index 01f1acd..b8c26d9 100644 --- a/Main Menu.tscn +++ b/GUI/Main Menu.tscn @@ -13,7 +13,7 @@ [ext_resource path="res://Sprites/Quit_Button_Hover.png" type="Texture" id=11] [ext_resource path="res://Sprites/Main_Menu_Background.png" type="Texture" id=12] [ext_resource path="res://Resources/Ash.tres" type="DynamicFontData" id=13] -[ext_resource path="res://Main Menu.gd" type="Script" id=14] +[ext_resource path="res://GUI/Main Menu.gd" type="Script" id=14] [sub_resource type="DynamicFont" id=1] size = 20 @@ -31,6 +31,8 @@ centered = false [node name="Menu Items" type="MarginContainer" parent="."] margin_left = 10.0 margin_top = 10.0 +margin_right = 310.0 +margin_bottom = 170.0 rect_min_size = Vector2( 300, 160 ) __meta__ = { "_edit_use_anchors_": false diff --git a/Splash Screen.gd b/GUI/Splash Screen.gd similarity index 100% rename from Splash Screen.gd rename to GUI/Splash Screen.gd diff --git a/Splash Screen.tscn b/GUI/Splash Screen.tscn similarity index 81% rename from Splash Screen.tscn rename to GUI/Splash Screen.tscn index 53f739c..2bd69d6 100644 --- a/Splash Screen.tscn +++ b/GUI/Splash Screen.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=2] [ext_resource path="res://Sprites/Splash_Screen.png" type="Texture" id=1] -[ext_resource path="res://Splash Screen.gd" type="Script" id=2] +[ext_resource path="res://GUI/Splash Screen.gd" type="Script" id=2] [node name="Splash Screen" type="Sprite"] self_modulate = Color( 1, 1, 1, 0 ) diff --git a/Item.gd b/Item.gd new file mode 100644 index 0000000..aa5be04 --- /dev/null +++ b/Item.gd @@ -0,0 +1,14 @@ +# Item Class + +var name: String +var type: String + +func _init(name: String, type: String) -> void: + self.name = name + self.type = type + return + +func equals(other) -> bool: + if(self.name == other.name and self.type == other.type): + return true + return false diff --git a/World.gd b/Levels/Hub World.gd similarity index 76% rename from World.gd rename to Levels/Hub World.gd index f349435..dac8a1f 100644 --- a/World.gd +++ b/Levels/Hub World.gd @@ -2,4 +2,5 @@ extends Node2D func _ready() -> void: $YSort/Player.position = get_viewport_rect().size / 2 + $YSort/Player.load_hud($HUD) return diff --git a/Levels/Hub World.tscn b/Levels/Hub World.tscn new file mode 100644 index 0000000..2f6daf6 --- /dev/null +++ b/Levels/Hub World.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1] +[ext_resource path="res://Levels/Hub World.gd" type="Script" id=2] +[ext_resource path="res://GUI/HUD.tscn" type="PackedScene" id=3] +[ext_resource path="res://Enemies/Enemy.tscn" type="PackedScene" id=4] + +[node name="World" type="Node2D"] +script = ExtResource( 2 ) + +[node name="YSort" type="YSort" parent="."] + +[node name="Player" parent="YSort" instance=ExtResource( 1 )] +collision_mask = 2 + +[node name="Enemies" type="YSort" parent="YSort"] + +[node name="Enemy" parent="YSort/Enemies" instance=ExtResource( 4 )] +position = Vector2( 204, 95.8129 ) + +[node name="HUD" parent="." instance=ExtResource( 3 )] diff --git a/Levels/Hub_World_Button_Normal.png b/Levels/Hub_World_Button_Normal.png new file mode 100644 index 0000000000000000000000000000000000000000..8b1bfe4676b8263227d516a651b49d288cbe7265 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^8X(Nb3?#Q1Xz2kdwg8_HS0MfW|No^o=iddg7)yfu zf*Bm1-ADs+Og&v3Ln>}1Cn(4j7(_65a_Xe8&Y5!1^B=>cq8^2yfA&H*8H^m~F*=?S kR8T#zEO8Q(%TGpzcqM*KRY}uLKm!;&UHx3vIVCg!0KPgWH2?qr literal 0 HcmV?d00001 diff --git a/Levels/Hub_World_Button_Normal.png.import b/Levels/Hub_World_Button_Normal.png.import new file mode 100644 index 0000000..133bc3b --- /dev/null +++ b/Levels/Hub_World_Button_Normal.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Hub_World_Button_Normal.png-e0e0c92697e93b1432bd2175db9ce2c3.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Levels/Hub_World_Button_Normal.png" +dest_files=[ "res://.import/Hub_World_Button_Normal.png-e0e0c92697e93b1432bd2175db9ce2c3.stex" ] + +[params] + +compress/mode=3 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=2 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=0 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/Levels/Level_1_Button_Normal.png b/Levels/Level_1_Button_Normal.png new file mode 100644 index 0000000000000000000000000000000000000000..cd36e3494aa891a24220a52dcd79517eceb629f4 GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0vp^8X(Nb3?#Q1Xz2kdwg8_HS0MfW|No^o=iddg7)yfu zf*Bm1-ADs+6g^!WLn>}1CoJH&(s=TJ!X`PNQ_Y@rN*;DHD$*BKBpDd?FfiTND0v|a PsF=ai)z4*}Q$iB}Au=MQ literal 0 HcmV?d00001 diff --git a/Levels/Level_1_Button_Normal.png.import b/Levels/Level_1_Button_Normal.png.import new file mode 100644 index 0000000..52f9978 --- /dev/null +++ b/Levels/Level_1_Button_Normal.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Level_1_Button_Normal.png-aabb94677b90d525ea57c43e1e096b4c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Levels/Level_1_Button_Normal.png" +dest_files=[ "res://.import/Level_1_Button_Normal.png-aabb94677b90d525ea57c43e1e096b4c.stex" ] + +[params] + +compress/mode=3 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=2 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=0 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/Levels/Level_2_Button_Normal.png b/Levels/Level_2_Button_Normal.png new file mode 100644 index 0000000000000000000000000000000000000000..cd7a5aaac390d7aff3982c811f1fbc1ccf82e267 GIT binary patch literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU3?z3ec*FxKwg8_HS0MfW|No^o=iddg7)yfu zf*Bm1-ADs+>^xl@Ln>~)J;lhzV8G*i@yWmGa%oH+$Ci27AE=)Zb!2il=T-Bd%N|a9 u8-K7Dw{suoYG>`a#_IDEex9!82a`ek81{+#Ng@b=d#Wzp$Pz%YcdP~ literal 0 HcmV?d00001 diff --git a/Levels/Level_2_Button_Normal.png.import b/Levels/Level_2_Button_Normal.png.import new file mode 100644 index 0000000..cfa1839 --- /dev/null +++ b/Levels/Level_2_Button_Normal.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Level_2_Button_Normal.png-fc84a3c0989fcc3c8e21d71dd29dae79.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Levels/Level_2_Button_Normal.png" +dest_files=[ "res://.import/Level_2_Button_Normal.png-fc84a3c0989fcc3c8e21d71dd29dae79.stex" ] + +[params] + +compress/mode=3 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=2 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=0 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/Levels/Level_3_Button_Normal.png b/Levels/Level_3_Button_Normal.png new file mode 100644 index 0000000000000000000000000000000000000000..bfacbed9a9b806debda6f4debf584c8149a95e9f GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU3?z3ec*FxKwg8_HS0MfW|No^o=iddg7)yfu zf*Bm1-ADs+JUm?-Ln>}1Gc*Mr;9zbE61hd|q%&N3*<;)TZH=se9-VDngACI05WHNZV`njxgN@xNA D!mu)0 literal 0 HcmV?d00001 diff --git a/Levels/Level_3_Button_Normal.png.import b/Levels/Level_3_Button_Normal.png.import new file mode 100644 index 0000000..b53d6f5 --- /dev/null +++ b/Levels/Level_3_Button_Normal.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Level_3_Button_Normal.png-13bd64d9d3b134bf83ed84336204422d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Levels/Level_3_Button_Normal.png" +dest_files=[ "res://.import/Level_3_Button_Normal.png-13bd64d9d3b134bf83ed84336204422d.stex" ] + +[params] + +compress/mode=3 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=2 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=0 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/Levels/Level_4_Button_Normal.png b/Levels/Level_4_Button_Normal.png new file mode 100644 index 0000000000000000000000000000000000000000..84c1499a8eb2b11b563be02a03aa4f31d22bc10f GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU3?z3ec*FxKwg8_HS0MfW|No^o=iddg7)yfu zf*Bm1-ADs++&o~)y~N1Ipdi3{(f<4X5{~XA`y&@gG4LDw`g)*k$}W>5B~1LA znp76Zcrcx66ggDjp0GpdgkB2Y@tn;1e-a`u?nz0$VAv$Px@QN_L}1CrGgNa5zLLG6nc5PRvueWqf3%bQo7+Lqw~~Y@ebP0l+XkKV;C*H literal 0 HcmV?d00001 diff --git a/Levels/Level_5_Button_Normal.png.import b/Levels/Level_5_Button_Normal.png.import new file mode 100644 index 0000000..32def41 --- /dev/null +++ b/Levels/Level_5_Button_Normal.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Level_5_Button_Normal.png-5692bf663ad3e725c957095a5773b43c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Levels/Level_5_Button_Normal.png" +dest_files=[ "res://.import/Level_5_Button_Normal.png-5692bf663ad3e725c957095a5773b43c.stex" ] + +[params] + +compress/mode=3 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=2 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=0 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/Main.gd b/Main.gd index 9d139b2..2a7ccb2 100644 --- a/Main.gd +++ b/Main.gd @@ -2,6 +2,7 @@ extends Node export var splash_screen_path: String export var main_menu_path: String +export var level_select_menu_path: String export var world_path: String @@ -19,7 +20,8 @@ func _ready() -> void: func play_splash_screen() -> Node: var splash_screen: Node = load(splash_screen_path).instance() - if splash_screen.connect('complete', self, 'free_connected_node', [splash_screen, 'free_connected_node']) != OK: + if splash_screen.connect('complete', self, 'free_connected_node', + [splash_screen, 'free_connected_node']) != OK: print('ERROR: Splash Screen "complete" signal already connected.') add_child(splash_screen) @@ -29,7 +31,7 @@ func play_splash_screen() -> Node: func play_main_menu() -> Node: var main_menu: Node = load(main_menu_path).instance() if main_menu.connect('complete', self, 'main_menu_option') != OK: - print('ERROR: Main Menu "quit" signal already connected.') + print('ERROR: Main Menu "complete" signal already connected.') add_child(main_menu) return main_menu @@ -37,12 +39,35 @@ func play_main_menu() -> Node: func main_menu_option(option: String) -> void: if option == 'new game': - new_game() + var level_select_menu: Node = play_level_select_menu() + yield(level_select_menu, 'complete') + free_connected_node(level_select_menu, 'level_select_menu_option') + level_select_menu = null elif option == 'quit': quit_game() return +func play_level_select_menu() -> Node: + var level_select_menu: Node = load(level_select_menu_path).instance() + if level_select_menu.connect('complete', self, 'level_select_menu_option') != OK: + print('ERROR: Level Select Menu "complete" signal already connected.') + + add_child(level_select_menu) + return level_select_menu + + +func level_select_menu_option(option: String) -> void: + var level: String = 'res://Levels/' + if option == 'H': + level += 'Hub World.tscn' + elif option == '1': + level += 'Level 1.tscn' + + new_game(level) + return + + func free_connected_node(node: Node, connected_function: String) -> void: node.disconnect('complete', self, connected_function) remove_child(node) @@ -50,9 +75,10 @@ func free_connected_node(node: Node, connected_function: String) -> void: return -func new_game() -> void: - if get_tree().change_scene(world_path) != OK: - print('ERROR: Main failed to change scene to World.') +func new_game(level: String) -> void: + if get_tree().change_scene(level) != OK: + print('ERROR: Main failed to change scene to Level.') + queue_free() return diff --git a/Main.tscn b/Main.tscn index 04cf11e..153388d 100644 --- a/Main.tscn +++ b/Main.tscn @@ -5,9 +5,10 @@ [node name="Main" type="Node"] script = ExtResource( 1 ) -splash_screen_path = "res://Splash Screen.tscn" -main_menu_path = "res://Main Menu.tscn" -world_path = "res://World.tscn" +splash_screen_path = "res://GUI/Splash Screen.tscn" +main_menu_path = "res://GUI/Main Menu.tscn" +level_select_menu_path = "res://GUI/Level Select Menu.tscn" +world_path = "res://Levels/Hub World.tscn" [node name="Background" type="Sprite" parent="."] texture = ExtResource( 3 ) diff --git a/Player.gd b/Player.gd deleted file mode 100644 index 2865a3b..0000000 --- a/Player.gd +++ /dev/null @@ -1,24 +0,0 @@ -extends KinematicBody2D - -const ACCELERATION = 1000 -const MAX_SPEED = 120 -const FRICTION = 1000 - -var velocity: Vector2 = Vector2.ZERO - - -func _physics_process(delta) -> void: - var input_vector: Vector2 = Vector2.ZERO - - input_vector.x = Input.get_action_strength('player_right') - Input.get_action_strength('player_left') - input_vector.y = Input.get_action_strength('player_down') - Input.get_action_strength('player_up') - input_vector = input_vector.normalized() - - if input_vector != Vector2.ZERO: - $AnimationTree.set('parameters/Idle/blend_position', input_vector) - velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta) - else: - velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta) - - velocity = move_and_slide(velocity) - return diff --git a/Player/Inventory.gd b/Player/Inventory.gd new file mode 100644 index 0000000..807e50d --- /dev/null +++ b/Player/Inventory.gd @@ -0,0 +1,45 @@ +extends Node + +signal update_currency(amount) + +var __currency: int + +var __weapons: Array +var __accessories: Array +var __categories: Dictionary + + +func _ready() -> void: + self.__currency = 100 + + self.__weapons = [] + self.__accessories = [] + self.__categories = { + 'Weapon': self.__weapons, + 'Accessory': self.__accessories} + return + + +func get_currency() -> int: + return self.__currency + + +func add_currency(amount: int) -> void: + self.__currency += amount + emit_signal('update_currency', self.__currency) + return + + +func add(item) -> void: + self.__categories[item.type].append(item) + return + + +func discard(item) -> void: + var index: int = 0 + for itr in self.__categories[item.type]: + if itr.equals(item): + self.__categories[item.type].remove(index) + break + index += 1 + return diff --git a/Player/Inventory.tscn b/Player/Inventory.tscn new file mode 100644 index 0000000..ab9e575 --- /dev/null +++ b/Player/Inventory.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Player/Inventory.gd" type="Script" id=1] + +[node name="Inventory" type="Node"] +script = ExtResource( 1 ) diff --git a/Player/Player.gd b/Player/Player.gd new file mode 100644 index 0000000..21e54fe --- /dev/null +++ b/Player/Player.gd @@ -0,0 +1,59 @@ +extends KinematicBody2D + +const ACCELERATION: int = 1000 +const MAX_SPEED: int = 120 +const FRICTION: int = 1000 +const HEALTH_SLICES: Array = [0, 20, 35, 50, 65, 80, 100] + +var health_index: int = 6 +var hud: CanvasLayer = null +var velocity: Vector2 = Vector2.ZERO + + +func _physics_process(delta) -> void: + var input_vector: Vector2 = Vector2.ZERO + + input_vector.x = Input.get_action_strength('player_right') \ + - Input.get_action_strength('player_left') + input_vector.y = Input.get_action_strength('player_down') \ + - Input.get_action_strength('player_up') + input_vector = input_vector.normalized() + + if input_vector != Vector2.ZERO: + $AnimationTree.set('parameters/Idle/blend_position', input_vector) + velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta) + else: + velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta) + + velocity = move_and_slide(velocity) + return + + +func load_hud(node: CanvasLayer) -> void: + hud = node + if hud.connect('add_currency', self, 'add_currency') != OK: + print('ERROR: HUD "add_currency" signal already connected.') + + hud.update_health(HEALTH_SLICES[health_index]) + hud.update_currency($Inventory.get_currency()) + return + + +func add_currency(amount: int) -> void: + $Inventory.add_currency(amount) + return + + +func _on_Inventory_update_currency(amount: int) -> void: + hud.update_currency(amount) + return + + +func _on_Hitbox_body_entered(body: Node) -> void: + if not 'enemies' in body.get_groups(): + return + + if health_index != 0: + health_index -= 1 + hud.update_health(HEALTH_SLICES[health_index]) + return diff --git a/Sprites/Player.png b/Player/Player.png similarity index 100% rename from Sprites/Player.png rename to Player/Player.png diff --git a/Sprites/Player.png.import b/Player/Player.png.import similarity index 68% rename from Sprites/Player.png.import rename to Player/Player.png.import index d60fbdc..442f173 100644 --- a/Sprites/Player.png.import +++ b/Player/Player.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/Player.png-0662117005c6b9039deb63a286c8efe4.stex" +path="res://.import/Player.png-3d0801c65bdfc563657cfa304115f1c7.stex" metadata={ "vram_texture": false } [deps] -source_file="res://Sprites/Player.png" -dest_files=[ "res://.import/Player.png-0662117005c6b9039deb63a286c8efe4.stex" ] +source_file="res://Player/Player.png" +dest_files=[ "res://.import/Player.png-3d0801c65bdfc563657cfa304115f1c7.stex" ] [params] @@ -28,6 +28,7 @@ process/fix_alpha_border=false process/premult_alpha=false process/HDR_as_SRGB=false process/invert_color=false +process/normal_map_invert_y=false stream=false size_limit=0 detect_3d=false diff --git a/Player.tscn b/Player/Player.tscn similarity index 86% rename from Player.tscn rename to Player/Player.tscn index e621a9d..9c6780c 100644 --- a/Player.tscn +++ b/Player/Player.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=19 format=2] +[gd_scene load_steps=20 format=2] -[ext_resource path="res://Player.gd" type="Script" id=1] -[ext_resource path="res://Sprites/Player.png" type="Texture" id=2] -[ext_resource path="res://Sprites/Player_Down.png" type="Texture" id=3] -[ext_resource path="res://Sprites/Player_Up.png" type="Texture" id=4] +[ext_resource path="res://Player/Player.gd" type="Script" id=1] +[ext_resource path="res://Player/Player.png" type="Texture" id=2] +[ext_resource path="res://Player/Player_Down.png" type="Texture" id=3] +[ext_resource path="res://Player/Player_Up.png" type="Texture" id=4] +[ext_resource path="res://Player/Inventory.tscn" type="PackedScene" id=5] [sub_resource type="SpriteFrames" id=1] animations = [ { @@ -14,12 +15,12 @@ animations = [ { }, { "frames": [ ExtResource( 2 ) ], "loop": false, -"name": "look_right", +"name": "look_left", "speed": 5.0 }, { "frames": [ ExtResource( 2 ) ], "loop": false, -"name": "look_left", +"name": "look_right", "speed": 5.0 }, { "frames": [ ExtResource( 3 ) ], @@ -192,7 +193,9 @@ visible = false rotation = 1.5708 shape = SubResource( 2 ) -[node name="Hitbox" type="CollisionShape2D" parent="."] +[node name="Hitbox" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] visible = false position = Vector2( 0, -5 ) shape = SubResource( 3 ) @@ -210,3 +213,8 @@ anim_player = NodePath("../AnimationPlayer") active = true parameters/playback = SubResource( 14 ) parameters/Idle/blend_position = Vector2( 0.993787, 0.0189655 ) + +[node name="Inventory" parent="." instance=ExtResource( 5 )] + +[connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"] +[connection signal="update_currency" from="Inventory" to="." method="_on_Inventory_update_currency"] diff --git a/Sprites/Player_Down.png b/Player/Player_Down.png similarity index 100% rename from Sprites/Player_Down.png rename to Player/Player_Down.png diff --git a/Player/Player_Down.png.import b/Player/Player_Down.png.import new file mode 100644 index 0000000..b876464 --- /dev/null +++ b/Player/Player_Down.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Player_Down.png-0720a85ec5e36101f691c750d323946c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Player/Player_Down.png" +dest_files=[ "res://.import/Player_Down.png-0720a85ec5e36101f691c750d323946c.stex" ] + +[params] + +compress/mode=3 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=2 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=0 +process/fix_alpha_border=false +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/Sprites/Player_Up.png b/Player/Player_Up.png similarity index 100% rename from Sprites/Player_Up.png rename to Player/Player_Up.png diff --git a/Sprites/Player_Up.png.import b/Player/Player_Up.png.import similarity index 66% rename from Sprites/Player_Up.png.import rename to Player/Player_Up.png.import index 3e59f41..c2ea171 100644 --- a/Sprites/Player_Up.png.import +++ b/Player/Player_Up.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/Player_Up.png-3bef5e9a80b83b2419123f6e36070755.stex" +path="res://.import/Player_Up.png-889a827868f4dc454da2bef028bdec76.stex" metadata={ "vram_texture": false } [deps] -source_file="res://Sprites/Player_Up.png" -dest_files=[ "res://.import/Player_Up.png-3bef5e9a80b83b2419123f6e36070755.stex" ] +source_file="res://Player/Player_Up.png" +dest_files=[ "res://.import/Player_Up.png-889a827868f4dc454da2bef028bdec76.stex" ] [params] @@ -28,6 +28,7 @@ process/fix_alpha_border=false process/premult_alpha=false process/HDR_as_SRGB=false process/invert_color=false +process/normal_map_invert_y=false stream=false size_limit=0 detect_3d=false diff --git a/Sprites/Enemy.png b/Sprites/Enemy.png new file mode 100644 index 0000000000000000000000000000000000000000..86d58e4c3d191aa8b192d62ddb1f4539c908b1e1 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^93afX3?$7I7w-U4LIFM@u0UEz!9+{lQ%%`IUB&kI zC$lLb{mDR4#*!evU