major rework on pickups, hud now shows the number and icon of pickup

This commit is contained in:
derek
2025-01-16 17:04:13 -06:00
parent ad89e9813c
commit 5c6f010fdc
30 changed files with 1134 additions and 59 deletions

View File

@@ -26,6 +26,7 @@ var crosshair_target
@onready var money: Label = $Money
@onready var crosshair: TextureRect = $Crosshair
@onready var crosshair_center: TextureRect = $CrosshairCenter
@onready var pickup_item_indicator = preload("res://assets/pickup_item_indicator.tscn")
const FULL_WHITE = Color(1, 1, 1, 1)
const TRANSPARENT = Color(1, 1, 1, 0)
@@ -36,6 +37,9 @@ const GREEN_COLOR = Color(0, 0.608, 0.172)
const STAM_BAR_MAX_OPACITY = 1.0
const CROSSHAIR_SIZE = Vector2(40,40)
var pickup_notifs = []
var can_spawn = true
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Get Viewport size
@@ -62,6 +66,7 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
player = level_control.player
if player != null:
# Crosshair
crosshair_target = lerp(crosshair_target,CROSSHAIR_SIZE,delta * 5)
@@ -156,6 +161,9 @@ func _process(delta: float) -> void:
## FADE ELEMENTS IN AND OUT
fade_in_out(current_stam_bar,STAM_BAR_MAX_OPACITY,stam_bar_visible,5,delta)
## SPAWN NOTIFICATIONS
spawn_notifs()
func crosshair_size_change():
crosshair_target += Vector2(20,20)
@@ -184,6 +192,23 @@ func fade_in_out(element,MAX_OPACITY,visible,speed,delta):
else:
element.modulate = lerp(element_color, Color(element_color.r,element_color.g,element_color.b,0),(delta * speed)/Engine.time_scale)
func pick_up_notif(type,ammo_type,value):
var pickup_notif = pickup_item_indicator.instantiate()
pickup_notif.pickup_type = type
pickup_notif.ammo_type = ammo_type
pickup_notif.value = value
pickup_notif.position = money.position + Vector2(150,-50)
pickup_notif.scale = Vector2(1,1)
pickup_notifs.append(pickup_notif)
func spawn_notifs():
if pickup_notifs.size() > 0 and can_spawn:
can_spawn = false
var msg = pickup_notifs.pop_front()
add_child(msg)
await get_tree().create_timer(.2).timeout
can_spawn = true
func player_hit():
pass
#self.position += wiggle_element(25)