diff --git a/items/generic/item_spawn.gd b/items/generic/item_spawn.gd index 41620b5..f391672 100644 --- a/items/generic/item_spawn.gd +++ b/items/generic/item_spawn.gd @@ -2,10 +2,7 @@ class_name ItemSpawn extends Node2D @export var common_items : Array[PackedScene] @export var rare_items : Array[PackedScene] -static var unique_items : Array[PackedScene] = [ - load("res://items/permanent_items/backslash.tscn"), - load("res://items/permanent_items/high_jump.tscn") -] +static var unique_items : Array[PackedScene] = [] @export var rarity_bonus = 0 @export var guarantee_rare : bool = false @@ -38,4 +35,10 @@ func _ready(): var object = packed_scene.instantiate() add_child.call_deferred(object) object.reparent.call_deferred(get_parent()) - + +static func refill_unique_item_pool(): + unique_items = [ + load("res://items/permanent_items/backslash.tscn"), + load("res://items/permanent_items/high_jump.tscn"), + load("res://items/permanent_items/upslash.tscn") + ] diff --git a/items/permanent_items/upslash.gd b/items/permanent_items/upslash.gd new file mode 100644 index 0000000..8a356de --- /dev/null +++ b/items/permanent_items/upslash.gd @@ -0,0 +1,5 @@ +extends Item + +func collect() -> bool: + player.can_upslash = true + return true diff --git a/items/permanent_items/upslash.gd.uid b/items/permanent_items/upslash.gd.uid new file mode 100644 index 0000000..d5d345b --- /dev/null +++ b/items/permanent_items/upslash.gd.uid @@ -0,0 +1 @@ +uid://cyql6o6m4xrv3 diff --git a/items/permanent_items/upslash.tscn b/items/permanent_items/upslash.tscn new file mode 100644 index 0000000..fd038aa --- /dev/null +++ b/items/permanent_items/upslash.tscn @@ -0,0 +1,41 @@ +[gd_scene load_steps=8 format=3 uid="uid://bwtdls58ajair"] + +[ext_resource type="Script" uid="uid://cyql6o6m4xrv3" path="res://items/permanent_items/upslash.gd" id="1_vv4qh"] +[ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="3_ayb0v"] +[ext_resource type="Texture2D" uid="uid://d4mrbgfl7jpqq" path="res://items/ItemShine.png" id="4_35mg8"] +[ext_resource type="Texture2D" uid="uid://c7mrm8uel7r36" path="res://items/permanent_items/backslash.png" id="5_f1n28"] +[ext_resource type="Texture2D" uid="uid://dxcfkdhl4g24c" path="res://items/active_items/updash/updash.png" id="6_4gfq4"] +[ext_resource type="AudioStream" uid="uid://pdd0sy3p4y0d" path="res://sounds/750240__universfield__coin-drop.mp3" id="6_5tj4p"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_hvhjo"] + +[node name="Upslash" type="Area2D"] +script = ExtResource("1_vv4qh") + +[node name="EarthAligner" parent="." instance=ExtResource("3_ayb0v")] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +visible = false +scale = Vector2(7, 7) +shape = SubResource("CircleShape2D_hvhjo") + +[node name="Sprite2D2" type="Sprite2D" parent="."] +modulate = Color(0.725757, 0.519822, 5.77569e-07, 1) +scale = Vector2(2.5, 2.5) +texture = ExtResource("4_35mg8") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(0, -13) +rotation = 0.7853982 +scale = Vector2(1.2, 1.2) +texture = ExtResource("5_f1n28") + +[node name="Sprite2D3" type="Sprite2D" parent="."] +z_index = -1 +position = Vector2(2, -18) +scale = Vector2(1.4, 1.4) +texture = ExtResource("6_4gfq4") + +[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("6_5tj4p") +volume_db = 2.0 diff --git a/player/player.gd b/player/player.gd index c01a18d..b1f723f 100644 --- a/player/player.gd +++ b/player/player.gd @@ -48,6 +48,8 @@ var damage_knockup = 500 # Attack Handling var atk_cooldown = 0.5 var atk_timer = 0 +var can_upslash = true + signal attack # Active Item @@ -86,7 +88,10 @@ 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): - attack.emit() + if Input.is_action_pressed("up") and can_upslash: + attack.emit("up") + else: + attack.emit("horizontal") $AnimatedSprite2D.play("attack") $SwordSwingAudio.play() atk_timer = atk_cooldown diff --git a/player/player.tscn b/player/player.tscn index fd7dbde..b735898 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=20 format=3 uid="uid://cmaovvr15b3qk"] +[gd_scene load_steps=21 format=3 uid="uid://cmaovvr15b3qk"] [ext_resource type="Script" uid="uid://ddidj1uau28ck" path="res://player/player.gd" id="1_4flbx"] [ext_resource type="Texture2D" uid="uid://c4xg25s8loxp0" path="res://player/Player_Walk/Walk 1.png" id="2_hg6s5"] @@ -112,4 +112,5 @@ pitch_scale = 1.62 [node name="SwordSwingAudio" type="AudioStreamPlayer2D" parent="."] stream = ExtResource("17_tqiix") volume_db = -12.0 + [connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_attack_end"] diff --git a/player/sword.gd b/player/sword.gd index 83ab9cd..b273ff0 100644 --- a/player/sword.gd +++ b/player/sword.gd @@ -10,9 +10,16 @@ func _ready() -> void: anim_sprite = $AnimatedSprite2D get_parent().attack.connect(swing) -func swing() -> void: +func swing(dir_str) -> void: facing = - get_parent().facing * facing_mult - scale.x = abs(scale.x) * facing + if dir_str == "up": + scale.x = abs(scale.x) + scale.y = abs(scale.y) * facing + rotation = PI/2 + else: + scale.x = abs(scale.x) * facing + scale.y = abs(scale.y) + rotation = 0 anim_sprite.visible = true await get_tree().create_timer(0.01).timeout slash_timer = slash_duration @@ -23,6 +30,6 @@ func _physics_process(delta: float) -> void: if(slash_timer == 0): anim_sprite.visible = false for area in get_overlapping_areas(): - area.hurt(damage, -get_parent().earth_aligner.global_from_local(Vector2(-facing, 0))) + area.hurt(damage, -get_parent().earth_aligner.global_from_local(Vector2(-facing, 0)).rotated(facing*rotation)) diff --git a/project.godot b/project.godot index c828fc3..544b94b 100644 --- a/project.godot +++ b/project.godot @@ -67,6 +67,11 @@ drop_item={ "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":121,"location":0,"echo":false,"script":null) ] } +up={ +"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":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} [layer_names] diff --git a/world/earth.gd b/world/earth.gd index ad9a151..e58099b 100644 --- a/world/earth.gd +++ b/world/earth.gd @@ -1,4 +1,7 @@ extends Node2D +func _ready() -> void: + ItemSpawn.refill_unique_item_pool() + func get_grid() -> Grid: return $Grid