diff --git a/enemies/ghost animation/Ghost 1.png b/enemies/ghost animation/Ghost 1.png new file mode 100644 index 0000000..7360438 Binary files /dev/null and b/enemies/ghost animation/Ghost 1.png differ diff --git a/enemies/ghost animation/Ghost 1.png.import b/enemies/ghost animation/Ghost 1.png.import new file mode 100644 index 0000000..b1d0f88 --- /dev/null +++ b/enemies/ghost animation/Ghost 1.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d3b5hmhjw2jyc" +path="res://.godot/imported/Ghost 1.png-43131954ed622829dc5453ddf6a96b4c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://enemies/ghost animation/Ghost 1.png" +dest_files=["res://.godot/imported/Ghost 1.png-43131954ed622829dc5453ddf6a96b4c.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/enemies/ghost animation/Ghost 2.png b/enemies/ghost animation/Ghost 2.png new file mode 100644 index 0000000..3da1dc5 Binary files /dev/null and b/enemies/ghost animation/Ghost 2.png differ diff --git a/enemies/ghost animation/Ghost 2.png.import b/enemies/ghost animation/Ghost 2.png.import new file mode 100644 index 0000000..87f2b9b --- /dev/null +++ b/enemies/ghost animation/Ghost 2.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dfhxhum8lek56" +path="res://.godot/imported/Ghost 2.png-67077adaa01a71a5c0b85fac254bdf8e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://enemies/ghost animation/Ghost 2.png" +dest_files=["res://.godot/imported/Ghost 2.png-67077adaa01a71a5c0b85fac254bdf8e.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/enemies/ghost animation/Ghost 3.png b/enemies/ghost animation/Ghost 3.png new file mode 100644 index 0000000..b0250cd Binary files /dev/null and b/enemies/ghost animation/Ghost 3.png differ diff --git a/enemies/ghost animation/Ghost 3.png.import b/enemies/ghost animation/Ghost 3.png.import new file mode 100644 index 0000000..5d4f743 --- /dev/null +++ b/enemies/ghost animation/Ghost 3.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ve5px6ib45g" +path="res://.godot/imported/Ghost 3.png-18da238556f83c92715d2db31a14d159.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://enemies/ghost animation/Ghost 3.png" +dest_files=["res://.godot/imported/Ghost 3.png-18da238556f83c92715d2db31a14d159.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/enemies/ghost animation/Ghost 4.png b/enemies/ghost animation/Ghost 4.png new file mode 100644 index 0000000..b2b91aa Binary files /dev/null and b/enemies/ghost animation/Ghost 4.png differ diff --git a/enemies/ghost animation/Ghost 4.png.import b/enemies/ghost animation/Ghost 4.png.import new file mode 100644 index 0000000..1ac4e37 --- /dev/null +++ b/enemies/ghost animation/Ghost 4.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cmg8yws3gwx6u" +path="res://.godot/imported/Ghost 4.png-45ba6df3ef207a5eff72f5f0036139d6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://enemies/ghost animation/Ghost 4.png" +dest_files=["res://.godot/imported/Ghost 4.png-45ba6df3ef207a5eff72f5f0036139d6.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/enemies/ghost animation/Ghost 5.png b/enemies/ghost animation/Ghost 5.png new file mode 100644 index 0000000..850769f Binary files /dev/null and b/enemies/ghost animation/Ghost 5.png differ diff --git a/enemies/ghost animation/Ghost 5.png.import b/enemies/ghost animation/Ghost 5.png.import new file mode 100644 index 0000000..c47e6e7 --- /dev/null +++ b/enemies/ghost animation/Ghost 5.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bs3lt13umfxu8" +path="res://.godot/imported/Ghost 5.png-08f0125e59cfd0173a5d36d75efeae60.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://enemies/ghost animation/Ghost 5.png" +dest_files=["res://.godot/imported/Ghost 5.png-08f0125e59cfd0173a5d36d75efeae60.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/enemies/ghost.tscn b/enemies/ghost.tscn index f5938fb..be29f28 100644 --- a/enemies/ghost.tscn +++ b/enemies/ghost.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" uid="uid://12jns4dppxxj" path="res://enemies/ghost.gd" id="1_6attn"] [ext_resource type="PackedScene" uid="uid://mtfsdd4cdf3a" path="res://utils/enemy_hurtbox.tscn" id="2_34o1m"] -[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_obmiq"] +[ext_resource type="Texture2D" uid="uid://d3b5hmhjw2jyc" path="res://enemies/ghost animation/Ghost 1.png" id="3_34o1m"] [ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="3_obmiq"] [sub_resource type="CircleShape2D" id="CircleShape2D_6attn"] @@ -22,7 +22,7 @@ scale = Vector2(6, 6) shape = SubResource("CircleShape2D_6attn") [node name="Sprite2D" type="Sprite2D" parent="."] -texture = ExtResource("2_obmiq") +texture = ExtResource("3_34o1m") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] scale = Vector2(6, 6) diff --git a/item_ui/item_ui.gd b/item_ui/item_ui.gd new file mode 100644 index 0000000..8ad93f1 --- /dev/null +++ b/item_ui/item_ui.gd @@ -0,0 +1,9 @@ +extends MarginContainer + +@export var player : Player; + +func _on_player_active_item_changed(newitem: ActiveItem) -> void: + %ItemTexture.texture = newitem.sprite + +func _process(_delta: float) -> void: + player diff --git a/item_ui/item_ui.gd.uid b/item_ui/item_ui.gd.uid new file mode 100644 index 0000000..06d07e6 --- /dev/null +++ b/item_ui/item_ui.gd.uid @@ -0,0 +1 @@ +uid://eusti457vwq1 diff --git a/item_ui/item_ui.tscn b/item_ui/item_ui.tscn index 1f2de90..5676bf2 100644 --- a/item_ui/item_ui.tscn +++ b/item_ui/item_ui.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://73g8y37skebh"] -[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_lfuq2"] +[ext_resource type="Script" uid="uid://eusti457vwq1" path="res://item_ui/item_ui.gd" id="1_lfuq2"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8oq0s"] draw_center = false @@ -26,12 +26,13 @@ theme_override_constants/margin_left = 25 theme_override_constants/margin_top = 25 theme_override_constants/margin_right = 25 theme_override_constants/margin_bottom = 25 +script = ExtResource("1_lfuq2") [node name="PanelContainer" type="PanelContainer" parent="."] layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_8oq0s") -[node name="TextureRect" type="TextureRect" parent="PanelContainer"] +[node name="ItemTexture" type="TextureRect" parent="PanelContainer"] +unique_name_in_owner = true layout_mode = 2 -texture = ExtResource("1_lfuq2") expand_mode = 1 diff --git a/items/active_item.gd b/items/active_item.gd index 2d7d09b..d110c4b 100644 --- a/items/active_item.gd +++ b/items/active_item.gd @@ -1,7 +1,14 @@ class_name ActiveItem extends Item +@export var sprite : Texture2D + func collect() -> bool: if (player.active_item == null): player.active_item = self return true return false + +func activate(): + assert(false) + + diff --git a/items/item_spawn.tscn b/items/item_spawn.tscn index 3956358..1433d89 100644 --- a/items/item_spawn.tscn +++ b/items/item_spawn.tscn @@ -1,14 +1,14 @@ -[gd_scene load_steps=4 format=3 uid="uid://xj0of571aur1"] +[gd_scene load_steps=5 format=3 uid="uid://xj0of571aur1"] [ext_resource type="Script" uid="uid://b8em61mqgdi58" path="res://items/item_spawn.gd" id="1_ms6tn"] [ext_resource type="PackedScene" uid="uid://b00185vygcka1" path="res://items/heal_item.tscn" id="2_w6i8k"] [ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="3_5pwuf"] +[ext_resource type="PackedScene" uid="uid://ewe36lqcjojk" path="res://items/updash.tscn" id="3_8hnnb"] [node name="ItemSpawn" type="Node2D"] script = ExtResource("1_ms6tn") common_items = Array[PackedScene]([ExtResource("2_w6i8k")]) -rare_items = Array[PackedScene]([ExtResource("2_w6i8k")]) -unique_items = Array[PackedScene]([ExtResource("2_w6i8k")]) +rare_items = Array[PackedScene]([ExtResource("3_8hnnb")]) metadata/_custom_type_script = "uid://b8em61mqgdi58" [node name="EarthAligner" parent="." instance=ExtResource("3_5pwuf")] diff --git a/items/updash.tscn b/items/updash.tscn index 799aa98..dd04581 100644 --- a/items/updash.tscn +++ b/items/updash.tscn @@ -1,12 +1,13 @@ [gd_scene load_steps=4 format=3 uid="uid://ewe36lqcjojk"] -[ext_resource type="Script" uid="uid://bbwsc2a2hd0ow" path="res://items/updash.gd" id="1_ghbl6"] +[ext_resource type="Script" path="res://items/updash.gd" id="1_ghbl6"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_ptc3l"] [sub_resource type="CircleShape2D" id="CircleShape2D_ghbl6"] [node name="Updash" type="Area2D"] script = ExtResource("1_ghbl6") +sprite = ExtResource("1_ptc3l") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] scale = Vector2(3, 3) diff --git a/main.tscn b/main.tscn index a818ccf..c3311cf 100644 --- a/main.tscn +++ b/main.tscn @@ -43,7 +43,8 @@ autostart = true offset_right = 128.0 offset_bottom = 128.0 -[node name="ItemUI" parent="CanvasLayer" instance=ExtResource("6_4c57u")] +[node name="ItemUI" parent="CanvasLayer" node_paths=PackedStringArray("player") instance=ExtResource("6_4c57u")] +player = NodePath("../../Player") [node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")] visible = false @@ -58,6 +59,7 @@ position = Vector2(0, -3000) [node name="HealthUp" parent="." instance=ExtResource("9_4c57u")] position = Vector2(0, -3100) +[connection signal="active_item_changed" from="Player" to="CanvasLayer/ItemUI" method="_on_player_active_item_changed"] [connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"] [connection signal="max_hp_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_max_hp_changed"] [connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"] diff --git a/player/player.gd b/player/player.gd index ca76900..0027380 100644 --- a/player/player.gd +++ b/player/player.gd @@ -1,9 +1,10 @@ -extends CharacterBody2D +class_name Player extends CharacterBody2D # Child Nodes @onready var camera : Camera2D = $Camera2D; @onready var anim_sprite : AnimatedSprite2D = $AnimatedSprite2D; @onready var earth_aligner : Node2D = $EarthAligner; @onready var sword : Area2D = $Sword; +@onready var active_item_cooldown : Timer = $ActiveItemCooldown # allow taking away player control var handle_input : bool = true @@ -47,8 +48,12 @@ var atk_cooldown = 0.5 var atk_timer = 0 # Active Item -var active_item = null -var item_cooldown = 0 +signal active_item_changed(newitem : Item) +var active_item : ActiveItem = null: + set(new_active_item): + active_item = new_active_item + active_item_changed.emit(active_item) + func _ready() -> void: max_hp_changed.emit(max_hp) @@ -75,8 +80,8 @@ func manage_attack(delta : float): atk_timer = atk_cooldown func manage_active(delta : float): - item_cooldown = max(item_cooldown - delta, 0) - if(active_item != null and Input.is_action_just_pressed("item") and item_cooldown <= 0): + # item_cooldown = max(item_cooldown - delta, 0) + if(active_item != null and Input.is_action_just_pressed("item") and active_item_cooldown.is_stopped()): active_item.activate() func manage_movement_options() -> void: diff --git a/player/player.tscn b/player/player.tscn index 12a3644..a28016f 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -58,3 +58,6 @@ frame_progress = 0.433977 [node name="EarthAligner" parent="." instance=ExtResource("3_i3pqv")] [node name="Sword" parent="." instance=ExtResource("4_yw30f")] + +[node name="ActiveItemCooldown" type="Timer" parent="."] +one_shot = true diff --git a/project.godot b/project.godot index 5b573d4..182a0cf 100644 --- a/project.godot +++ b/project.godot @@ -26,11 +26,13 @@ window/size/mode=3 move_right={ "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":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, 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":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) ] } move_left={ "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":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, 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":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) ] } jump={ @@ -41,16 +43,19 @@ jump={ attack={ "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":67,"key_label":0,"unicode":99,"location":0,"echo":false,"script":null) +, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(356, 29),"global_position":Vector2(365, 77),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } drop={ "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":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, 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":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) ] } item={ "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":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null) +, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(297, 25),"global_position":Vector2(306, 73),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null) ] }