Basic HUD: health bar and ewapon/ammo info (mockup-y, not functional)

godot4-port
unfa 2020-09-28 22:21:26 +02:00
parent 69194327e1
commit e19f7733c3
5 changed files with 379 additions and 1 deletions

160
Assets/HUD/HUD.tscn Normal file
View File

@ -0,0 +1,160 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Assets/HUD/HeathBarEmpty.svg" type="Texture" id=1]
[ext_resource path="res://Assets/HUD/HeathBarProgress.svg" type="Texture" id=2]
[ext_resource path="res://Assets/HUD/HeathBarUnder.svg" type="Texture" id=3]
[sub_resource type="VisualShaderNodeColorConstant" id=1]
constant = Color( 0, 0, 0, 0.176471 )
[sub_resource type="VisualShader" id=2]
code = "shader_type canvas_item;
void vertex() {
// Output:0
}
void fragment() {
// Color:2
vec3 n_out2p0 = vec3(0.000000, 0.000000, 0.000000);
float n_out2p1 = 0.176471;
// Output:0
COLOR.rgb = n_out2p0;
COLOR.a = n_out2p1;
}
void light() {
// Output:0
}
"
graph_offset = Vector2( 0, -7 )
mode = 1
flags/light_only = false
nodes/fragment/0/position = Vector2( 840, 80 )
nodes/fragment/2/node = SubResource( 1 )
nodes/fragment/2/position = Vector2( 300, 60 )
nodes/fragment/connections = PoolIntArray( 2, 0, 0, 0, 2, 1, 0, 1 )
[sub_resource type="ShaderMaterial" id=3]
shader = SubResource( 2 )
[node name="HUD" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 0.610558
margin_right = 0.610596
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Health" type="MarginContainer" parent="."]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 32.0
margin_top = -50.0
margin_right = 148.0
margin_bottom = -32.0
grow_horizontal = 2
grow_vertical = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HealthBar" type="TextureProgress" parent="Health"]
margin_right = 150.0
margin_bottom = 50.0
rect_min_size = Vector2( 150, 50 )
max_value = 150.0
value = 100.0
texture_under = ExtResource( 3 )
texture_over = ExtResource( 1 )
texture_progress = ExtResource( 2 )
tint_under = Color( 0, 0, 0, 0.0980392 )
tint_progress = Color( 0, 1, 1.2, 0.75 )
nine_patch_stretch = true
stretch_margin_left = 25
stretch_margin_top = 25
stretch_margin_right = 25
stretch_margin_bottom = 25
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HealthText" type="Label" parent="Health/HealthBar"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -80.0
margin_top = -24.5
margin_right = 80.0
margin_bottom = 24.5
text = "150"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Weapon" type="MarginContainer" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -148.0
margin_top = -50.0
margin_right = -32.0
margin_bottom = -32.0
grow_horizontal = 2
grow_vertical = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="NinePatchRect" type="NinePatchRect" parent="Weapon"]
material = SubResource( 3 )
margin_right = 116.0
margin_bottom = 64.0
texture = ExtResource( 3 )
patch_margin_left = 32
patch_margin_top = 32
patch_margin_right = 32
patch_margin_bottom = 32
axis_stretch_horizontal = 2
axis_stretch_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Weapon"]
material = SubResource( 3 )
margin_right = 116.0
margin_bottom = 64.0
grow_horizontal = 2
grow_vertical = 2
alignment = 1
[node name="RoundsClips" type="Label" parent="Weapon/VBoxContainer"]
margin_top = 16.0
margin_right = 116.0
margin_bottom = 30.0
text = "12 / 6"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="WeaponName" type="Label" parent="Weapon/VBoxContainer"]
margin_top = 34.0
margin_right = 116.0
margin_bottom = 48.0
text = "Handgun"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="96"
height="96"
viewBox="0 0 25.399999 25.400001"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="HeathBarEmpty.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#545454"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="85.752294"
inkscape:cy="55.305259"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true"
units="px"
inkscape:snap-global="false"
inkscape:window-width="1920"
inkscape:window-height="1006"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid833"
empspacing="32" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:1;fill:none;stroke-width:0.79375;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers fill stroke;stroke:#ffffff"
id="rect835"
width="23.847076"
height="23.847076"
x="0.77646106"
y="0.77646106"
rx="3.0779727"
ry="3.0779727" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="96"
height="96"
viewBox="0 0 25.399999 25.400001"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="HeathBarProgress.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#545454"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="85.752294"
inkscape:cy="55.305259"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true"
units="px"
inkscape:snap-global="false"
inkscape:window-width="1920"
inkscape:window-height="1051"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid833"
empspacing="32" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:1;fill:#ffffff;stroke-width:0.79375;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers fill stroke;stroke:none;fill-opacity:1"
id="rect835"
width="23.847076"
height="23.847076"
x="0.77646106"
y="0.77646106"
rx="3.0779727"
ry="3.0779727" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="96"
height="96"
viewBox="0 0 25.399999 25.400001"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="HeathBarUnder.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#545454"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="85.752294"
inkscape:cy="55.305259"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true"
units="px"
inkscape:snap-global="false"
inkscape:window-width="1920"
inkscape:window-height="1051"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid833"
empspacing="32" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:1;fill:#ffffff;stroke-width:0.79375;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers fill stroke;stroke:none"
id="rect835"
width="23.847076"
height="23.847076"
x="0.77646106"
y="0.77646106"
rx="3.0779727"
ry="3.0779727" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,5 +1,6 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Assets/HUD/HUD.tscn" type="PackedScene" id=1]
[ext_resource path="res://Game.gd" type="Script" id=2]
[ext_resource path="res://Level.tscn" type="PackedScene" id=3]
@ -38,6 +39,8 @@ glow_bicubic_upscale = true
script = ExtResource( 2 )
SERVER_IP = "127.0.0.1"
[node name="HUD" parent="." instance=ExtResource( 1 )]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 2 )
@ -48,6 +51,8 @@ environment = SubResource( 2 )
[node name="MenuContainer" type="CenterContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -0.943848
margin_right = -0.943848
__meta__ = {
"_edit_use_anchors_": false
}