major rework on pickups, hud now shows the number and icon of pickup
This commit is contained in:
66
scripts/pickup_item_indicator.gd
Normal file
66
scripts/pickup_item_indicator.gd
Normal file
@@ -0,0 +1,66 @@
|
||||
extends Control
|
||||
|
||||
@onready var image: TextureRect = $image
|
||||
@onready var label: Label = $image/Label
|
||||
|
||||
|
||||
## ITEM TEXTURES
|
||||
#AMMO
|
||||
const LIGHT_AMMO = preload("res://assets/Textures/ObjectTextures/light_ammo.png")
|
||||
const ROCKET = preload("res://assets/Textures/ObjectTextures/rocket.png")
|
||||
|
||||
const MONEY = preload("res://assets/Textures/ObjectTextures/money.png")
|
||||
const HEALTH = preload("res://assets/Textures/ObjectTextures/health.png")
|
||||
const STAMINA = preload("res://assets/Textures/ObjectTextures/stamina.png")
|
||||
|
||||
var pickup_type
|
||||
var ammo_type
|
||||
var value
|
||||
|
||||
var random_point
|
||||
var alpha_amt : float = 1.0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
random_point = get_random_point()
|
||||
|
||||
match pickup_type:
|
||||
0:
|
||||
match ammo_type:
|
||||
0:
|
||||
image.texture = LIGHT_AMMO
|
||||
1:
|
||||
image.texture = LIGHT_AMMO #medium
|
||||
2:
|
||||
image.texture = LIGHT_AMMO #heavy
|
||||
3:
|
||||
image.texture = LIGHT_AMMO #shotgun
|
||||
4:
|
||||
image.texture = ROCKET
|
||||
1:
|
||||
image.texture = STAMINA
|
||||
2:
|
||||
image.texture = HEALTH
|
||||
3:
|
||||
image.texture = MONEY
|
||||
|
||||
if pickup_type == 3:
|
||||
label.text = str("$",value)
|
||||
else:
|
||||
label.text = str(value)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
alpha_amt = lerp(alpha_amt, 0.0,delta * 1)
|
||||
modulate = Color(1, 1, 1, alpha_amt)
|
||||
position += random_point * delta * 2
|
||||
scale -= Vector2(.2,.2) * delta
|
||||
if alpha_amt <= .01:
|
||||
queue_free()
|
||||
|
||||
func get_random_point():
|
||||
var x_pos = randf_range(-50,50)
|
||||
var y_pos = randf_range(-250,-300)
|
||||
|
||||
return Vector2(x_pos,y_pos)
|
||||
Reference in New Issue
Block a user