diff --git a/buildings/building.tscn b/buildings/building.tscn index 1b058c7..7e926d3 100644 --- a/buildings/building.tscn +++ b/buildings/building.tscn @@ -8,7 +8,7 @@ [ext_resource type="PackedScene" uid="uid://dpv1w56yr1xue" path="res://traps/morning_star.tscn" id="5_xr4t5"] [ext_resource type="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="7_35wcg"] [ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://utils/platform.tscn" id="8_sifiv"] -[ext_resource type="PackedScene" uid="uid://xj0of571aur1" path="res://items/item_spawn.tscn" id="9_i1qmw"] +[ext_resource type="PackedScene" uid="uid://xj0of571aur1" path="res://items/generic/item_spawn.tscn" id="9_i1qmw"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_pfkkr"] shader = ExtResource("2_xx8ra") diff --git a/items/active_item.gd b/items/active_items/active_item.gd similarity index 100% rename from items/active_item.gd rename to items/active_items/active_item.gd diff --git a/items/active_item.gd.uid b/items/active_items/active_item.gd.uid similarity index 100% rename from items/active_item.gd.uid rename to items/active_items/active_item.gd.uid diff --git a/items/arrow.gd b/items/active_items/bow/arrow.gd similarity index 100% rename from items/arrow.gd rename to items/active_items/bow/arrow.gd diff --git a/items/arrow.gd.uid b/items/active_items/bow/arrow.gd.uid similarity index 100% rename from items/arrow.gd.uid rename to items/active_items/bow/arrow.gd.uid diff --git a/items/arrow.tscn b/items/active_items/bow/arrow.tscn similarity index 93% rename from items/arrow.tscn rename to items/active_items/bow/arrow.tscn index 7e18afd..f4bb095 100644 --- a/items/arrow.tscn +++ b/items/active_items/bow/arrow.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://dfva4dhflxglr"] -[ext_resource type="Script" uid="uid://bglrm0bb4nla" path="res://items/arrow.gd" id="1_lxthq"] +[ext_resource type="Script" uid="uid://bglrm0bb4nla" path="res://items/active_items/bow/arrow.gd" id="1_lxthq"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_tl37p"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_tfcgf"] diff --git a/items/bow.gd b/items/active_items/bow/bow.gd similarity index 100% rename from items/bow.gd rename to items/active_items/bow/bow.gd diff --git a/items/bow.gd.uid b/items/active_items/bow/bow.gd.uid similarity index 100% rename from items/bow.gd.uid rename to items/active_items/bow/bow.gd.uid diff --git a/items/bow.tscn b/items/active_items/bow/bow.tscn similarity index 88% rename from items/bow.tscn rename to items/active_items/bow/bow.tscn index 457a3bd..d645434 100644 --- a/items/bow.tscn +++ b/items/active_items/bow/bow.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://ddn025xnjngko"] -[ext_resource type="Script" uid="uid://bkcip66at5sug" path="res://items/bow.gd" id="1_xppub"] -[ext_resource type="PackedScene" uid="uid://dfva4dhflxglr" path="res://items/arrow.tscn" id="2_0id2q"] +[ext_resource type="Script" uid="uid://bkcip66at5sug" path="res://items/active_items/bow/bow.gd" id="1_xppub"] +[ext_resource type="PackedScene" uid="uid://dfva4dhflxglr" path="res://items/active_items/bow/arrow.tscn" id="2_0id2q"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_gllxn"] [sub_resource type="CircleShape2D" id="CircleShape2D_gllxn"] diff --git a/items/updash.gd b/items/active_items/updash/updash.gd similarity index 100% rename from items/updash.gd rename to items/active_items/updash/updash.gd diff --git a/items/updash.gd.uid b/items/active_items/updash/updash.gd.uid similarity index 100% rename from items/updash.gd.uid rename to items/active_items/updash/updash.gd.uid diff --git a/items/updash.tscn b/items/active_items/updash/updash.tscn similarity index 92% rename from items/updash.tscn rename to items/active_items/updash/updash.tscn index e2026f0..676c052 100644 --- a/items/updash.tscn +++ b/items/active_items/updash/updash.tscn @@ -1,6 +1,6 @@ [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" uid="uid://bbwsc2a2hd0ow" path="res://items/active_items/updash/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"] diff --git a/items/item.gd b/items/generic/item.gd similarity index 100% rename from items/item.gd rename to items/generic/item.gd diff --git a/items/item.gd.uid b/items/generic/item.gd.uid similarity index 100% rename from items/item.gd.uid rename to items/generic/item.gd.uid diff --git a/items/item_spawn.gd b/items/generic/item_spawn.gd similarity index 100% rename from items/item_spawn.gd rename to items/generic/item_spawn.gd diff --git a/items/item_spawn.gd.uid b/items/generic/item_spawn.gd.uid similarity index 100% rename from items/item_spawn.gd.uid rename to items/generic/item_spawn.gd.uid diff --git a/items/item_spawn.tscn b/items/generic/item_spawn.tscn similarity index 76% rename from items/item_spawn.tscn rename to items/generic/item_spawn.tscn index 5753c45..db31386 100644 --- a/items/item_spawn.tscn +++ b/items/generic/item_spawn.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=7 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="Script" uid="uid://b8em61mqgdi58" path="res://items/generic/item_spawn.gd" id="1_ms6tn"] +[ext_resource type="PackedScene" uid="uid://b00185vygcka1" path="res://items/immediate_items/heal_item/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://gwctb2xqsbj" path="res://items/healthup.tscn" id="3_yi7ag"] -[ext_resource type="PackedScene" uid="uid://ddn025xnjngko" path="res://items/bow.tscn" id="4_v0ua0"] -[ext_resource type="PackedScene" uid="uid://ewe36lqcjojk" path="res://items/updash.tscn" id="5_uitgx"] +[ext_resource type="PackedScene" uid="uid://gwctb2xqsbj" path="res://items/immediate_items/healthup/healthup.tscn" id="3_yi7ag"] +[ext_resource type="PackedScene" uid="uid://ddn025xnjngko" path="res://items/active_items/bow/bow.tscn" id="4_v0ua0"] +[ext_resource type="PackedScene" uid="uid://ewe36lqcjojk" path="res://items/active_items/updash/updash.tscn" id="5_uitgx"] [node name="ItemSpawn" type="Node2D"] script = ExtResource("1_ms6tn") diff --git a/items/heal_item.gd b/items/immediate_items/heal_item/heal_item.gd similarity index 100% rename from items/heal_item.gd rename to items/immediate_items/heal_item/heal_item.gd diff --git a/items/heal_item.gd.uid b/items/immediate_items/heal_item/heal_item.gd.uid similarity index 100% rename from items/heal_item.gd.uid rename to items/immediate_items/heal_item/heal_item.gd.uid diff --git a/items/heal_item.tscn b/items/immediate_items/heal_item/heal_item.tscn similarity index 92% rename from items/heal_item.tscn rename to items/immediate_items/heal_item/heal_item.tscn index ed70383..4ab1ef5 100644 --- a/items/heal_item.tscn +++ b/items/immediate_items/heal_item/heal_item.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=5 format=3 uid="uid://b00185vygcka1"] -[ext_resource type="Script" uid="uid://b43fudwi47qfd" path="res://items/heal_item.gd" id="1_3vbv8"] +[ext_resource type="Script" uid="uid://b43fudwi47qfd" path="res://items/immediate_items/heal_item/heal_item.gd" id="1_3vbv8"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_48lih"] [ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="2_evqwq"] diff --git a/items/healthup.gd b/items/immediate_items/healthup/healthup.gd similarity index 100% rename from items/healthup.gd rename to items/immediate_items/healthup/healthup.gd diff --git a/items/healthup.gd.uid b/items/immediate_items/healthup/healthup.gd.uid similarity index 100% rename from items/healthup.gd.uid rename to items/immediate_items/healthup/healthup.gd.uid diff --git a/items/healthup.tscn b/items/immediate_items/healthup/healthup.tscn similarity index 92% rename from items/healthup.tscn rename to items/immediate_items/healthup/healthup.tscn index c97dec2..9ab798e 100644 --- a/items/healthup.tscn +++ b/items/immediate_items/healthup/healthup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=5 format=3 uid="uid://gwctb2xqsbj"] -[ext_resource type="Script" uid="uid://ce6fxbjarlvtk" path="res://items/healthup.gd" id="1_ivtxh"] +[ext_resource type="Script" uid="uid://ce6fxbjarlvtk" path="res://items/immediate_items/healthup/healthup.gd" id="1_ivtxh"] [ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="2_lolop"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="3_v056v"] diff --git a/items/permanent_items/backslash.gd b/items/permanent_items/backslash.gd new file mode 100644 index 0000000..2cbdf11 --- /dev/null +++ b/items/permanent_items/backslash.gd @@ -0,0 +1,10 @@ +extends Item + +@export var sword : PackedScene + +func collect() -> bool: + var sword_instance = sword.instantiate() + player.add_child(sword_instance) + sword_instance.facing_mult = -1 + return true + diff --git a/items/permanent_items/backslash.gd.uid b/items/permanent_items/backslash.gd.uid new file mode 100644 index 0000000..964b0de --- /dev/null +++ b/items/permanent_items/backslash.gd.uid @@ -0,0 +1 @@ +uid://blg876atd71cg diff --git a/items/permanent_items/backslash.tscn b/items/permanent_items/backslash.tscn new file mode 100644 index 0000000..79634f3 --- /dev/null +++ b/items/permanent_items/backslash.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=6 format=3 uid="uid://bbpf28ohayd8n"] + +[ext_resource type="Script" uid="uid://blg876atd71cg" path="res://items/permanent_items/backslash.gd" id="1_s4bdx"] +[ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="2_kiuxs"] +[ext_resource type="PackedScene" uid="uid://d3e3kuyeh6mr1" path="res://player/sword.tscn" id="2_u6vk4"] +[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="3_vb0oa"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_hvhjo"] + +[node name="Backslash" type="Area2D"] +scale = Vector2(1, -1) +script = ExtResource("1_s4bdx") +sword = ExtResource("2_u6vk4") + +[node name="EarthAligner" parent="." instance=ExtResource("2_kiuxs")] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +scale = Vector2(7, 7) +shape = SubResource("CircleShape2D_hvhjo") + +[node name="Sprite2D" type="Sprite2D" parent="."] +modulate = Color(1, 1, 0, 1) +texture = ExtResource("3_vb0oa") diff --git a/main.tscn b/main.tscn index 3d2c86f..ceace35 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://cxo6bq26huau7"] +[gd_scene load_steps=9 format=3 uid="uid://cxo6bq26huau7"] [ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"] [ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="2_lquwl"] @@ -7,17 +7,10 @@ [ext_resource type="PackedScene" uid="uid://73g8y37skebh" path="res://item_ui/item_ui.tscn" id="6_4c57u"] [ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"] [ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"] +[ext_resource type="PackedScene" uid="uid://bbpf28ohayd8n" path="res://items/permanent_items/backslash.tscn" id="8_5vw27"] [node name="main" type="Node2D"] -[node name="Layer0" type="Parallax2D" parent="."] - -[node name="Layer1" type="Parallax2D" parent="."] - -[node name="Layer2" type="Parallax2D" parent="."] - -[node name="Layer3" type="Parallax2D" parent="."] - [node name="Earth" parent="." instance=ExtResource("3_lquwl")] unique_name_in_owner = true script = ExtResource("2_lquwl") @@ -54,6 +47,9 @@ player = NodePath("../../Player") [node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")] visible = false +[node name="Backslash" parent="." instance=ExtResource("8_5vw27")] +position = Vector2(174, -3243) + [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"] diff --git a/player/player.gd b/player/player.gd index 285c745..288808b 100644 --- a/player/player.gd +++ b/player/player.gd @@ -46,6 +46,7 @@ var damage_knockup = 500 # Attack Handling var atk_cooldown = 0.5 var atk_timer = 0 +signal attack # Active Item signal active_item_changed(newitem : Item) @@ -83,7 +84,7 @@ func manage_attack(delta : float): atk_timer = max(0, atk_timer-delta) if handle_input: if(Input.is_action_just_pressed("attack") and atk_timer <= 0): - sword.swing() + attack.emit() atk_timer = atk_cooldown func manage_active(_delta : float): diff --git a/player/player.tscn b/player/player.tscn index e1a7dea..7297c6b 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -58,7 +58,7 @@ frame_progress = 0.433977 [node name="EarthAligner" parent="." instance=ExtResource("3_i3pqv")] [node name="Sword" parent="." instance=ExtResource("4_yw30f")] -position = Vector2(0, -1.9999999) +position = Vector2(0, -2) [node name="ActiveItemCooldown" type="Timer" parent="."] one_shot = true diff --git a/player/sword.gd b/player/sword.gd index 9540423..83ab9cd 100644 --- a/player/sword.gd +++ b/player/sword.gd @@ -4,13 +4,15 @@ var slash_duration = 0.1 var slash_timer = 0 var damage = 20 var facing = -1 +var facing_mult = 1 func _ready() -> void: anim_sprite = $AnimatedSprite2D + get_parent().attack.connect(swing) func swing() -> void: - facing = -get_parent().facing - scale.x = facing + facing = - get_parent().facing * facing_mult + scale.x = abs(scale.x) * facing anim_sprite.visible = true await get_tree().create_timer(0.01).timeout slash_timer = slash_duration