delete files in nickes
This commit is contained in:
@@ -38,6 +38,7 @@ var collected: bool = false
|
||||
@onready var sfx_coin_collect = $SfxCoinCollect
|
||||
@onready var sfx_loot_collect = $SfxLootCollect
|
||||
@onready var sfx_potion_collect = $SfxPotionCollect
|
||||
@onready var sfx_banana_collect = $SfxBananaCollect
|
||||
@onready var sfx_key_collect = $SfxKeyCollect
|
||||
|
||||
func _ready():
|
||||
@@ -102,21 +103,21 @@ func _setup_sprite():
|
||||
sprite.texture = items_texture
|
||||
sprite.hframes = 20
|
||||
sprite.vframes = 14
|
||||
sprite.frame = (8 * 20) + 11
|
||||
sprite.frame = (8 * 20) + 10
|
||||
LootType.BANANA:
|
||||
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
|
||||
if items_texture:
|
||||
sprite.texture = items_texture
|
||||
sprite.hframes = 20
|
||||
sprite.vframes = 14
|
||||
sprite.frame = (8 * 20) + 12
|
||||
sprite.frame = (8 * 20) + 11
|
||||
LootType.CHERRY:
|
||||
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
|
||||
if items_texture:
|
||||
sprite.texture = items_texture
|
||||
sprite.hframes = 20
|
||||
sprite.vframes = 14
|
||||
sprite.frame = (8 * 20) + 13
|
||||
sprite.frame = (8 * 20) + 12
|
||||
LootType.KEY:
|
||||
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
|
||||
if items_texture:
|
||||
@@ -165,6 +166,14 @@ func _physics_process(delta):
|
||||
# Apply gravity to Z-axis
|
||||
acceleration_z = -300.0 # Gravity
|
||||
velocity_z += acceleration_z * delta
|
||||
|
||||
# CRITICAL: Apply damping to velocity_z to lerp it towards 0 (prevents infinite bouncing)
|
||||
# Dampen more when velocity is small (closer to ground) but allow normal bounces first
|
||||
var damping_factor = 8.0 # How quickly velocity_z approaches 0 (allow more visible bounces)
|
||||
if abs(velocity_z) < 25.0: # More aggressive damping for very small velocities only
|
||||
damping_factor = 20.0
|
||||
velocity_z = lerpf(velocity_z, 0.0, 1.0 - exp(-damping_factor * delta))
|
||||
|
||||
position_z += velocity_z * delta
|
||||
|
||||
# Apply air resistance to slow down horizontal movement while airborne
|
||||
@@ -177,24 +186,38 @@ func _physics_process(delta):
|
||||
# Apply friction when on ground (dampen X/Y momentum faster)
|
||||
velocity = velocity.lerp(Vector2.ZERO, 1.0 - exp(-friction * delta))
|
||||
|
||||
# Check if we should bounce (only if not collected)
|
||||
# Check if we should bounce (only if not collected and velocity is significant)
|
||||
# Allow bouncing but ensure it eventually stops
|
||||
if not collected and abs(velocity_z) > min_bounce_velocity:
|
||||
# Bounce on floor
|
||||
if loot_type == LootType.COIN and bounce_timer == 0.0:
|
||||
# Play bounce sound for coins
|
||||
# Only play bounce sound if bounce is significant enough and timer has elapsed
|
||||
# CRITICAL: Only play sound if velocity is large enough and coin is actually falling (downward)
|
||||
if loot_type == LootType.COIN and bounce_timer == 0.0 and abs(velocity_z) > 50.0 and velocity_z < 0.0:
|
||||
# Play bounce sound for coins (only for significant downward velocities)
|
||||
if sfx_coin_bounce:
|
||||
# Adjust volume based on bounce velocity
|
||||
sfx_coin_bounce.volume_db = -1.0 + (-10.0 - (velocity_z * 0.1))
|
||||
# Adjust volume based on bounce velocity (softer for smaller bounces)
|
||||
var volume_multiplier = clamp(abs(velocity_z) / 100.0, 0.3, 1.0)
|
||||
sfx_coin_bounce.volume_db = -3.0 + (-12.0 * (1.0 - volume_multiplier))
|
||||
sfx_coin_bounce.play()
|
||||
bounce_timer = 0.08 # Prevent rapid bounce sounds
|
||||
bounce_timer = 0.12 # Prevent rapid bounce sounds but allow reasonable bounce rate
|
||||
|
||||
velocity_z = - velocity_z * bounce_restitution
|
||||
is_airborne = true # Still bouncing
|
||||
|
||||
# CRITICAL: Force stop bouncing if velocity is too small after bounce (prevent micro-bounces)
|
||||
# Use a lower threshold to allow a few more bounces before stopping
|
||||
if abs(velocity_z) < min_bounce_velocity * 0.5:
|
||||
velocity_z = 0.0
|
||||
is_airborne = false
|
||||
else:
|
||||
is_airborne = true # Still bouncing
|
||||
else:
|
||||
# Velocity too small or collected - stop bouncing
|
||||
velocity_z = 0.0
|
||||
is_airborne = false
|
||||
else:
|
||||
is_airborne = false
|
||||
# Ensure velocity_z is zero when on ground
|
||||
velocity_z = 0.0
|
||||
# Apply friction even when not airborne (on ground)
|
||||
velocity = velocity.lerp(Vector2.ZERO, 1.0 - exp(-friction * delta))
|
||||
|
||||
@@ -340,7 +363,7 @@ func _process_pickup_on_server(player: Node):
|
||||
player.add_coins(coin_value)
|
||||
# Show floating text with item graphic and text
|
||||
var coin_texture = load("res://assets/gfx/pickups/gold_coin.png")
|
||||
_show_floating_text(player, "+" + str(coin_value) + " coin", Color(1.0, 0.84, 0.0), 0.5, 0.5, coin_texture, 6, 1, 0)
|
||||
_show_floating_text(player, "+" + str(coin_value) + " COIN", Color(1.0, 0.84, 0.0), 0.5, 0.5, coin_texture, 6, 1, 0)
|
||||
|
||||
self.visible = false
|
||||
|
||||
@@ -358,7 +381,7 @@ func _process_pickup_on_server(player: Node):
|
||||
player.heal(heal_amount)
|
||||
# Show floating text with item graphic and heal amount
|
||||
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
|
||||
_show_floating_text(player, "+" + str(int(actual_heal)) + " hp", Color.GREEN, 0.5, 0.5, items_texture, 20, 14, (8 * 20) + 11)
|
||||
_show_floating_text(player, "+" + str(int(actual_heal)) + " HP", Color.GREEN, 0.5, 0.5, items_texture, 20, 14, (8 * 20) + 11)
|
||||
|
||||
self.visible = false
|
||||
|
||||
@@ -367,8 +390,8 @@ func _process_pickup_on_server(player: Node):
|
||||
await sfx_potion_collect.finished
|
||||
queue_free()
|
||||
LootType.BANANA:
|
||||
if sfx_potion_collect:
|
||||
sfx_potion_collect.play()
|
||||
if sfx_banana_collect:
|
||||
sfx_banana_collect.play()
|
||||
# Heal player
|
||||
var actual_heal = 0.0
|
||||
if player.has_method("heal"):
|
||||
@@ -376,17 +399,17 @@ func _process_pickup_on_server(player: Node):
|
||||
player.heal(heal_amount)
|
||||
# Show floating text with item graphic and heal amount
|
||||
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
|
||||
_show_floating_text(player, "+" + str(int(actual_heal)) + " hp", Color.GREEN, 0.5, 0.5, items_texture, 20, 14, (8 * 20) + 12)
|
||||
_show_floating_text(player, "+" + str(int(actual_heal)) + " HP", Color.GREEN, 0.5, 0.5, items_texture, 20, 14, (8 * 20) + 12)
|
||||
|
||||
self.visible = false
|
||||
|
||||
# Wait for sound to finish before removing
|
||||
if sfx_potion_collect and sfx_potion_collect.playing:
|
||||
await sfx_potion_collect.finished
|
||||
if sfx_banana_collect and sfx_banana_collect.playing:
|
||||
await sfx_banana_collect.finished
|
||||
queue_free()
|
||||
LootType.CHERRY:
|
||||
if sfx_potion_collect:
|
||||
sfx_potion_collect.play()
|
||||
if sfx_banana_collect:
|
||||
sfx_banana_collect.play()
|
||||
# Heal player
|
||||
var actual_heal = 0.0
|
||||
if player.has_method("heal"):
|
||||
@@ -394,13 +417,13 @@ func _process_pickup_on_server(player: Node):
|
||||
player.heal(heal_amount)
|
||||
# Show floating text with item graphic and heal amount
|
||||
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
|
||||
_show_floating_text(player, "+" + str(int(actual_heal)) + " hp", Color.GREEN, 0.5, 0.5, items_texture, 20, 14, (8 * 20) + 13)
|
||||
_show_floating_text(player, "+" + str(int(actual_heal)) + " HP", Color.GREEN, 0.5, 0.5, items_texture, 20, 14, (8 * 20) + 13)
|
||||
|
||||
self.visible = false
|
||||
|
||||
# Wait for sound to finish before removing
|
||||
if sfx_potion_collect and sfx_potion_collect.playing:
|
||||
await sfx_potion_collect.finished
|
||||
if sfx_banana_collect and sfx_banana_collect.playing:
|
||||
await sfx_banana_collect.finished
|
||||
queue_free()
|
||||
LootType.KEY:
|
||||
if sfx_key_collect:
|
||||
@@ -410,7 +433,7 @@ func _process_pickup_on_server(player: Node):
|
||||
player.add_key(1)
|
||||
# Show floating text with item graphic and text
|
||||
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
|
||||
_show_floating_text(player, "+1 key", Color.YELLOW, 0.5, 0.5, items_texture, 20, 14, (13 * 20) + 10)
|
||||
_show_floating_text(player, "+1 KEY", Color.YELLOW, 0.5, 0.5, items_texture, 20, 14, (13 * 20) + 10)
|
||||
|
||||
self.visible = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user