bug arreglado

This commit is contained in:
Diego De la Viuda Llorente committed 2026-10-20 17:20:42 +02:00
1 parent 84c148f1ab
commit 82c7963767
4 files changed
+76 -6

No files matched your search

+41 -5
View File
@@ -199,8 +199,9 @@ var is_dead: bool = false
var jumps_remaining: int = 2
var _speed_boost_timer: float = 0.0
var _speed_boost_multiplier: float = 1.0
var _original_move_speed: float = 0.0
var _speed_boost_multiplier: float = 0.0
var _floating_texts: Array = []
# Tracks the highest point reached since leaving the ground, used to scale
# ground pound damage by jump height instead of fall distance.
@@ -252,6 +253,7 @@ func _physics_process(delta: float) -> void:
_handle_horizontal_movement(delta)
_update_punch_damage()
_update_speed_boost(delta)
_update_floating_texts(delta)
move_and_slide()
@@ -528,15 +530,39 @@ func _on_pickup_picked_up(pickup: Node, data: PickupData) -> void:
if is_dead or data == null:
return
if data.effect_type == "heal":
current_health = min(current_health + int(data.value), character_data.max_health)
var heal_amount: int = int(data.value)
current_health = min(current_health + heal_amount, character_data.max_health)
health_changed.emit(current_health, character_data.max_health)
_spawn_floating_text("+" + str(heal_amount), Color(0.2, 1.0, 0.3))
elif data.effect_type == "speed_boost":
_speed_boost_multiplier = data.value
_speed_boost_timer = data.duration
_spawn_floating_text("SPEED UP", Color(1.0, 0.8, 0.2))
func _update_speed_boost(_delta: float) -> void:
pass
func _update_speed_boost(delta: float) -> void:
if _speed_boost_timer > 0.0:
_speed_boost_timer = max(_speed_boost_timer - delta, 0.0)
else:
_speed_boost_multiplier = 0.0
func _spawn_floating_text(text: String, color: Color) -> void:
var entry := {
"text": text,
"timer": 1.2,
"pos": Vector2(-12, -60),
"color": color,
"velocity": Vector2(0, -25)
}
_floating_texts.append(entry)
func _update_floating_texts(delta: float) -> void:
for entry in _floating_texts:
entry.pos += entry.velocity * delta
entry.timer -= delta
_floating_texts = _floating_texts.filter(func(e): return e.timer > 0.0)
func _connect_to_enemies() -> void:
@@ -622,6 +648,8 @@ func _update_timers(delta: float) -> void:
invulnerability_timer = max(invulnerability_timer - delta, 0.0)
if _speed_boost_timer > 0.0:
_speed_boost_timer = max(_speed_boost_timer - delta, 0.0)
else:
_speed_boost_multiplier = 0.0
func _update_animation() -> void:
@@ -722,6 +750,14 @@ func _draw() -> void:
2.0
)
var font: Font = ThemeDB.get_default_theme().get_font("font", "Label")
if font != null:
for entry in _floating_texts:
var alpha: float = clamp(entry.timer / 1.2, 0.0, 1.0)
var col = entry.color
col.a = alpha
draw_string(font, entry.pos, entry.text, 0, -1, 14, col)
func _draw_rectangle_collision(
collision: CollisionShape2D,