Compare commits
2 commits
9b05276ad6
...
85f7d32f71
| Author | SHA1 | Date | |
|---|---|---|---|
| 85f7d32f71 | |||
| 697e5ad9e4 |
15 changed files with 82 additions and 22 deletions
|
|
@ -1,10 +1,23 @@
|
|||
class_name ActiveItem extends Item
|
||||
|
||||
@onready var active_item_uses = get_tree().get_root().get_node_or_null("main/UIOverlay/ActiveItemUses")
|
||||
|
||||
@export var sprite : Texture2D
|
||||
@export var uses_left_icon : PackedScene
|
||||
@export var uses = 1:
|
||||
set(new_uses):
|
||||
uses = new_uses
|
||||
if active_item_uses != null:
|
||||
while active_item_uses.get_children().size() > uses:
|
||||
active_item_uses.remove_child(active_item_uses.get_child(0))
|
||||
while active_item_uses.get_children().size() < uses:
|
||||
if uses_left_icon != null:
|
||||
active_item_uses.add_child(uses_left_icon.instantiate())
|
||||
|
||||
func collect() -> bool:
|
||||
if (player.active_item == null):
|
||||
player.active_item = self
|
||||
uses = uses
|
||||
actually_collect()
|
||||
|
||||
return true
|
||||
|
|
@ -13,7 +26,17 @@ func collect() -> bool:
|
|||
func actually_collect():
|
||||
pass
|
||||
|
||||
func trigger_activation():
|
||||
activate()
|
||||
if uses != -1:
|
||||
uses -= 1
|
||||
if uses == 0:
|
||||
remove()
|
||||
|
||||
func activate():
|
||||
assert(false)
|
||||
|
||||
|
||||
|
||||
func remove():
|
||||
uses = 0
|
||||
player.active_item = null
|
||||
self.queue_free()
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 770 B |
BIN
items/active_items/bow/arrow.png
Normal file
BIN
items/active_items/bow/arrow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 875 B |
|
|
@ -3,15 +3,15 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bavoghl2pxs83"
|
||||
path="res://.godot/imported/arror.png-9ea2fbd842e6807dfd42e9ceed411fd2.ctex"
|
||||
path="res://.godot/imported/arrow.png-11da51178d457b4db8d73e91ed37096d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://items/active_items/bow/arror.png"
|
||||
dest_files=["res://.godot/imported/arror.png-9ea2fbd842e6807dfd42e9ceed411fd2.ctex"]
|
||||
source_file="res://items/active_items/bow/arrow.png"
|
||||
dest_files=["res://.godot/imported/arrow.png-11da51178d457b4db8d73e91ed37096d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dfva4dhflxglr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bglrm0bb4nla" path="res://items/active_items/bow/arrow.gd" id="1_lxthq"]
|
||||
[ext_resource type="Texture2D" uid="uid://bavoghl2pxs83" path="res://items/active_items/bow/arror.png" id="2_ilsew"]
|
||||
[ext_resource type="Texture2D" uid="uid://bavoghl2pxs83" path="res://items/active_items/bow/arrow.png" id="2_ilsew"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tfcgf"]
|
||||
size = Vector2(20, 5)
|
||||
|
|
|
|||
9
items/active_items/bow/arrow_icon.tscn
Normal file
9
items/active_items/bow/arrow_icon.tscn
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bu3j6ambrybd2"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bavoghl2pxs83" path="res://items/active_items/bow/arrow.png" id="1_7lvex"]
|
||||
|
||||
[node name="TextureRect" type="TextureRect"]
|
||||
custom_minimum_size = Vector2(0, 3)
|
||||
texture = ExtResource("1_7lvex")
|
||||
expand_mode = 3
|
||||
stretch_mode = 3
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
extends ActiveItem
|
||||
@export var cooldown = 1
|
||||
@export var cooldown = 0.3
|
||||
@export var arrow_scene : PackedScene
|
||||
|
||||
func actually_collect():
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://ddn025xnjngko"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://ddn025xnjngko"]
|
||||
|
||||
[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://d01h01le82gyh" path="res://items/active_items/bow/bow.png" id="3_vkelq"]
|
||||
[ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="4_0id2q"]
|
||||
[ext_resource type="PackedScene" uid="uid://bu3j6ambrybd2" path="res://items/active_items/bow/arrow_icon.tscn" id="4_2dslu"]
|
||||
[ext_resource type="AudioStream" uid="uid://bg1w0fyeyys2p" path="res://sounds/item-equip-6904.mp3" id="5_gfbg0"]
|
||||
[ext_resource type="Texture2D" uid="uid://d4mrbgfl7jpqq" path="res://items/ItemShine.png" id="5_o1smo"]
|
||||
[ext_resource type="AudioStream" uid="uid://10ljbd4djqgb" path="res://sounds/263675__porkmuncher__bow_release_cut.wav" id="7_o1smo"]
|
||||
|
|
@ -17,6 +18,8 @@ collision_mask = 4
|
|||
script = ExtResource("1_xppub")
|
||||
arrow_scene = ExtResource("2_0id2q")
|
||||
sprite = ExtResource("3_vkelq")
|
||||
uses_left_icon = ExtResource("4_2dslu")
|
||||
uses = 5
|
||||
icon = ExtResource("3_vkelq")
|
||||
item_name = "Bow"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
extends ActiveItem
|
||||
var cooldown = 1.5
|
||||
@export var cooldown = 0.2
|
||||
var dash_time = 0.15
|
||||
var dashing = 0
|
||||
var dash_timer : SceneTreeTimer
|
||||
var dash_dir
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
super(delta)
|
||||
if dashing > 0:
|
||||
dashing -= delta
|
||||
if dash_timer != null and dash_timer.time_left > 0:
|
||||
player.reset_to_velocity = player.earth_aligner.local_from_global(dash_dir)
|
||||
|
||||
|
||||
|
|
@ -18,6 +17,14 @@ func activate():
|
|||
$DashSound.play()
|
||||
player.activate_cooldown()
|
||||
player.air_jumps_current = min(player.air_jumps_current + 1, player.air_jumps_max)
|
||||
dashing = dash_time
|
||||
dash_timer = get_tree().create_timer(dash_time)
|
||||
dash_dir = player.earth_aligner.global_from_local(Vector2.RIGHT * player.facing * 1600)
|
||||
player.inv_time = max(player.inv_time, dash_time)
|
||||
|
||||
func remove():
|
||||
if(dash_timer != null):
|
||||
player.active_item = null
|
||||
await dash_timer.timeout
|
||||
super()
|
||||
else:
|
||||
super()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ var cooldown = 10
|
|||
|
||||
func actually_collect():
|
||||
player.set_cooldown(cooldown)
|
||||
|
||||
|
||||
func activate():
|
||||
$UpdashSound.play()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@
|
|||
|
||||
[resource]
|
||||
script = ExtResource("6_rli0f")
|
||||
common = Array[PackedScene]([ExtResource("1_2l6sh")])
|
||||
common = Array[PackedScene]([ExtResource("1_2l6sh"), ExtResource("5_jwi73")])
|
||||
rare = Array[PackedScene]([ExtResource("3_g002j"), ExtResource("2_rli0f"), ExtResource("4_vpswe"), ExtResource("5_jwi73")])
|
||||
unique = Array[PackedScene]([ExtResource("6_73uum"), ExtResource("7_k6eth"), ExtResource("8_8cxou"), ExtResource("9_esvgx")])
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
extends Item
|
||||
|
||||
func collect():
|
||||
player.jump_strength = 1600
|
||||
player.ground_jump_strength = 1600
|
||||
player.air_jump_strength = 1400
|
||||
$SoundCollect.play()
|
||||
return true
|
||||
|
|
|
|||
14
main.tscn
14
main.tscn
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://cxo6bq26huau7"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://cxo6bq26huau7"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"]
|
||||
[ext_resource type="Texture2D" uid="uid://d3fpq76anm4t7" path="res://world/Background Prototype/Background prototype.png" id="3_kek77"]
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://cqn67nwyrtq3k" path="res://ui/journal/journal.tscn" id="10_w48qg"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpe4s6vsn0ujd" path="res://enemies/boss/boss.tscn" id="11_efxa6"]
|
||||
[ext_resource type="Script" uid="uid://gul4u5tw1vxk" path="res://bg_image.gd" id="13_vivmo"]
|
||||
[ext_resource type="PackedScene" uid="uid://ddn025xnjngko" path="res://items/active_items/bow/bow.tscn" id="16_2cqfq"]
|
||||
|
||||
[node name="main" type="Node2D"]
|
||||
|
||||
|
|
@ -55,6 +56,14 @@ texture = ExtResource("4_ycdy4")
|
|||
offset_right = 96.0
|
||||
offset_bottom = 96.0
|
||||
|
||||
[node name="ActiveItemUses" type="VBoxContainer" parent="UIOverlay"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 1863.0
|
||||
offset_top = 25.0
|
||||
offset_right = 1895.0
|
||||
offset_bottom = 120.0
|
||||
alignment = 2
|
||||
|
||||
[node name="ItemUI" parent="UIOverlay" node_paths=PackedStringArray("player") instance=ExtResource("6_4c57u")]
|
||||
player = NodePath("../../Player")
|
||||
|
||||
|
|
@ -95,6 +104,9 @@ colors = Array[Color]([Color(0, 0.6441987, 0.6693053, 1), Color(0.90588236, 0.15
|
|||
script = ExtResource("10_efxa6")
|
||||
boss = ExtResource("11_efxa6")
|
||||
|
||||
[node name="Bow" parent="." instance=ExtResource("16_2cqfq")]
|
||||
position = Vector2(325, -3068)
|
||||
|
||||
[connection signal="active_item_changed" from="Player" to="UIOverlay/ItemUI" method="_on_player_active_item_changed"]
|
||||
[connection signal="health_changed" from="Player" to="UIOverlay/Healthbar" method="_on_player_health_changed"]
|
||||
[connection signal="max_hp_changed" from="Player" to="UIOverlay/Healthbar" method="_on_player_max_hp_changed"]
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ var gravity = 100;
|
|||
# Movement
|
||||
var facing = -1;
|
||||
var hspeed = 150;
|
||||
var jump_strength = 1200;
|
||||
var ground_jump_strength = 1400;
|
||||
var air_jump_strength = 1100;
|
||||
var air_jumps_max = 1;
|
||||
var air_jumps_current = 1;
|
||||
|
||||
|
|
@ -101,9 +102,9 @@ func manage_attack(delta : float):
|
|||
|
||||
func manage_active(_delta : float):
|
||||
if(active_item != null and Input.is_action_just_pressed("item") and active_item_cooldown.is_stopped()):
|
||||
active_item.activate()
|
||||
active_item.trigger_activation()
|
||||
if(Input.is_action_just_pressed("drop_item")):
|
||||
active_item = null
|
||||
active_item.remove()
|
||||
|
||||
func manage_movement_options() -> void:
|
||||
if(is_on_floor()):
|
||||
|
|
@ -154,7 +155,10 @@ func manage_velocity(delta: float) -> void:
|
|||
dropped = true
|
||||
self.position += earth_aligner.global_from_local(Vector2(0,12))
|
||||
if(not dropped):
|
||||
local_velocity.y = -jump_strength
|
||||
if is_on_floor():
|
||||
local_velocity.y = -ground_jump_strength
|
||||
else:
|
||||
local_velocity.y = -air_jump_strength
|
||||
|
||||
if(local_velocity.y > max_fall_speed):
|
||||
local_velocity.y = max_fall_speed
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ func swing(dir_str) -> void:
|
|||
anim_sprite.visible = true
|
||||
await get_tree().physics_frame
|
||||
await get_tree().physics_frame
|
||||
if dir_str == "up":
|
||||
apply_swing_knockback = false
|
||||
slash_timer = slash_duration
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
|
@ -37,7 +39,7 @@ func _process(delta: float) -> void:
|
|||
for area in get_overlapping_areas():
|
||||
var hurt_dir = -get_parent().earth_aligner.global_from_local(Vector2(-facing, 0)).rotated(facing*rotation)
|
||||
if area.hurt(damage, hurt_dir, dmg_id) and apply_swing_knockback:
|
||||
get_parent().reset_to_velocity = Vector2(swing_knockback * facing, 0)
|
||||
get_parent().reset_to_velocity += Vector2(swing_knockback * facing, 0)
|
||||
apply_swing_knockback = false
|
||||
else:
|
||||
apply_swing_knockback = true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue