diff --git a/common/globals/resonance.gd b/common/globals/resonance.gd new file mode 100644 index 0000000..991ba52 --- /dev/null +++ b/common/globals/resonance.gd @@ -0,0 +1,13 @@ +extends Node + +signal fragment_collected + +var _resonance_fragments: int = 0 + +func collect_fragments(count: int): + if count > 0: + _resonance_fragments += count + fragment_collected.emit() + +func get_fragment_count(): + return _resonance_fragments diff --git a/common/globals/resonance.gd.uid b/common/globals/resonance.gd.uid new file mode 100644 index 0000000..9c69499 --- /dev/null +++ b/common/globals/resonance.gd.uid @@ -0,0 +1 @@ +uid://dfn4l008e5cm0 diff --git a/entities/receiver/receiver.gd b/entities/receiver/receiver.gd index 014ecd1..47f900b 100644 --- a/entities/receiver/receiver.gd +++ b/entities/receiver/receiver.gd @@ -1,6 +1,8 @@ extends Interactable class_name Receiver +@export var stored_energy: float = 0 + func _on_interaction_area_body_entered(body: Player) -> void: body.interaction_target = self diff --git a/entities/receiver/receiver_energy_acceptor.gd b/entities/receiver/receiver_energy_acceptor.gd index 5ee8a4d..30eab30 100644 --- a/entities/receiver/receiver_energy_acceptor.gd +++ b/entities/receiver/receiver_energy_acceptor.gd @@ -4,6 +4,7 @@ extends EnergyAcceptor func energize(energy: float, position: Vector2): receiver.modulate = Color.GREEN + receiver.stored_energy += energy func deplete(): receiver.modulate = Color.WHITE diff --git a/entities/resonance/fragment/resonance_fragment.aseprite b/entities/resonance/fragment/resonance_fragment.aseprite new file mode 100644 index 0000000..9303a76 Binary files /dev/null and b/entities/resonance/fragment/resonance_fragment.aseprite differ diff --git a/entities/resonance/fragment/resonance_fragment.aseprite.import b/entities/resonance/fragment/resonance_fragment.aseprite.import new file mode 100644 index 0000000..97d9276 --- /dev/null +++ b/entities/resonance/fragment/resonance_fragment.aseprite.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://8o4m2hhug7m2" +path="res://.godot/imported/resonance_fragment.aseprite-eb1e5f8855d0edd5fd209db6a390b133.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entities/resonance/fragment/resonance_fragment.aseprite" +dest_files=["res://.godot/imported/resonance_fragment.aseprite-eb1e5f8855d0edd5fd209db6a390b133.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +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/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/entities/resonance/fragment/resonance_fragment.gd b/entities/resonance/fragment/resonance_fragment.gd new file mode 100644 index 0000000..917405e --- /dev/null +++ b/entities/resonance/fragment/resonance_fragment.gd @@ -0,0 +1,6 @@ +extends Interactable + +func interact(player: Player): + Resonance.collect_fragments(1) + print("Fragment collected") + queue_free() diff --git a/entities/resonance/fragment/resonance_fragment.gd.uid b/entities/resonance/fragment/resonance_fragment.gd.uid new file mode 100644 index 0000000..f183e54 --- /dev/null +++ b/entities/resonance/fragment/resonance_fragment.gd.uid @@ -0,0 +1 @@ +uid://j36u8fr5qfnv diff --git a/entities/resonance/fragment/resonance_fragment.tscn b/entities/resonance/fragment/resonance_fragment.tscn new file mode 100644 index 0000000..6a8fe82 --- /dev/null +++ b/entities/resonance/fragment/resonance_fragment.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=5 format=3 uid="uid://hgudcjglmgu3"] + +[ext_resource type="Script" uid="uid://j36u8fr5qfnv" path="res://entities/resonance/fragment/resonance_fragment.gd" id="1_ths52"] +[ext_resource type="Texture2D" uid="uid://8o4m2hhug7m2" path="res://entities/resonance/fragment/resonance_fragment.aseprite" id="2_1bsyt"] +[ext_resource type="Script" uid="uid://dryjau28sybgd" path="res://common/interactable_body.gd" id="3_rlkgh"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_h3krt"] +radius = 7.0 + +[node name="ResonanceFragment" type="Node2D"] +script = ExtResource("1_ths52") +metadata/_custom_type_script = "uid://csbip0oj1uu0j" + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.5, 0.5) +texture = ExtResource("2_1bsyt") + +[node name="InteractableBody" type="StaticBody2D" parent="."] +script = ExtResource("3_rlkgh") +metadata/_custom_type_script = "uid://dryjau28sybgd" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="InteractableBody"] +shape = SubResource("CircleShape2D_h3krt") diff --git a/project.godot b/project.godot index d15f9e9..cb2bba8 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="uid://bopet83k23n7t" config/features=PackedStringArray("4.4", "GL Compatibility") config/icon="res://icon.svg" +[autoload] + +Resonance="*res://common/globals/resonance.gd" + [editor] version_control/plugin_name="GitPlugin" diff --git a/ui/world/resource_container.gd b/ui/world/resource_container.gd new file mode 100644 index 0000000..a47c145 --- /dev/null +++ b/ui/world/resource_container.gd @@ -0,0 +1,7 @@ +extends HBoxContainer +class_name ResourceContainer + +@onready var resource_count: Label = %ResourceCount + +func update_resource_count(count: int): + resource_count.text = String.num(count, 0) diff --git a/ui/world/resource_container.gd.uid b/ui/world/resource_container.gd.uid new file mode 100644 index 0000000..6bc65c7 --- /dev/null +++ b/ui/world/resource_container.gd.uid @@ -0,0 +1 @@ +uid://dni6uvp0jginl diff --git a/ui/world/resource_container.tscn b/ui/world/resource_container.tscn new file mode 100644 index 0000000..bc37cc8 --- /dev/null +++ b/ui/world/resource_container.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=3 uid="uid://bvxyjrqyxfho8"] + +[ext_resource type="Script" uid="uid://dni6uvp0jginl" path="res://ui/world/resource_container.gd" id="1_2qhpl"] +[ext_resource type="Texture2D" uid="uid://8o4m2hhug7m2" path="res://entities/resonance/fragment/resonance_fragment.aseprite" id="1_q10xt"] + +[node name="ResourceContainer" type="HBoxContainer"] +script = ExtResource("1_2qhpl") + +[node name="ResourceTexture" type="TextureRect" parent="."] +layout_mode = 2 +texture = ExtResource("1_q10xt") + +[node name="ResourceLabel" type="Label" parent="."] +layout_mode = 2 +text = "Resonance Fragments:" + +[node name="ResourceCount" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 2 +text = "0" diff --git a/ui/world/world_gui.gd b/ui/world/world_gui.gd new file mode 100644 index 0000000..3e2d206 --- /dev/null +++ b/ui/world/world_gui.gd @@ -0,0 +1,9 @@ +extends Control + +@onready var resonance_container: ResourceContainer = %ResonanceContainer + +func _ready() -> void: + Resonance.fragment_collected.connect(_update_resonance_fragments) + +func _update_resonance_fragments(): + resonance_container.update_resource_count(Resonance.get_fragment_count()) diff --git a/ui/world/world_gui.gd.uid b/ui/world/world_gui.gd.uid new file mode 100644 index 0000000..4af1255 --- /dev/null +++ b/ui/world/world_gui.gd.uid @@ -0,0 +1 @@ +uid://4j3yn7ianpwa diff --git a/ui/world/world_gui.tscn b/ui/world/world_gui.tscn new file mode 100644 index 0000000..b80b106 --- /dev/null +++ b/ui/world/world_gui.tscn @@ -0,0 +1,36 @@ +[gd_scene load_steps=3 format=3 uid="uid://brxffqulpxvfg"] + +[ext_resource type="Script" uid="uid://4j3yn7ianpwa" path="res://ui/world/world_gui.gd" id="1_7mgj1"] +[ext_resource type="PackedScene" uid="uid://bvxyjrqyxfho8" path="res://ui/world/resource_container.tscn" id="2_wcbix"] + +[node name="WorldGui" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_7mgj1") + +[node name="TopRightContainer" type="PanelContainer" parent="."] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -225.0 +offset_bottom = 40.0 +grow_horizontal = 0 + +[node name="MarginContainer" type="MarginContainer" parent="TopRightContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 8 +theme_override_constants/margin_top = 4 +theme_override_constants/margin_right = 8 +theme_override_constants/margin_bottom = 4 + +[node name="VBoxContainer" type="VBoxContainer" parent="TopRightContainer/MarginContainer"] +layout_mode = 2 + +[node name="ResonanceContainer" parent="TopRightContainer/MarginContainer/VBoxContainer" instance=ExtResource("2_wcbix")] +unique_name_in_owner = true +layout_mode = 2 diff --git a/worlds/World 1.tscn b/worlds/World 1.tscn index bc194d6..260eec8 100644 --- a/worlds/World 1.tscn +++ b/worlds/World 1.tscn @@ -1,12 +1,14 @@ -[gd_scene load_steps=12 format=4 uid="uid://bopet83k23n7t"] +[gd_scene load_steps=14 format=4 uid="uid://bopet83k23n7t"] [ext_resource type="Texture2D" uid="uid://134x6njync81" path="res://entities/terrain/grass/grass.aseprite" id="1_vd0v3"] +[ext_resource type="PackedScene" uid="uid://brxffqulpxvfg" path="res://ui/world/world_gui.tscn" id="1_yxo24"] [ext_resource type="PackedScene" uid="uid://cprggjrluc751" path="res://entities/player/player.tscn" id="2_8t5gy"] [ext_resource type="Texture2D" uid="uid://b16ui0wwwtfq8" path="res://entities/terrain/fog/fog.aseprite" id="2_hen7s"] [ext_resource type="PackedScene" uid="uid://q3f3j7p3t43w" path="res://entities/button/button.tscn" id="3_8t5gy"] [ext_resource type="PackedScene" uid="uid://cayxfaqxv0irg" path="res://entities/emitter/emitter.tscn" id="4_6qmhn"] [ext_resource type="PackedScene" uid="uid://docbcbiad4ghy" path="res://entities/deflector/deflector.tscn" id="5_wjxv1"] [ext_resource type="PackedScene" uid="uid://fo3xwyve7i5p" path="res://entities/receiver/receiver.tscn" id="6_vcuff"] +[ext_resource type="PackedScene" uid="uid://hgudcjglmgu3" path="res://entities/resonance/fragment/resonance_fragment.tscn" id="8_2l688"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_6qmhn"] texture = ExtResource("1_vd0v3") @@ -252,3 +254,10 @@ position = Vector2(246, 148) [node name="Receiver" parent="." instance=ExtResource("6_vcuff")] position = Vector2(264, 23) + +[node name="ResonanceFragment" parent="." instance=ExtResource("8_2l688")] +position = Vector2(221, -128) + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="WorldGui" parent="CanvasLayer" instance=ExtResource("1_yxo24")]