diff --git a/assets/graphics/player/death/Player Death 64x64.png b/assets/graphics/player/death/Player Death 64x64.png new file mode 100644 index 0000000..2e6a1ae Binary files /dev/null and b/assets/graphics/player/death/Player Death 64x64.png differ diff --git a/assets/graphics/player/death/Player Death 64x64.png.import b/assets/graphics/player/death/Player Death 64x64.png.import new file mode 100644 index 0000000..395a2e7 --- /dev/null +++ b/assets/graphics/player/death/Player Death 64x64.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dgj6nq2pnxgho" +path="res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/death/Player Death 64x64.png" +dest_files=["res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.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..26c4e69 --- /dev/null +++ b/assets/graphics/player/hurt/Player Hurt 48x48.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cdsu1cetxa45b" +path="res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.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-a720e51cb19103e76b22ab6c1b81302d.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/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..34635f6 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,46 @@ +[preset.0] + +name="Linux" +platform="Linux" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="../../godotexport/MarchGame.arm64" +patches=PackedStringArray() +patch_delta_encoding=false +patch_delta_compression_level_zstd=19 +patch_delta_min_reduction=0.1 +patch_delta_include_filters="*" +patch_delta_exclude_filters="" +encryption_include_filters="" +encryption_exclude_filters="" +seed=0 +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=false +texture_format/s3tc_bptc=true +texture_format/etc2_astc=false +shader_baker/enabled=false +binary_format/architecture="arm64" +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +export DISPLAY=:0 +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +\"{temp_dir}/{exe_name}\" {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +pkill -x -f \"{temp_dir}/{exe_name} {cmd_args}\" +rm -rf \"{temp_dir}\"" diff --git a/project.godot b/project.godot index 4ca2ede..6aebbdc 100644 --- a/project.godot +++ b/project.godot @@ -42,6 +42,16 @@ shoot={ "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":90,"key_label":0,"unicode":122,"location":0,"echo":false,"script":null) ] } +save={ +"deadzone": 0.2, +"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":78,"key_label":0,"unicode":110,"location":0,"echo":false,"script":null) +] +} +load={ +"deadzone": 0.2, +"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":77,"key_label":0,"unicode":109,"location":0,"echo":false,"script":null) +] +} [physics] diff --git a/scenes/game.tscn b/scenes/game.tscn index dbaf83f..f565d7c 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -14,6 +14,7 @@ [ext_resource type="Texture2D" uid="uid://cufqer3a7texm" path="res://assets/graphics/environment/terrain/bg/background B layer4.png" id="13_kvuet"] [ext_resource type="PackedScene" uid="uid://dowh0cdyuldlp" path="res://scenes/coin.tscn" id="13_trtic"] [ext_resource type="PackedScene" uid="uid://dkht2dvm4ob7d" path="res://scenes/slime.tscn" id="14_trtic"] +[ext_resource type="PackedScene" uid="uid://6cde4fo65rig" path="res://scenes/ui.tscn" id="15_ir15t"] [sub_resource type="TileMapPattern" id="TileMapPattern_u5sy4"] tile_data = PackedInt32Array(0, 1, 0, 65536, 1, 1, 131072, 1, 1, 196608, 1, 2, 1, 65537, 0, 65537, 65537, 1, 131073, 131073, 1, 196609, 65537, 2, 2, 65537, 0, 65538, 131073, 1, 131074, 65537, 1, 196610, 65537, 2, 3, 131073, 0, 65539, 262145, 1, 131075, 131073, 1, 196611, 131073, 2) @@ -521,3 +522,7 @@ position = Vector2(494, 311) [node name="Slime2" parent="Slimes" unique_id=141676046 instance=ExtResource("14_trtic")] position = Vector2(461, 311) + +[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1721503250] + +[node name="ui" parent="CanvasLayer" unique_id=1523689629 instance=ExtResource("15_ir15t")] diff --git a/scenes/level2.tscn b/scenes/level2.tscn index f928c0f..1b5b1b1 100644 --- a/scenes/level2.tscn +++ b/scenes/level2.tscn @@ -12,6 +12,7 @@ [ext_resource type="PackedScene" uid="uid://bf50mxdma8wq4" path="res://scenes/trigger.tscn" id="10_s4es8"] [ext_resource type="PackedScene" uid="uid://b6lw2go5mwk3h" path="res://scenes/crate.tscn" id="11_63e4f"] [ext_resource type="PackedScene" uid="uid://bgi18lbutp5ui" path="res://scenes/npc_character.tscn" id="12_y6lc1"] +[ext_resource type="PackedScene" uid="uid://6cde4fo65rig" path="res://scenes/ui.tscn" id="13_56gwk"] [sub_resource type="TileMapPattern" id="TileMapPattern_u5sy4"] tile_data = PackedInt32Array(0, 1, 0, 65536, 1, 1, 131072, 1, 1, 196608, 1, 2, 1, 65537, 0, 65537, 65537, 1, 131073, 131073, 1, 196609, 65537, 2, 2, 65537, 0, 65538, 131073, 1, 131074, 65537, 1, 196610, 65537, 2, 3, 131073, 0, 65539, 262145, 1, 131075, 131073, 1, 196611, 131073, 2) @@ -497,3 +498,7 @@ shape = SubResource("WorldBoundaryShape2D_lbhrr") [node name="NPCCharacter" parent="." unique_id=597270257 instance=ExtResource("12_y6lc1")] position = Vector2(103, 417) + +[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=161671243] + +[node name="ui" parent="CanvasLayer" unique_id=1523689629 instance=ExtResource("13_56gwk")] diff --git a/scenes/level3.tscn b/scenes/level3.tscn index 75b75a1..59ebc4b 100644 --- a/scenes/level3.tscn +++ b/scenes/level3.tscn @@ -12,6 +12,7 @@ [ext_resource type="PackedScene" uid="uid://bf50mxdma8wq4" path="res://scenes/trigger.tscn" id="10_x008a"] [ext_resource type="PackedScene" uid="uid://b6lw2go5mwk3h" path="res://scenes/crate.tscn" id="11_atr84"] [ext_resource type="PackedScene" uid="uid://bgi18lbutp5ui" path="res://scenes/npc_character.tscn" id="12_qyu38"] +[ext_resource type="PackedScene" uid="uid://6cde4fo65rig" path="res://scenes/ui.tscn" id="13_bradm"] [sub_resource type="TileMapPattern" id="TileMapPattern_u5sy4"] tile_data = PackedInt32Array(0, 1, 0, 65536, 1, 1, 131072, 1, 1, 196608, 1, 2, 1, 65537, 0, 65537, 65537, 1, 131073, 131073, 1, 196609, 65537, 2, 2, 65537, 0, 65538, 131073, 1, 131074, 65537, 1, 196610, 65537, 2, 3, 131073, 0, 65539, 262145, 1, 131075, 131073, 1, 196611, 131073, 2) @@ -497,3 +498,7 @@ shape = SubResource("WorldBoundaryShape2D_lbhrr") [node name="NPCCharacter" parent="." unique_id=597270257 instance=ExtResource("12_qyu38")] position = Vector2(103, 417) + +[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1454087989] + +[node name="ui" parent="CanvasLayer" unique_id=1523689629 instance=ExtResource("13_bradm")] diff --git a/scenes/player.tscn b/scenes/player.tscn index 0d3fc46..ef3c73a 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -3,14 +3,72 @@ [ext_resource type="Script" uid="uid://c17de7vvtri1e" path="res://scripts/player.gd" id="1_3vyb7"] [ext_resource type="Texture2D" uid="uid://bihghvekq435s" path="res://assets/graphics/player/jump_fall/player jump 48x48.png" id="2_dqkch"] [ext_resource type="Texture2D" uid="uid://dyus25iplw8ei" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_g2els"] +[ext_resource type="Texture2D" uid="uid://dgj6nq2pnxgho" path="res://assets/graphics/player/death/Player Death 64x64.png" id="2_tuyoq"] [ext_resource type="Texture2D" uid="uid://3c7ngirfyrkh" path="res://assets/graphics/player/running/player run 48x48.png" id="3_qhqgy"] +[ext_resource type="Texture2D" uid="uid://cdsu1cetxa45b" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="4_fjrip"] [sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"] +[sub_resource type="AtlasTexture" id="AtlasTexture_l71n6"] +atlas = ExtResource("2_tuyoq") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ke2ow"] +atlas = ExtResource("2_tuyoq") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ujl30"] +atlas = ExtResource("2_tuyoq") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_31cv2"] +atlas = ExtResource("2_tuyoq") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pf23h"] +atlas = ExtResource("2_tuyoq") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dt7fs"] +atlas = ExtResource("2_tuyoq") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wqfne"] +atlas = ExtResource("2_tuyoq") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wnwbv"] +atlas = ExtResource("2_tuyoq") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gl8cc"] +atlas = ExtResource("2_tuyoq") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_487ah"] +atlas = ExtResource("2_tuyoq") +region = Rect2(432, 0, 48, 48) + [sub_resource type="AtlasTexture" id="AtlasTexture_i4ail"] atlas = ExtResource("2_dqkch") region = Rect2(96, 0, 48, 48) +[sub_resource type="AtlasTexture" id="AtlasTexture_md1ol"] +atlas = ExtResource("4_fjrip") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bj30b"] +atlas = ExtResource("4_fjrip") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jc3p3"] +atlas = ExtResource("4_fjrip") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hax0n"] +atlas = ExtResource("4_fjrip") +region = Rect2(144, 0, 48, 48) + [sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"] atlas = ExtResource("2_g2els") region = Rect2(0, 0, 48, 48) @@ -91,10 +149,85 @@ region = Rect2(288, 0, 48, 48) atlas = ExtResource("3_qhqgy") region = Rect2(336, 0, 48, 48) +[sub_resource type="AtlasTexture" id="AtlasTexture_t4otl"] +atlas = ExtResource("2_tuyoq") +region = Rect2(432, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j2b1d"] +atlas = ExtResource("2_tuyoq") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cs1tg"] +atlas = ExtResource("2_tuyoq") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2dvfe"] +atlas = ExtResource("2_tuyoq") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_giy8y"] +atlas = ExtResource("2_tuyoq") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fdfoy"] +atlas = ExtResource("2_tuyoq") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hhpqf"] +atlas = ExtResource("2_tuyoq") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_g5jhy"] +atlas = ExtResource("2_tuyoq") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_holxr"] +atlas = ExtResource("2_tuyoq") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mx1m4"] +atlas = ExtResource("2_tuyoq") +region = Rect2(0, 0, 48, 48) + [sub_resource type="SpriteFrames" id="SpriteFrames_jej6c"] animations = [{ "frames": [{ "duration": 1.0, +"texture": SubResource("AtlasTexture_l71n6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ke2ow") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ujl30") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_31cv2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pf23h") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dt7fs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wqfne") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wnwbv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gl8cc") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_487ah") +}], +"loop": false, +"name": &"death", +"speed": 3.0 +}, { +"frames": [{ +"duration": 1.0, "texture": SubResource("AtlasTexture_i4ail") }], "loop": false, @@ -103,6 +236,23 @@ animations = [{ }, { "frames": [{ "duration": 1.0, +"texture": SubResource("AtlasTexture_md1ol") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bj30b") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jc3p3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hax0n") +}], +"loop": false, +"name": &"hurt", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, "texture": SubResource("AtlasTexture_qhqgy") }, { "duration": 1.0, @@ -175,6 +325,41 @@ animations = [{ "loop": true, "name": &"running", "speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_t4otl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j2b1d") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cs1tg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2dvfe") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_giy8y") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fdfoy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hhpqf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_g5jhy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_holxr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mx1m4") +}], +"loop": true, +"name": &"spawn", +"speed": 12.0 }] [node name="Player" type="CharacterBody2D" unique_id=161143934] @@ -195,7 +380,7 @@ position = Vector2(-15, -3) texture_filter = 1 position = Vector2(1, -7) sprite_frames = SubResource("SpriteFrames_jej6c") -animation = &"falling" +animation = &"death" autoplay = "idle" [node name="Camera2D" type="Camera2D" parent="." unique_id=453583176] diff --git a/scenes/ui.tscn b/scenes/ui.tscn new file mode 100644 index 0000000..3342a69 --- /dev/null +++ b/scenes/ui.tscn @@ -0,0 +1,47 @@ +[gd_scene format=3 uid="uid://6cde4fo65rig"] + +[ext_resource type="Script" uid="uid://6tbvoaj20pws" path="res://scripts/ui.gd" id="1_nt7q6"] + +[node name="ui" type="Control" unique_id=1523689629] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_nt7q6") + +[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=860304686] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer" unique_id=815365890] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer" unique_id=1206394048] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="health" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer" unique_id=1839745909] +layout_mode = 2 +text = "HEALTH" + +[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer/HBoxContainer" unique_id=1606638895] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="timer" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer2" unique_id=1053612937] +layout_mode = 2 +text = "TIMER" +horizontal_alignment = 1 + +[node name="MarginContainer3" type="MarginContainer" parent="VBoxContainer/HBoxContainer" unique_id=85183065] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="coiins" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer3" unique_id=827757901] +layout_mode = 2 +text = "COINS" +horizontal_alignment = 2 diff --git a/scripts/gameController.gd b/scripts/gameController.gd index 835fdb4..dee64f5 100644 --- a/scripts/gameController.gd +++ b/scripts/gameController.gd @@ -4,6 +4,11 @@ var crateTotal = 0 signal destroySignal(body) signal teleportSignal(body) signal levelChangeSignal(level) +signal playerDamageSignal(health, maxHealth) +signal playerDeathSignal +signal countDownSignal(timeRemaining) +signal coinCollectedSignal(totalCoinsCollected, coinsRemaining) + var currentScene:String = "res://scenes/game.tscn" var timer := Timer.new() @@ -20,22 +25,29 @@ var playerStartingHealth = 100 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/slimeStats.tres") + player = load("res://scripts/rscs/playerStats.tres") add_child(timer) timer.wait_time = 1 timer.one_shot= false timer.connect("timeout", secondCounter) timer.start() - + func reset()->void: timeAvailable = timers[currentLevel] - playerHealth = playerStartingHealth + playerHealth = player.starting_health + coinsCollected = 0 -func secondCounter()->void: + func secondCounter()->void: timeAvailable -=1 + countDownSignal.emit(timeAvailable) if timeAvailable <=0: print("YOU LOSE BABY!!") levelChangeSignal.emit(levels[currentLevel]) @@ -78,7 +90,7 @@ func bulletDamage(body:Node2D, bullet:Bullet)->void: destroySignal.emit(body) destroySignal.emit(bullet) if body is Slime: - enemiesDict[body]["health"] -= 10 + enemiesDict[body]["health"] -= player.rangeDamage if enemiesDict[body]["health"]<=0: destroySignal.emit(body) destroySignal.emit(bullet) @@ -90,6 +102,7 @@ func _on_coin_collected(body:Node2D, coin:Coin)->void: func totalCoins(value)->void: print("GC knows coins remaining "+str(value)) + coinCollectedSignal.emit(coinsCollected, value) if value <=0: #no coins left in level currentLevel +=1 @@ -103,12 +116,20 @@ func _on_slime_damage(body:Node2D, slime:Slime)->void: print("GC knows slime damage to player "+str(playerHealth)) if playerHealth <=0: print("YOU DED") - levelChangeSignal.emit(levels[currentLevel]) + playerDeathSignal.emit() + + else: + #damage + playerDamageSignal.emit(playerHealth, player.max_health) + func addEnemyToLevel(slime:Slime)->void: - var randDamage:int = randi()%10 + # var randDamage:int = randi()%10 var enemyStat = { - "health":50, - "damage":randDamage + "health":enemy.starting_health, + "damage":enemy.meleeDamage } #put it in dictionary enemiesDict[slime]=enemyStat + +func loadLevel()->void: + levelChangeSignal.emit(levels[currentLevel]) diff --git a/scripts/player.gd b/scripts/player.gd index 42dcd97..aff61d6 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -11,13 +11,16 @@ const BUMP_POWER = 50 enum FaceDirection{LEFT, RIGHT} var facing:FaceDirection = FaceDirection.RIGHT var direction -enum PlayerState{IDLE,RUNNING, JUMPING, FALLING} +enum PlayerState{IDLE,RUNNING, JUMPING, FALLING, HURT, DEAD} var current_player_state:PlayerState = PlayerState.IDLE var jumpUp:bool = false +signal deathAnimationCompleteSignal + func _physics_process(delta: float) -> void: - handle_input() + if current_player_state != PlayerState.DEAD: + handle_input() handle_movement(delta) handle_state() handle_animation() @@ -36,6 +39,7 @@ func handle_input()->void: velocity.y = JUMP_VELOCITY current_player_state = PlayerState.JUMPING jumpUp = true + # Handle Shoot if Input.is_action_just_pressed("shoot"): print("Player wants to shoot") @@ -71,6 +75,10 @@ func handle_animation()->void: player_graphic.play("jumping") PlayerState.FALLING: player_graphic.play("falling") + PlayerState.HURT: + player_graphic.play("hurt") + PlayerState.DEAD: + player_graphic.play("death") func handle_movement(delta)->void: # Add the gravity. @@ -98,3 +106,13 @@ func _on_animation_finished() -> void: match current_player_state: PlayerState.JUMPING: jumpUp = false + PlayerState.HURT: + current_player_state = PlayerState.IDLE + PlayerState.DEAD: + deathAnimationCompleteSignal.emit() + +func playerDamage(health, maxHealth) ->void: + current_player_state = PlayerState.HURT +func playerDead()->void: + print("Player should die") + current_player_state = PlayerState.DEAD diff --git a/scripts/rscs/characterStats.gd b/scripts/rscs/characterStats.gd new file mode 100644 index 0000000..419cd58 --- /dev/null +++ b/scripts/rscs/characterStats.gd @@ -0,0 +1,11 @@ +class_name CharacterStats extends Resource + +@export_category("health") +@export var health:int = 100 +@export var max_health:int =100 +@export var starting_health:int = 100 + +# damage" +@export_category("damage") +@export var meleeDamage: int = 10 +@export var rangeDamage: int =5 diff --git a/scripts/rscs/characterStats.gd.uid b/scripts/rscs/characterStats.gd.uid new file mode 100644 index 0000000..0d141e4 --- /dev/null +++ b/scripts/rscs/characterStats.gd.uid @@ -0,0 +1 @@ +uid://jdmo742f5t43 diff --git a/scripts/rscs/playerStats.tres b/scripts/rscs/playerStats.tres new file mode 100644 index 0000000..f11f4ad --- /dev/null +++ b/scripts/rscs/playerStats.tres @@ -0,0 +1,7 @@ +[gd_resource type="Resource" script_class="CharacterStats" format=3 uid="uid://b6qxf7j8kcw7f"] + +[ext_resource type="Script" uid="uid://jdmo742f5t43" path="res://scripts/rscs/characterStats.gd" id="1_sqkfu"] + +[resource] +script = ExtResource("1_sqkfu") +metadata/_custom_type_script = "uid://jdmo742f5t43" diff --git a/scripts/rscs/slimeStats.tres b/scripts/rscs/slimeStats.tres new file mode 100644 index 0000000..0a099cb --- /dev/null +++ b/scripts/rscs/slimeStats.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="CharacterStats" format=3 uid="uid://qpkg5xp8sk1a"] + +[ext_resource type="Script" uid="uid://jdmo742f5t43" path="res://scripts/rscs/characterStats.gd" id="1_ppipo"] + +[resource] +script = ExtResource("1_ppipo") +health = 20 +max_health = 30 +starting_health = 20 +meleeDamage = 20 +rangeDamage = 0 +metadata/_custom_type_script = "uid://jdmo742f5t43" diff --git a/scripts/scene_manager.gd b/scripts/scene_manager.gd index f4fd30e..dd971a9 100644 --- a/scripts/scene_manager.gd +++ b/scripts/scene_manager.gd @@ -4,6 +4,8 @@ class_name SceneManager extends Node2D @onready var level: Node2D = $"../Level" @onready var coins: Node2D = $"../Coins" @onready var slimes: Node2D = $"../Slimes" +@onready var player: Player = $"../Player" +@onready var ui: UI = $"../CanvasLayer/ui" var bullet = preload("res://scenes/bullet.tscn") var bulletArray:Array[Bullet] = [] @@ -20,7 +22,10 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: - pass + if Input.is_action_just_pressed("save"): + print("Save the game!") + if Input.is_action_just_pressed("load"): + print("Load the game!") func buildLevel()->void: print("building level") @@ -33,6 +38,13 @@ func buildLevel()->void: Gamecontroller.destroySignal.connect(destroy) Gamecontroller.teleportSignal.connect(teleport) Gamecontroller.levelChangeSignal.connect(loadLevel) + Gamecontroller.playerDamageSignal.connect(player.playerDamage) + Gamecontroller.playerDamageSignal.connect(ui.updateHealth) + Gamecontroller.playerDeathSignal.connect(player.playerDead) + Gamecontroller.countDownSignal.connect(ui.updateTimer) + Gamecontroller.coinCollectedSignal.connect(ui.updateCoins) + player.deathAnimationCompleteSignal.connect(Gamecontroller.loadLevel) + func updateEnemies()->void: if slimes: var totalSlimes = 0 diff --git a/scripts/ui.gd b/scripts/ui.gd new file mode 100644 index 0000000..9c0617c --- /dev/null +++ b/scripts/ui.gd @@ -0,0 +1,16 @@ +class_name UI extends Control +@onready var health: Label = $VBoxContainer/HBoxContainer/MarginContainer/health +@onready var timer: Label = $VBoxContainer/HBoxContainer/MarginContainer2/timer +@onready var coins: Label = $VBoxContainer/HBoxContainer/MarginContainer3/coiins + +func _ready() -> void: + health.text = "Hi MOM!" + +func updateTimer(timerValue)->void: + timer.text = str(timerValue) + +func updateHealth(healthValue, maxHealth)->void: + health.text = str(healthValue) + +func updateCoins(collectedCoins, coinsRemaining)->void: + coins.text= str(collectedCoins)+" of "+str(coinsRemaining+collectedCoins) diff --git a/scripts/ui.gd.uid b/scripts/ui.gd.uid new file mode 100644 index 0000000..9b47f78 --- /dev/null +++ b/scripts/ui.gd.uid @@ -0,0 +1 @@ +uid://6tbvoaj20pws