* animate slime faster

* show loot text above head much closer to head
This commit is contained in:
2026-01-11 04:32:42 +01:00
parent a43a17ed10
commit 464f499b36
7 changed files with 160 additions and 80 deletions

View File

@@ -530,21 +530,21 @@ func _open_chest(by_player: Node = null):
by_player.heal(heal_amount)
# Show pickup notification with apple graphic
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
_show_item_pickup_notification(by_player, "+" + str(int(heal_amount)) + " HP", selected_loot.color, items_texture, 20, 14, (8 * 20) + 11)
_show_item_pickup_notification(by_player, "+" + str(int(heal_amount)) + " HP", selected_loot.color, items_texture, 20, 14, (8 * 20) + 10)
"banana":
var heal_amount = 20.0
if by_player.has_method("heal"):
by_player.heal(heal_amount)
# Show pickup notification with banana graphic
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
_show_item_pickup_notification(by_player, "+" + str(int(heal_amount)) + " HP", selected_loot.color, items_texture, 20, 14, (8 * 20) + 12)
_show_item_pickup_notification(by_player, "+" + str(int(heal_amount)) + " HP", selected_loot.color, items_texture, 20, 14, (8 * 20) + 11)
"cherry":
var heal_amount = 20.0
if by_player.has_method("heal"):
by_player.heal(heal_amount)
# Show pickup notification with cherry graphic
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
_show_item_pickup_notification(by_player, "+" + str(int(heal_amount)) + " HP", selected_loot.color, items_texture, 20, 14, (8 * 20) + 13)
_show_item_pickup_notification(by_player, "+" + str(int(heal_amount)) + " HP", selected_loot.color, items_texture, 20, 14, (8 * 20) + 12)
"key":
if by_player.has_method("add_key"):
by_player.add_key(1)
@@ -562,7 +562,8 @@ func _open_chest(by_player: Node = null):
# Sync chest opening visual to all clients (item already given on server)
if multiplayer.has_multiplayer_peer():
_sync_chest_open.rpc(selected_loot.type if by_player else "coin")
var player_peer_id = by_player.get_multiplayer_authority() if by_player else 0
_sync_chest_open.rpc(selected_loot.type if by_player else "coin", player_peer_id)
@rpc("any_peer", "reliable")
func _request_chest_open(player_peer_id: int):
@@ -593,7 +594,7 @@ func _request_chest_open(player_peer_id: int):
_open_chest(player)
@rpc("any_peer", "reliable")
func _sync_chest_open(_loot_type_str: String = "coin"):
func _sync_chest_open(loot_type_str: String = "coin", player_peer_id: int = 0):
# Sync chest opening to all clients (only visual - item already given on server)
if not is_chest_opened and sprite and chest_opened_frame >= 0:
is_chest_opened = true
@@ -602,6 +603,37 @@ func _sync_chest_open(_loot_type_str: String = "coin"):
# Play chest open sound on clients
if has_node("SfxChestOpen"):
$SfxChestOpen.play()
# Show pickup notification on client side
if player_peer_id > 0:
var players = get_tree().get_nodes_in_group("player")
var player = null
for p in players:
if p.get_multiplayer_authority() == player_peer_id:
player = p
break
if player and is_instance_valid(player):
# Show notification based on loot type (same as server)
match loot_type_str:
"coin":
var coin_texture = load("res://assets/gfx/pickups/gold_coin.png")
_show_item_pickup_notification(player, "+1 COIN", Color(1.0, 0.84, 0.0), coin_texture, 6, 1, 0)
"apple":
var heal_amount = 20.0
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
_show_item_pickup_notification(player, "+" + str(int(heal_amount)) + " HP", Color.GREEN, items_texture, 20, 14, (8 * 20) + 10)
"banana":
var heal_amount = 20.0
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
_show_item_pickup_notification(player, "+" + str(int(heal_amount)) + " HP", Color.YELLOW, items_texture, 20, 14, (8 * 20) + 11)
"cherry":
var heal_amount = 20.0
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
_show_item_pickup_notification(player, "+" + str(int(heal_amount)) + " HP", Color.RED, items_texture, 20, 14, (8 * 20) + 12)
"key":
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
_show_item_pickup_notification(player, "+1 KEY", Color.YELLOW, items_texture, 20, 14, (13 * 20) + 10)
func _show_item_pickup_notification(player: Node, text: String, text_color: Color, item_texture: Texture2D = null, sprite_hframes: int = 1, sprite_vframes: int = 1, sprite_frame: int = 0):
# Show item graphic and text above player's head for 0.5s, then fade out over 0.5s
@@ -611,7 +643,8 @@ func _show_item_pickup_notification(player: Node, text: String, text_color: Colo
var parent = player.get_parent()
if parent:
parent.add_child(floating_text)
floating_text.global_position = player.global_position + Vector2(0, -20)
# Position at player.position.y - 20 (just above head)
floating_text.global_position = Vector2(player.global_position.x, player.global_position.y - 20)
floating_text.setup(text, text_color, 0.5, 0.5, item_texture, sprite_hframes, sprite_vframes, sprite_frame) # Show for 0.5s, fade over 0.5s
func play_destroy_sound():