init
This commit is contained in:
BIN
gui/hud/gui-health.png
Normal file
BIN
gui/hud/gui-health.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 394 B |
40
gui/hud/gui-health.png.import
Normal file
40
gui/hud/gui-health.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://csf8yqiq5fs5n"
|
||||
path="res://.godot/imported/gui-health.png-d93a49566652243a8143d8e668d232ff.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://gui/hud/gui-health.png"
|
||||
dest_files=["res://.godot/imported/gui-health.png-d93a49566652243a8143d8e668d232ff.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
11
gui/hud/heart.gd
Normal file
11
gui/hud/heart.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
class_name HeartGUI extends Control
|
||||
|
||||
@onready var sprite: Sprite2D = $HeartSprite
|
||||
|
||||
var value: int = 2 :
|
||||
set(_value):
|
||||
value = _value
|
||||
update_sprite()
|
||||
|
||||
func update_sprite() -> void:
|
||||
sprite.frame = value
|
||||
1
gui/hud/heart.gd.uid
Normal file
1
gui/hud/heart.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bacc4v8q6cvlb
|
||||
17
gui/hud/heart.tscn
Normal file
17
gui/hud/heart.tscn
Normal file
@@ -0,0 +1,17 @@
|
||||
[gd_scene format=3 uid="uid://bpe1y2o6gsmlv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bacc4v8q6cvlb" path="res://gui/hud/heart.gd" id="1_5rmhy"]
|
||||
[ext_resource type="Texture2D" uid="uid://csf8yqiq5fs5n" path="res://gui/hud/gui-health.png" id="1_7gnmf"]
|
||||
|
||||
[node name="Heart" type="Control" unique_id=1010364190]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(9, 0)
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_5rmhy")
|
||||
|
||||
[node name="HeartSprite" type="Sprite2D" parent="." unique_id=424664538]
|
||||
texture = ExtResource("1_7gnmf")
|
||||
centered = false
|
||||
hframes = 7
|
||||
vframes = 2
|
||||
22
gui/hud/hud.gd
Normal file
22
gui/hud/hud.gd
Normal file
@@ -0,0 +1,22 @@
|
||||
extends CanvasLayer
|
||||
|
||||
var hearts: Array[HeartGUI] = []
|
||||
|
||||
func _ready() -> void:
|
||||
for child in $control/HFlowContainer.get_children():
|
||||
if child is HeartGUI:
|
||||
hearts.append(child)
|
||||
child.visible = false
|
||||
|
||||
func update_hp(hp: int, max_hp: int) -> void:
|
||||
update_max_hp(max_hp)
|
||||
for i in max_hp:
|
||||
update_heart(i, hp)
|
||||
|
||||
func update_heart(index: int, hp: int) -> void:
|
||||
hearts[index].value = clampi(hp - index * 2, 0, 2)
|
||||
|
||||
func update_max_hp(max_hp: int) -> void:
|
||||
var heart_count: int = roundi(max_hp * 0.5)
|
||||
for i in hearts.size():
|
||||
hearts[i].visible = i < heart_count
|
||||
1
gui/hud/hud.gd.uid
Normal file
1
gui/hud/hud.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvupqrfocd635
|
||||
94
gui/hud/hud.tscn
Normal file
94
gui/hud/hud.tscn
Normal file
@@ -0,0 +1,94 @@
|
||||
[gd_scene format=3 uid="uid://dwon5dsqxao56"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://csf8yqiq5fs5n" path="res://gui/hud/gui-health.png" id="1_4w87a"]
|
||||
[ext_resource type="Script" uid="uid://cvupqrfocd635" path="res://gui/hud/hud.gd" id="1_rllpj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bpe1y2o6gsmlv" path="res://gui/hud/heart.tscn" id="2_rllpj"]
|
||||
|
||||
[node name="hud" type="CanvasLayer" unique_id=256487066]
|
||||
layer = 2
|
||||
script = ExtResource("1_rllpj")
|
||||
|
||||
[node name="control" type="Control" parent="." unique_id=1112650233]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="health_sprite" type="Sprite2D" parent="control" unique_id=1001694164]
|
||||
position = Vector2(387, 9)
|
||||
texture = ExtResource("1_4w87a")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(30, 0, 33, 8)
|
||||
|
||||
[node name="HFlowContainer" type="HFlowContainer" parent="control" unique_id=1403418063]
|
||||
layout_mode = 0
|
||||
offset_left = 322.0
|
||||
offset_top = 17.0
|
||||
offset_right = 452.0
|
||||
offset_bottom = 50.0
|
||||
theme_override_constants/h_separation = 4
|
||||
theme_override_constants/v_separation = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Heart" parent="control/HFlowContainer" unique_id=1010364190 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart2" parent="control/HFlowContainer" unique_id=1093190859 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart3" parent="control/HFlowContainer" unique_id=2139127460 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart4" parent="control/HFlowContainer" unique_id=2098524055 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart5" parent="control/HFlowContainer" unique_id=784572064 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart6" parent="control/HFlowContainer" unique_id=1170384884 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart7" parent="control/HFlowContainer" unique_id=488907353 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart8" parent="control/HFlowContainer" unique_id=2092404839 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart9" parent="control/HFlowContainer" unique_id=642254142 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart10" parent="control/HFlowContainer" unique_id=1150287437 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart11" parent="control/HFlowContainer" unique_id=1332044652 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart12" parent="control/HFlowContainer" unique_id=1873062161 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart13" parent="control/HFlowContainer" unique_id=809306772 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart14" parent="control/HFlowContainer" unique_id=1383244089 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart15" parent="control/HFlowContainer" unique_id=749427884 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart16" parent="control/HFlowContainer" unique_id=1553915001 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart17" parent="control/HFlowContainer" unique_id=432065662 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart18" parent="control/HFlowContainer" unique_id=21663377 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart19" parent="control/HFlowContainer" unique_id=1650662833 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Heart20" parent="control/HFlowContainer" unique_id=705981093 instance=ExtResource("2_rllpj")]
|
||||
layout_mode = 2
|
||||
Reference in New Issue
Block a user