Broke Activ Items

This commit is contained in:
Florian 2025-09-17 15:59:14 +02:00
parent 5658b57749
commit aec5133150
21 changed files with 249 additions and 15 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -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

View file

@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://12jns4dppxxj" path="res://enemies/ghost.gd" id="1_6attn"] [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="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"] [ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="3_obmiq"]
[sub_resource type="CircleShape2D" id="CircleShape2D_6attn"] [sub_resource type="CircleShape2D" id="CircleShape2D_6attn"]
@ -22,7 +22,7 @@ scale = Vector2(6, 6)
shape = SubResource("CircleShape2D_6attn") shape = SubResource("CircleShape2D_6attn")
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_obmiq") texture = ExtResource("3_34o1m")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(6, 6) scale = Vector2(6, 6)

9
item_ui/item_ui.gd Normal file
View file

@ -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

1
item_ui/item_ui.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://eusti457vwq1

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://73g8y37skebh"] [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"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8oq0s"]
draw_center = false draw_center = false
@ -26,12 +26,13 @@ theme_override_constants/margin_left = 25
theme_override_constants/margin_top = 25 theme_override_constants/margin_top = 25
theme_override_constants/margin_right = 25 theme_override_constants/margin_right = 25
theme_override_constants/margin_bottom = 25 theme_override_constants/margin_bottom = 25
script = ExtResource("1_lfuq2")
[node name="PanelContainer" type="PanelContainer" parent="."] [node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 2 layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_8oq0s") 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 layout_mode = 2
texture = ExtResource("1_lfuq2")
expand_mode = 1 expand_mode = 1

View file

@ -1,7 +1,14 @@
class_name ActiveItem extends Item class_name ActiveItem extends Item
@export var sprite : Texture2D
func collect() -> bool: func collect() -> bool:
if (player.active_item == null): if (player.active_item == null):
player.active_item = self player.active_item = self
return true return true
return false return false
func activate():
assert(false)

View file

@ -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="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://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://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"] [node name="ItemSpawn" type="Node2D"]
script = ExtResource("1_ms6tn") script = ExtResource("1_ms6tn")
common_items = Array[PackedScene]([ExtResource("2_w6i8k")]) common_items = Array[PackedScene]([ExtResource("2_w6i8k")])
rare_items = Array[PackedScene]([ExtResource("2_w6i8k")]) rare_items = Array[PackedScene]([ExtResource("3_8hnnb")])
unique_items = Array[PackedScene]([ExtResource("2_w6i8k")])
metadata/_custom_type_script = "uid://b8em61mqgdi58" metadata/_custom_type_script = "uid://b8em61mqgdi58"
[node name="EarthAligner" parent="." instance=ExtResource("3_5pwuf")] [node name="EarthAligner" parent="." instance=ExtResource("3_5pwuf")]

View file

@ -1,12 +1,13 @@
[gd_scene load_steps=4 format=3 uid="uid://ewe36lqcjojk"] [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"] [ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_ptc3l"]
[sub_resource type="CircleShape2D" id="CircleShape2D_ghbl6"] [sub_resource type="CircleShape2D" id="CircleShape2D_ghbl6"]
[node name="Updash" type="Area2D"] [node name="Updash" type="Area2D"]
script = ExtResource("1_ghbl6") script = ExtResource("1_ghbl6")
sprite = ExtResource("1_ptc3l")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(3, 3) scale = Vector2(3, 3)

View file

@ -43,7 +43,8 @@ autostart = true
offset_right = 128.0 offset_right = 128.0
offset_bottom = 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")] [node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")]
visible = false visible = false
@ -58,6 +59,7 @@ position = Vector2(0, -3000)
[node name="HealthUp" parent="." instance=ExtResource("9_4c57u")] [node name="HealthUp" parent="." instance=ExtResource("9_4c57u")]
position = Vector2(0, -3100) 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="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="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"] [connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"]

View file

@ -1,9 +1,10 @@
extends CharacterBody2D class_name Player extends CharacterBody2D
# Child Nodes # Child Nodes
@onready var camera : Camera2D = $Camera2D; @onready var camera : Camera2D = $Camera2D;
@onready var anim_sprite : AnimatedSprite2D = $AnimatedSprite2D; @onready var anim_sprite : AnimatedSprite2D = $AnimatedSprite2D;
@onready var earth_aligner : Node2D = $EarthAligner; @onready var earth_aligner : Node2D = $EarthAligner;
@onready var sword : Area2D = $Sword; @onready var sword : Area2D = $Sword;
@onready var active_item_cooldown : Timer = $ActiveItemCooldown
# allow taking away player control # allow taking away player control
var handle_input : bool = true var handle_input : bool = true
@ -47,8 +48,12 @@ var atk_cooldown = 0.5
var atk_timer = 0 var atk_timer = 0
# Active Item # Active Item
var active_item = null signal active_item_changed(newitem : Item)
var item_cooldown = 0 var active_item : ActiveItem = null:
set(new_active_item):
active_item = new_active_item
active_item_changed.emit(active_item)
func _ready() -> void: func _ready() -> void:
max_hp_changed.emit(max_hp) max_hp_changed.emit(max_hp)
@ -75,8 +80,8 @@ func manage_attack(delta : float):
atk_timer = atk_cooldown atk_timer = atk_cooldown
func manage_active(delta : float): func manage_active(delta : float):
item_cooldown = max(item_cooldown - delta, 0) # item_cooldown = max(item_cooldown - delta, 0)
if(active_item != null and Input.is_action_just_pressed("item") and item_cooldown <= 0): if(active_item != null and Input.is_action_just_pressed("item") and active_item_cooldown.is_stopped()):
active_item.activate() active_item.activate()
func manage_movement_options() -> void: func manage_movement_options() -> void:

View file

@ -58,3 +58,6 @@ frame_progress = 0.433977
[node name="EarthAligner" parent="." instance=ExtResource("3_i3pqv")] [node name="EarthAligner" parent="." instance=ExtResource("3_i3pqv")]
[node name="Sword" parent="." instance=ExtResource("4_yw30f")] [node name="Sword" parent="." instance=ExtResource("4_yw30f")]
[node name="ActiveItemCooldown" type="Timer" parent="."]
one_shot = true

View file

@ -26,11 +26,13 @@ window/size/mode=3
move_right={ move_right={
"deadzone": 0.2, "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) "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={ move_left={
"deadzone": 0.2, "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) "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={ jump={
@ -41,16 +43,19 @@ jump={
attack={ attack={
"deadzone": 0.2, "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) "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={ drop={
"deadzone": 0.2, "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) "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={ item={
"deadzone": 0.2, "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) "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)
] ]
} }