This commit is contained in:
MarcEricMartel 2023-01-15 14:14:58 -05:00
parent e472d6567f
commit e09681afec
9 changed files with 147 additions and 0 deletions

13
Bladder.gd Normal file
View File

@ -0,0 +1,13 @@
extends Sprite2D
var fill;
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
material.set("fill",clamp(fill, 0.0, 1.0))

BIN
Images/Bladder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

34
Images/Bladder.png.import Normal file
View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b25de1d0yyuji"
path="res://.godot/imported/Bladder.png-67828a0d166717b5269a348903393516.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Images/Bladder.png"
dest_files=["res://.godot/imported/Bladder.png-67828a0d166717b5269a348903393516.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
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

BIN
Images/BladderHollow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d2nqjxofehkum"
path="res://.godot/imported/BladderHollow.png-e4fd50cc80f9ae5a6291ebfabb73f55a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Images/BladderHollow.png"
dest_files=["res://.godot/imported/BladderHollow.png-e4fd50cc80f9ae5a6291ebfabb73f55a.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
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

13
bladder.gdshader Normal file
View File

@ -0,0 +1,13 @@
shader_type canvas_item;
uniform vec4 tex;
uniform float fill;
void fragment() {
if ((fill + 0.5) * 0.5 >= 1.0 - UV.y)
COLOR = vec4(0.1, 0.4, 0.4, 1.0);
COLOR.a = tex.a;
}

11
hud.gd Normal file
View File

@ -0,0 +1,11 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
$Bladder.fill = 0.3; # <-- value goes here!

9
hud.gdshader Normal file
View File

@ -0,0 +1,9 @@
shader_type canvas_item;
uniform float fill;
void fragment() {
if ((fill + 0.5) * 0.5 >= 1.0 - UV.y)
COLOR = vec4(0.1, 0.4, 0.4, texture(TEXTURE, UV).a);
else COLOR = texture(TEXTURE, UV);
}

33
hud.tscn Normal file
View File

@ -0,0 +1,33 @@
[gd_scene load_steps=7 format=3 uid="uid://3n1o2mbywp8w"]
[ext_resource type="Shader" path="res://hud.gdshader" id="1_0s6h4"]
[ext_resource type="Script" path="res://hud.gd" id="1_jkk58"]
[ext_resource type="Texture2D" uid="uid://b25de1d0yyuji" path="res://Images/Bladder.png" id="2_fa8jy"]
[ext_resource type="Script" path="res://Bladder.gd" id="3_tb31y"]
[ext_resource type="Texture2D" uid="uid://d2nqjxofehkum" path="res://Images/BladderHollow.png" id="4_lbxgy"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0gcor"]
shader = ExtResource("1_0s6h4")
shader_parameter/fill = 0.0
[node name="HUD" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 198.0
offset_top = 205.0
offset_right = 198.0
offset_bottom = 205.0
script = ExtResource("1_jkk58")
[node name="Bladder" type="Sprite2D" parent="."]
material = SubResource("ShaderMaterial_0gcor")
scale = Vector2(4, 4)
texture = ExtResource("2_fa8jy")
script = ExtResource("3_tb31y")
[node name="BladderHollow" type="Sprite2D" parent="."]
position = Vector2(-2, 0)
scale = Vector2(4, 4)
texture = ExtResource("4_lbxgy")