From ee5252292580d630ea28a4b092968066eb377562 Mon Sep 17 00:00:00 2001 From: Nitsud Yarg Date: Sat, 8 Jun 2024 09:15:29 -0700 Subject: [PATCH] Simple lifebar implemented. UI work still in progress. --- Main.tscn | 19 +++++++++++- assets/UI/Healthbar-Indicator.png | Bin 0 -> 174 bytes assets/UI/Healthbar-Indicator.png.import | 35 +++++++++++++++++++++++ assets/UI/Healthbar-Indicator.tres | 3 ++ assets/UI/Healthbar.png | Bin 0 -> 172 bytes assets/UI/Healthbar.png.import | 35 +++++++++++++++++++++++ src/UI/HealthBar.gd | 16 +++++++++++ src/playerC/Player-KinematicBody2D.gd | 3 ++ 8 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 assets/UI/Healthbar-Indicator.png create mode 100644 assets/UI/Healthbar-Indicator.png.import create mode 100644 assets/UI/Healthbar-Indicator.tres create mode 100644 assets/UI/Healthbar.png create mode 100644 assets/UI/Healthbar.png.import create mode 100644 src/UI/HealthBar.gd diff --git a/Main.tscn b/Main.tscn index 3408eb6..bcacac2 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=2] +[gd_scene load_steps=26 format=2] [ext_resource path="res://assets/Backgrounds/bgmuck.png" type="Texture" id=1] [ext_resource path="res://src/playerC/Player.tscn" type="PackedScene" id=2] @@ -9,6 +9,9 @@ [ext_resource path="res://src/enemyC/EnemyC.tscn" type="PackedScene" id=7] [ext_resource path="res://assets/Fonts/QuinqueFive.tres" type="DynamicFont" id=8] [ext_resource path="res://src/UI_Dialog.tscn" type="PackedScene" id=9] +[ext_resource path="res://assets/UI/Healthbar.png" type="Texture" id=10] +[ext_resource path="res://assets/UI/Healthbar-Indicator.png" type="Texture" id=11] +[ext_resource path="res://src/UI/HealthBar.gd" type="Script" id=12] [sub_resource type="ConvexPolygonShape2D" id=2] points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 ) @@ -230,3 +233,17 @@ margin_bottom = 53.0 custom_fonts/font = ExtResource( 8 ) text = "In a world where danger lurks in your plumbing. One thing decides to do another thing and we all determine it wasn't worth it. Hello World" autowrap = true + +[node name="CanvasLayer" type="CanvasLayer" parent="."] +layer = 2 + +[node name="HealthBar" type="TextureProgress" parent="CanvasLayer"] +margin_left = 2.0 +margin_top = 2.0 +margin_right = 104.0 +margin_bottom = 14.0 +value = 50.0 +texture_under = ExtResource( 10 ) +texture_progress = ExtResource( 11 ) +texture_progress_offset = Vector2( 1, 1 ) +script = ExtResource( 12 ) diff --git a/assets/UI/Healthbar-Indicator.png b/assets/UI/Healthbar-Indicator.png new file mode 100644 index 0000000000000000000000000000000000000000..071fb8774d12ebf0a6094f4cc332d7c114bcd19b GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^DL~A{!3HFqWPaBHDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheoCO|{#S9F5he4R}c>W5Ic4to)$B+p3x7T+HGAQsIIUuc7{NMMZ#S%vC z3v72R!d$*hJ)Qcd%0Kk$!*luUg6)n8JWR;~63quBSdJ-}{6BtV?wuzLC$yg43s$SX Q4m6Iz)78&qol`;+0H1_6pa1{> literal 0 HcmV?d00001 diff --git a/assets/UI/Healthbar-Indicator.png.import b/assets/UI/Healthbar-Indicator.png.import new file mode 100644 index 0000000..8f5cca8 --- /dev/null +++ b/assets/UI/Healthbar-Indicator.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Healthbar-Indicator.png-cbbde6797adcb3b0445dfd4f9ab1961a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/UI/Healthbar-Indicator.png" +dest_files=[ "res://.import/Healthbar-Indicator.png-cbbde6797adcb3b0445dfd4f9ab1961a.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/UI/Healthbar-Indicator.tres b/assets/UI/Healthbar-Indicator.tres new file mode 100644 index 0000000..e9f7a46 --- /dev/null +++ b/assets/UI/Healthbar-Indicator.tres @@ -0,0 +1,3 @@ +[gd_resource type="StreamTexture" format=2] + +[resource] diff --git a/assets/UI/Healthbar.png b/assets/UI/Healthbar.png new file mode 100644 index 0000000000000000000000000000000000000000..b1c74da44f0ffdbdff616ee6fb929d2ce6cf1fbb GIT binary patch literal 172 zcmeAS@N?(olHy`uVBq!ia0vp^X+X@w!3HEJY&a1Iq!^2X+?^QKos)S9a~60+7BevL9R^{>Jztoa zyO-Qqb9ssI#64=+M=yTnKPbU=${?Vv(THbC;sPG#R0)m44nHR`W=-NYXXD^sGqdj- P&@cv1S3j3^P6 void: + PlayerInfo.player_health = $Health_Component.health #var sound_effects = preload("res://src/playerC/resources/sound_effects.tres") @@ -40,6 +42,7 @@ func gotcha(damage): $Health_Component.take_damage(damage) if $Health_Component.health > 0: movement_state_machine.change_state($movement_state_machine/hurt) + PlayerInfo.player_health = $Health_Component.health yield( get_tree().create_timer(2 + $movement_state_machine/hurt.timeout_seconds), "timeout") $Hurtbox_Component.set_hurtbox(true)