diff --git a/Scenes/UI.tscn b/Scenes/UI.tscn new file mode 100644 index 0000000..4290fb1 --- /dev/null +++ b/Scenes/UI.tscn @@ -0,0 +1,47 @@ +[gd_scene format=3 uid="uid://b2mbs0mt6pfk1"] + +[ext_resource type="Script" uid="uid://dlajwbi28mo3c" path="res://Scripts/ui.gd" id="1_w371h"] + +[node name="Control" type="Control" unique_id=647295477] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_w371h") + +[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1986399715] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer" unique_id=1201878653] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer" unique_id=2066260090] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="hEALTH" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer" unique_id=8299279] +layout_mode = 2 +text = "HEALTH" + +[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer/HBoxContainer" unique_id=722194416] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TIME" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer2" unique_id=262400277] +layout_mode = 2 +text = "TIME" +horizontal_alignment = 1 + +[node name="MarginContainer3" type="MarginContainer" parent="VBoxContainer/HBoxContainer" unique_id=659233158] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="CRATES" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer3" unique_id=426403136] +layout_mode = 2 +text = "CRATES" +horizontal_alignment = 2 diff --git a/Scenes/game.tscn b/Scenes/game.tscn index 02a3b50..5d392bb 100644 --- a/Scenes/game.tscn +++ b/Scenes/game.tscn @@ -6,6 +6,7 @@ [ext_resource type="Script" uid="uid://kb3v21msvi17" path="res://Scripts/trigger.gd" id="3_wrm1d"] [ext_resource type="Script" uid="uid://qhll446powxt" path="res://Scripts/scene_manager.gd" id="6_1l0tm"] [ext_resource type="PackedScene" uid="uid://dkp7dy7npof2g" path="res://Scenes/slime.tscn" id="6_i6g32"] +[ext_resource type="PackedScene" uid="uid://b2mbs0mt6pfk1" path="res://Scenes/UI.tscn" id="7_1l0tm"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v158k"] texture = ExtResource("3_1l0tm") @@ -13,13 +14,14 @@ texture_region_size = Vector2i(32, 32) 0:0/0 = 0 0:0/0/terrain_set = 0 0:0/0/terrain = 0 -0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, -4.4608307, -16, -4.1422005, 16, -16, 16) +0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 0:0/0/terrains_peering_bit/right_side = 0 0:0/0/terrains_peering_bit/bottom_right_corner = 0 0:0/0/terrains_peering_bit/bottom_side = 0 1:0/0 = 0 1:0/0/terrain_set = 0 1:0/0/terrain = 0 +1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 1:0/0/terrains_peering_bit/right_side = 0 1:0/0/terrains_peering_bit/bottom_right_corner = 0 1:0/0/terrains_peering_bit/bottom_side = 0 @@ -28,7 +30,7 @@ texture_region_size = Vector2i(32, 32) 2:0/0 = 0 2:0/0/terrain_set = 0 2:0/0/terrain = 0 -2:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(8.603031, -16, 16, -16, 16, 16, 8.603031, 16, 8.284401, 16) +2:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 2:0/0/terrains_peering_bit/bottom_side = 0 2:0/0/terrains_peering_bit/bottom_left_corner = 0 2:0/0/terrains_peering_bit/left_side = 0 @@ -193,13 +195,14 @@ texture_region_size = Vector2i(32, 32) 0:2/0 = 0 0:2/0/terrain_set = 0 0:2/0/terrain = 0 -0:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, -4.4608307, -16, -4.1422005, 16, -16, 16) +0:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 0:2/0/terrains_peering_bit/right_side = 0 0:2/0/terrains_peering_bit/top_side = 0 0:2/0/terrains_peering_bit/top_right_corner = 0 1:2/0 = 0 1:2/0/terrain_set = 0 1:2/0/terrain = 0 +1:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 1:2/0/terrains_peering_bit/right_side = 0 1:2/0/terrains_peering_bit/left_side = 0 1:2/0/terrains_peering_bit/top_left_corner = 0 @@ -208,7 +211,7 @@ texture_region_size = Vector2i(32, 32) 2:2/0 = 0 2:2/0/terrain_set = 0 2:2/0/terrain = 0 -2:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(8.603031, -16, 16, -16, 16, 16, 8.603031, 16, 8.284401, 16) +2:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 2:2/0/terrains_peering_bit/left_side = 0 2:2/0/terrains_peering_bit/top_left_corner = 0 2:2/0/terrains_peering_bit/top_side = 0 @@ -220,7 +223,7 @@ texture_region_size = Vector2i(32, 32) 6:3/0 = 0 6:3/0/terrain_set = 0 6:3/0/terrain = 0 -6:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, -3.5049381, -13.06386, -3.5049381, 16, -16, 16) +6:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 6:3/0/terrains_peering_bit/right_side = 0 6:3/0/terrains_peering_bit/bottom_side = 0 6:3/0/terrains_peering_bit/top_side = 0 @@ -228,7 +231,7 @@ texture_region_size = Vector2i(32, 32) 7:3/0 = 0 7:3/0/terrain_set = 0 7:3/0/terrain = 0 -7:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(8.921661, -16, 16, -16, 16, 16, 8.603031, 16) +7:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 7:3/0/terrains_peering_bit/bottom_side = 0 7:3/0/terrains_peering_bit/left_side = 0 7:3/0/terrains_peering_bit/top_left_corner = 0 @@ -236,7 +239,7 @@ texture_region_size = Vector2i(32, 32) 9:3/0 = 0 9:3/0/terrain_set = 0 9:3/0/terrain = 0 -9:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, -3.8235683, -16, -4.1422005) +9:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 9:3/0/terrains_peering_bit/right_side = 0 9:3/0/terrains_peering_bit/bottom_side = 0 9:3/0/terrains_peering_bit/bottom_left_corner = 0 @@ -244,7 +247,7 @@ texture_region_size = Vector2i(32, 32) 10:3/0 = 0 10:3/0/terrain_set = 0 10:3/0/terrain = 0 -10:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, -3.8235683, -16, -4.1422005) +10:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 10:3/0/terrains_peering_bit/right_side = 0 10:3/0/terrains_peering_bit/bottom_right_corner = 0 10:3/0/terrains_peering_bit/bottom_side = 0 @@ -252,14 +255,14 @@ texture_region_size = Vector2i(32, 32) 12:3/0 = 0 12:3/0/terrain_set = 0 12:3/0/terrain = 0 -12:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, -6.691246, -16, -6.372616, 16, -16, 16) +12:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 12:3/0/terrains_peering_bit/right_side = 0 12:3/0/terrains_peering_bit/bottom_side = 0 12:3/0/terrains_peering_bit/top_side = 0 13:3/0 = 0 13:3/0/terrain_set = 0 13:3/0/terrain = 0 -13:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, -3.8235683, -16, -4.1422005) +13:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 13:3/0/terrains_peering_bit/right_side = 0 13:3/0/terrains_peering_bit/bottom_side = 0 13:3/0/terrains_peering_bit/left_side = 0 @@ -299,7 +302,7 @@ texture_region_size = Vector2i(32, 32) 6:4/0 = 0 6:4/0/terrain_set = 0 6:4/0/terrain = 0 -6:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, -3.5049381, -13.06386, -3.5049381, 16, -16, 16) +6:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 6:4/0/terrains_peering_bit/right_side = 0 6:4/0/terrains_peering_bit/bottom_right_corner = 0 6:4/0/terrains_peering_bit/bottom_side = 0 @@ -307,7 +310,7 @@ texture_region_size = Vector2i(32, 32) 7:4/0 = 0 7:4/0/terrain_set = 0 7:4/0/terrain = 0 -7:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(8.921661, -16, 16, -16, 16, 16, 8.603031, 16) +7:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 7:4/0/terrains_peering_bit/bottom_side = 0 7:4/0/terrains_peering_bit/bottom_left_corner = 0 7:4/0/terrains_peering_bit/left_side = 0 @@ -315,7 +318,7 @@ texture_region_size = Vector2i(32, 32) 9:4/0 = 0 9:4/0/terrain_set = 0 9:4/0/terrain = 0 -9:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 3.186306, 16, 2.5490456, 16, 16, -16, 16) +9:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 9:4/0/terrains_peering_bit/right_side = 0 9:4/0/terrains_peering_bit/left_side = 0 9:4/0/terrains_peering_bit/top_left_corner = 0 @@ -323,7 +326,7 @@ texture_region_size = Vector2i(32, 32) 10:4/0 = 0 10:4/0/terrain_set = 0 10:4/0/terrain = 0 -10:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 3.186306, 16, 2.5490456, 16, 16, -16, 16) +10:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 10:4/0/terrains_peering_bit/right_side = 0 10:4/0/terrains_peering_bit/left_side = 0 10:4/0/terrains_peering_bit/top_side = 0 @@ -331,14 +334,14 @@ texture_region_size = Vector2i(32, 32) 12:4/0 = 0 12:4/0/terrain_set = 0 12:4/0/terrain = 0 -12:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 5.7353554, 16, 6.372616, 16, 16, -16, 16) +12:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 12:4/0/terrains_peering_bit/right_side = 0 12:4/0/terrains_peering_bit/left_side = 0 12:4/0/terrains_peering_bit/top_side = 0 13:4/0 = 0 13:4/0/terrain_set = 0 13:4/0/terrain = 0 -13:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(8.284401, -16, 16, -16, 16, 16, 8.603031, 16) +13:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16) 13:4/0/terrains_peering_bit/bottom_side = 0 13:4/0/terrains_peering_bit/bottom_left_corner = 0 13:4/0/terrains_peering_bit/left_side = 0 @@ -384,7 +387,7 @@ position = Vector2(-39, 148) script = ExtResource("6_1l0tm") [node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=2001245533] -tile_map_data = PackedByteArray("AAALAAMAAAAEAAAAAAAMAAQAAAABAAQAAAANAAMAAAAEAAAAAAAMAAMAAAAEAAQAAAAMAAUAAAABAAQAAAANAAUAAAAJAAQAAAAPAAMAAAAEAAQAAAALAAQAAAAJAAEAAAANAAQAAAACAAEAAAALAAUAAAAKAAQAAAAKAAUAAAANAAMAAAAJAAUAAAANAAMAAAAIAAUAAAANAAMAAAAHAAUAAAANAAMAAAAGAAUAAAAPAAMAAAAFAAUAAAABAAQAAAAOAAUAAAABAAQAAAAPAAUAAAABAAQAAAAQAAUAAAABAAQAAAARAAUAAAABAAQAAAASAAUAAAABAAQAAAATAAUAAAABAAQAAAAUAAUAAAABAAQAAAAVAAUAAAABAAQAAAA=") +tile_map_data = PackedByteArray("AAALAAMAAAAEAAAAAAAMAAQAAAABAAAAAAANAAMAAAAEAAAAAAAMAAMAAAAEAAQAAAAPAAMAAAAEAAQAAAALAAQAAAAGAAQAAAANAAQAAAAHAAQAAAAFAAUAAAAAAAQAAAAGAAUAAAABAAQAAAAHAAUAAAABAAQAAAAIAAUAAAABAAQAAAAJAAUAAAABAAQAAAAKAAUAAAABAAQAAAALAAUAAAAKAAQAAAAMAAUAAAABAAIAAAANAAUAAAAJAAQAAAAOAAUAAAABAAQAAAAPAAUAAAABAAQAAAAQAAUAAAABAAQAAAARAAUAAAABAAQAAAASAAUAAAABAAQAAAATAAUAAAABAAQAAAAUAAUAAAABAAQAAAAVAAUAAAAKAAQAAAAWAAUAAAAJAAQAAAAXAAUAAAACAAQAAAAVAAQAAAAAAAAAAAAWAAQAAAANAAQAAAAWAAMAAAAEAAAAAAA=") tile_set = SubResource("TileSet_h4fw4") [node name="platfrom" type="StaticBody2D" parent="." unique_id=446401574] @@ -425,10 +428,14 @@ position = Vector2(252, 66.99999) [node name="Enemies" type="Node2D" parent="." unique_id=1049899688] [node name="Slime" parent="Enemies" unique_id=1791005633 instance=ExtResource("6_i6g32")] -position = Vector2(505, 148) +position = Vector2(505, 150) [node name="Slime2" parent="Enemies" unique_id=834201238 instance=ExtResource("6_i6g32")] position = Vector2(308, 147) +[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1920919030] + +[node name="Control" parent="CanvasLayer" unique_id=647295477 instance=ExtResource("7_1l0tm")] + [connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"] [connection signal="triggerActiveSignal" from="Area2D" to="." method="_on_triggerSignal"] diff --git a/Scenes/player.tscn b/Scenes/player.tscn index f55cffc..3755ed9 100644 --- a/Scenes/player.tscn +++ b/Scenes/player.tscn @@ -2,11 +2,69 @@ [ext_resource type="Script" uid="uid://b4efh8nwneqkf" path="res://Scripts/player.gd" id="1_v0iea"] [ext_resource type="Texture2D" uid="uid://p72rbg7thsvi" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_cvnsp"] +[ext_resource type="Texture2D" uid="uid://cikmdjl8tc17o" path="res://assets/graphics/player/Hurt/Player Hurt 48x48.png" id="2_fkybt"] [ext_resource type="Texture2D" uid="uid://b524p0lnj8ftn" path="res://assets/graphics/player/jump_fall/player jump 48x48.png" id="2_vgqql"] +[ext_resource type="Texture2D" uid="uid://c2vtgqubns1p8" path="res://assets/graphics/player/DEAD/Player Death 64x64.png" id="2_x3wgy"] [ext_resource type="Texture2D" uid="uid://b74hvan7k63nk" path="res://assets/graphics/player/Run/player run 48x48.png" id="3_6t5aa"] [sub_resource type="CircleShape2D" id="CircleShape2D_2poj3"] +[sub_resource type="AtlasTexture" id="AtlasTexture_y6uwr"] +atlas = ExtResource("2_x3wgy") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_83xs0"] +atlas = ExtResource("2_x3wgy") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ypfnu"] +atlas = ExtResource("2_x3wgy") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_xuaoq"] +atlas = ExtResource("2_x3wgy") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wohnl"] +atlas = ExtResource("2_x3wgy") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_36dho"] +atlas = ExtResource("2_x3wgy") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yh6i2"] +atlas = ExtResource("2_x3wgy") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nv4vc"] +atlas = ExtResource("2_x3wgy") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8gxox"] +atlas = ExtResource("2_x3wgy") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_11gg7"] +atlas = ExtResource("2_x3wgy") +region = Rect2(432, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2ijsl"] +atlas = ExtResource("2_fkybt") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_p1odr"] +atlas = ExtResource("2_fkybt") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0gysh"] +atlas = ExtResource("2_fkybt") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vfarp"] +atlas = ExtResource("2_fkybt") +region = Rect2(144, 0, 48, 48) + [sub_resource type="AtlasTexture" id="AtlasTexture_olqyp"] atlas = ExtResource("2_vgqql") region = Rect2(96, 0, 48, 48) @@ -95,6 +153,58 @@ region = Rect2(336, 0, 48, 48) animations = [{ "frames": [{ "duration": 1.0, +"texture": SubResource("AtlasTexture_y6uwr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_83xs0") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ypfnu") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xuaoq") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wohnl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_36dho") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yh6i2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nv4vc") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8gxox") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_11gg7") +}], +"loop": false, +"name": &"DEAD", +"speed": 9.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_2ijsl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_p1odr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0gysh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vfarp") +}], +"loop": false, +"name": &"Hurt", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, "texture": SubResource("AtlasTexture_olqyp") }], "loop": false, @@ -195,7 +305,7 @@ position = Vector2(-17, -8) texture_filter = 1 position = Vector2(0, -6) sprite_frames = SubResource("SpriteFrames_ukyrk") -animation = &"idle" +animation = &"DEAD" autoplay = "idle" [node name="Camera2D" type="Camera2D" parent="." unique_id=124446220] diff --git a/Scenes/slime.tscn b/Scenes/slime.tscn index 7dc3e3a..485e6df 100644 --- a/Scenes/slime.tscn +++ b/Scenes/slime.tscn @@ -59,17 +59,17 @@ position = Vector2(0, 1.5) shape = SubResource("RectangleShape2D_vblni") [node name="Rightcast" type="RayCast2D" parent="." unique_id=1783847293] -target_position = Vector2(12, 0) +target_position = Vector2(16, 0) [node name="LeftCast" type="RayCast2D" parent="." unique_id=500912486] -target_position = Vector2(-12, 0) +target_position = Vector2(-15, 0) [node name="LeftDownCast" type="RayCast2D" parent="." unique_id=586259475] -position = Vector2(-7, 0) -target_position = Vector2(0, 14) +position = Vector2(-9, 0) +target_position = Vector2(0, 12) [node name="RightDownCast" type="RayCast2D" parent="." unique_id=54037895] -position = Vector2(7, 0) -target_position = Vector2(0, 14) +position = Vector2(9, 0) +target_position = Vector2(0, 12) [connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/Scripts/game controller.gd b/Scripts/game controller.gd index 79087b5..3a1890b 100644 --- a/Scripts/game controller.gd +++ b/Scripts/game controller.gd @@ -2,6 +2,9 @@ extends Node2D signal destroySignal(body) signal levelChangeSignal(level) +signal damagePlayerSignal(damageTotal, playerHealthTotal) +signal killPlayerSignal +signal timechangesignal(currenttimeavailable) var levels = ["res://Scenes/game.tscn","res://Scenes/level 2.tscn","res://Scenes/level3.tscn"] var currentLevel = 0 @@ -15,9 +18,14 @@ var playerCurrentHealth:int = 100 #enemies var enemiesDict = {} +var enemy:CharacterStats +var player:CharacterStats + # Called when the node enters the scene tree for the first time. func _ready() -> void: get_window().grab_focus() + enemy = load("res://Scripts/rscs/slime_stats.tres") + player = load("res://Scripts/rscs/player_sats.tres") add_child(timer) timer.wait_time = 1 timer.one_shot = false @@ -27,6 +35,7 @@ func _ready() -> void: func secondCounter()->void: print("tick") timeAvailable-=1 + timechangesignal.emit(timeAvailable) if timeAvailable <=0: print ("you loose!") levelChangeSignal.emit(levels[currentLevel]) @@ -34,7 +43,7 @@ func secondCounter()->void: func reset() -> void: timeAvailable = timers[currentLevel] - playerCurrentHealth = 100 + playerCurrentHealth = player.starting_health get_window().grab_focus() # Called every frame. 'delta' is the elapsed time since the previous frame. @@ -60,16 +69,21 @@ func _on_slime_damage(_body, slime)->void: print ("GC knows slime doing damage") print("doing damage: "+str(enemiesDict[slime]["damage"])) playerCurrentHealth -= enemiesDict[slime]["damage"] + #send a custom signal about damage + damagePlayerSignal.emit(enemiesDict[slime]["damage"], playerCurrentHealth) if playerCurrentHealth <=0: print ("U ded") - levelChangeSignal.emit(levels[currentLevel]) + killPlayerSignal.emit() + func addEnemyToLevel(slime)->void: #give each enemy some health and damage var randamage = randi_range(1,20) var enemyStat = { - "health": 50, - "damage": 30+randamage - } + "health": enemy.starting_health, + "damage": enemy.meleeDamage+randamage + } enemiesDict[slime]=enemyStat +func respawn()->void: + levelChangeSignal.emit(levels[currentLevel]) diff --git a/Scripts/player.gd b/Scripts/player.gd index 4227e63..b9c16b6 100644 --- a/Scripts/player.gd +++ b/Scripts/player.gd @@ -7,16 +7,19 @@ const JUMP_VELOCITY = -400.0 @onready var left_spawn: Marker2D = $LeftSpawn @onready var player_graphic: AnimatedSprite2D = $PlayerGraphic +signal deathAnimationComplete + var direction enum FaceDirection{LEFT,RIGHT} var facing:FaceDirection = FaceDirection.RIGHT -enum PlayerState{IDLE,RUNNING,JUMPING,FALLING} +enum PlayerState{IDLE,RUNNING,JUMPING,FALLING,HURT,DEAD} var current_player_state:PlayerState = PlayerState.IDLE var upjump:bool = false func _physics_process(delta: float) -> void: - handle_input() + if not current_player_state == PlayerState.HURT: + handle_input() handle_state() handle_animation() @@ -88,6 +91,10 @@ func handle_animation()->void: player_graphic.play("jump") PlayerState.FALLING: player_graphic.play("fall") + PlayerState.HURT: + player_graphic.play("Hurt") + PlayerState.DEAD: + player_graphic.play("dead") @@ -95,3 +102,12 @@ func _on_animation_finished() -> void: match current_player_state: PlayerState.JUMPING: upjump = false + PlayerState.HURT: + current_player_state = PlayerState.IDLE + PlayerState.DEAD: + deathAnimationComplete.emit() +func takeDamage(_damage,_remainingHealth)->void: + print("Players knows damage"+str(_damage)) + current_player_state = PlayerState.HURT +func die()->void: + current_player_state = PlayerState.DEAD diff --git a/Scripts/rscs/character_stats.gd b/Scripts/rscs/character_stats.gd new file mode 100644 index 0000000..1d0f769 --- /dev/null +++ b/Scripts/rscs/character_stats.gd @@ -0,0 +1,8 @@ +class_name CharacterStats extends Resource + +@export var health:int = 100 +@export var max_health:int = 120 +@export var starting_health = 100 + +@export var meleeDamage:int = 10 +@export var rangeDamage:int = 5 diff --git a/Scripts/rscs/character_stats.gd.uid b/Scripts/rscs/character_stats.gd.uid new file mode 100644 index 0000000..3d8f0ef --- /dev/null +++ b/Scripts/rscs/character_stats.gd.uid @@ -0,0 +1 @@ +uid://btjirk5r5r50v diff --git a/Scripts/rscs/player_sats.tres b/Scripts/rscs/player_sats.tres new file mode 100644 index 0000000..94e644d --- /dev/null +++ b/Scripts/rscs/player_sats.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" script_class="CharacterStats" format=3 uid="uid://cobe3kt6pn1wb"] + +[ext_resource type="Script" uid="uid://btjirk5r5r50v" path="res://Scripts/rscs/character_stats.gd" id="1_jiogy"] + +[resource] +script = ExtResource("1_jiogy") +health = 110 +metadata/_custom_type_script = "uid://btjirk5r5r50v" diff --git a/Scripts/rscs/slime_stats.tres b/Scripts/rscs/slime_stats.tres new file mode 100644 index 0000000..0c9be58 --- /dev/null +++ b/Scripts/rscs/slime_stats.tres @@ -0,0 +1,11 @@ +[gd_resource type="Resource" script_class="CharacterStats" format=3 uid="uid://c0xhd2g03rcls"] + +[ext_resource type="Script" uid="uid://btjirk5r5r50v" path="res://Scripts/rscs/character_stats.gd" id="1_38j4j"] + +[resource] +script = ExtResource("1_38j4j") +health = 40 +max_health = 45 +starting_health = 40 +rangeDamage = 0 +metadata/_custom_type_script = "uid://btjirk5r5r50v" diff --git a/Scripts/scene_manager.gd b/Scripts/scene_manager.gd index ee0be2e..ebb9d23 100644 --- a/Scripts/scene_manager.gd +++ b/Scripts/scene_manager.gd @@ -3,12 +3,19 @@ class_name SceneManager extends Node2D @onready var crates: Node2D = $"../Crates" var grenade = preload("res://Scenes/grenade.tscn") @onready var enemies: Node2D = $"../Enemies" +@onready var player = $"../Player" +@onready var control = $"../CanvasLayer/Control" func _ready() -> void: GameController.reset() print("Scene manager is ready!") GameController.destroySignal.connect(destroy) GameController.levelChangeSignal.connect(changeScene) + GameController.damagePlayerSignal.connect(player.takeDamage) + GameController.damagePlayerSignal.connect((control.updatehealth)) + GameController.timechangesignal.connect(control.updatetime) + GameController.killPlayerSignal.connect(player.die) + player.deathAnimationComplete.connect(GameController.respawn) buildLevel() func destroy(body)->void: diff --git a/Scripts/slime.gd b/Scripts/slime.gd index 1bb305a..21e9143 100644 --- a/Scripts/slime.gd +++ b/Scripts/slime.gd @@ -15,13 +15,16 @@ func _process(delta: float) -> void: if rightcast.is_colliding() and not rightcast.get_collider() is Player: direction = -1 slime_graphic.flip_h = true + if left_cast.is_colliding() and not left_cast.get_collider() is Player: direction = 1 slime_graphic.flip_h = false + if not right_down_cast.is_colliding(): direction = -1 slime_graphic.flip_h = true - if not left_cast.is_colliding(): + + if not left_down_cast.is_colliding(): direction = +1 slime_graphic.flip_h = false diff --git a/Scripts/ui.gd b/Scripts/ui.gd new file mode 100644 index 0000000..31e1ea6 --- /dev/null +++ b/Scripts/ui.gd @@ -0,0 +1,17 @@ +extends Control +@onready var health = $VBoxContainer/HBoxContainer/MarginContainer/hEALTH +@onready var time = $VBoxContainer/HBoxContainer/MarginContainer2/TIME + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + health.text = "boombastic" + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass +func updatehealth(_damage,_health)->void: + health.text = "Health"+str(_health) +func updatetime (timeavailable)->void: + time.text = str(timeavailable) diff --git a/Scripts/ui.gd.uid b/Scripts/ui.gd.uid new file mode 100644 index 0000000..4698d09 --- /dev/null +++ b/Scripts/ui.gd.uid @@ -0,0 +1 @@ +uid://dlajwbi28mo3c diff --git a/assets/graphics/player/DEAD/Player Death 64x64.png b/assets/graphics/player/DEAD/Player Death 64x64.png new file mode 100644 index 0000000..2e6a1ae Binary files /dev/null and b/assets/graphics/player/DEAD/Player Death 64x64.png differ diff --git a/assets/graphics/player/DEAD/Player Death 64x64.png.import b/assets/graphics/player/DEAD/Player Death 64x64.png.import new file mode 100644 index 0000000..e8a1112 --- /dev/null +++ b/assets/graphics/player/DEAD/Player Death 64x64.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c2vtgqubns1p8" +path="res://.godot/imported/Player Death 64x64.png-98bd69b60fbf82e63e73cc68f91dafb5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/DEAD/Player Death 64x64.png" +dest_files=["res://.godot/imported/Player Death 64x64.png-98bd69b60fbf82e63e73cc68f91dafb5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/graphics/player/Hurt/Player Hurt 48x48.png b/assets/graphics/player/Hurt/Player Hurt 48x48.png new file mode 100644 index 0000000..57d8783 Binary files /dev/null and b/assets/graphics/player/Hurt/Player Hurt 48x48.png differ diff --git a/assets/graphics/player/Hurt/Player Hurt 48x48.png.import b/assets/graphics/player/Hurt/Player Hurt 48x48.png.import new file mode 100644 index 0000000..0fa7d30 --- /dev/null +++ b/assets/graphics/player/Hurt/Player Hurt 48x48.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cikmdjl8tc17o" +path="res://.godot/imported/Player Hurt 48x48.png-9cfb2ae49bd1c502aca3213d55f31e60.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/Hurt/Player Hurt 48x48.png" +dest_files=["res://.godot/imported/Player Hurt 48x48.png-9cfb2ae49bd1c502aca3213d55f31e60.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1