Added new HUD for bed timer

This commit is contained in:
akshay 2022-08-21 10:16:24 -04:00
parent 2bd6bc1c4e
commit fc58d4590f
11 changed files with 190 additions and 17 deletions

BIN
assets/UI/Icon_Stomach.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Icon_Stomach.png-ef46cca6dfcb43524b88fb3b81c668c9.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/UI/Icon_Stomach.png"
dest_files=[ "res://.import/Icon_Stomach.png-ef46cca6dfcb43524b88fb3b81c668c9.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=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/Meter_Completion.png-784a759a14eb89b22a4a7dcdbcc5f68b.s3tc.stex"
path.etc="res://.import/Meter_Completion.png-784a759a14eb89b22a4a7dcdbcc5f68b.etc.stex"
metadata={
"imported_formats": [ "s3tc", "etc" ],
"vram_texture": true
}
[deps]
source_file="res://assets/UI/Meter_Completion.png"
dest_files=[ "res://.import/Meter_Completion.png-784a759a14eb89b22a4a7dcdbcc5f68b.s3tc.stex", "res://.import/Meter_Completion.png-784a759a14eb89b22a4a7dcdbcc5f68b.etc.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=1
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=false
svg/scale=1.0

BIN
assets/UI/Timers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Timers.png-f1d89b18b8787e509a7ff5d60f99da61.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/UI/Timers.png"
dest_files=[ "res://.import/Timers.png-f1d89b18b8787e509a7ff5d60f99da61.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=true
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

View File

@ -1,22 +1,22 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://scripts/game_manager.gd" type="Script" id=1]
[ext_resource path="res://assets/UI/Menu_Recipes.png" type="Texture" id=2]
[ext_resource path="res://assets/tutorial/machine_repair.png" type="Texture" id=3]
[ext_resource path="res://assets/Fonts/AlphaProta-Wy7VE.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://assets/UI/Timers.png" type="Texture" id=5]
[sub_resource type="DynamicFont" id=2]
size = 50
font_data = ExtResource( 4 )
[sub_resource type="DynamicFont" id=1]
size = 75
size = 55
font_data = ExtResource( 4 )
[sub_resource type="StyleBoxFlat" id=3]
bg_color = Color( 0, 0.282353, 0.721569, 1 )
border_color = Color( 0, 0, 0, 1 )
border_blend = true
[sub_resource type="DynamicFont" id=3]
size = 34
font_data = ExtResource( 4 )
[node name="game_manager" type="CanvasLayer" groups=["game_manager"]]
pause_mode = 2
@ -99,12 +99,21 @@ text = "MAIN MENU"
icon_align = 1
expand_icon = true
[node name="day_timer_text" type="Label" parent="UI"]
[node name="HUD" type="TextureRect" parent="UI"]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -747.0
margin_top = -8.0
margin_bottom = 137.0
texture = ExtResource( 5 )
[node name="day_timer_text" type="Label" parent="UI/HUD"]
unique_name_in_owner = true
anchor_left = 1.0
anchor_right = 1.0
margin_left = -520.0
margin_bottom = 51.0
margin_left = -198.0
margin_top = 8.0
margin_bottom = 84.0
grow_horizontal = 0
rect_pivot_offset = Vector2( 116.901, -0.362253 )
custom_colors/font_color = Color( 0.0235294, 0.792157, 0, 1 )
@ -113,9 +122,30 @@ custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_offset_x = -2
custom_constants/shadow_offset_y = 2
custom_fonts/font = SubResource( 1 )
custom_styles/normal = SubResource( 3 )
text = "Time Left: 00:20"
align = 2
text = "00:20"
align = 1
valign = 1
uppercase = true
[node name="current_coins_text" type="Label" parent="UI/HUD"]
unique_name_in_owner = true
anchor_left = 1.0
anchor_right = 1.0
margin_left = -94.0
margin_top = 95.0
margin_right = -20.0
margin_bottom = 130.0
grow_horizontal = 0
rect_pivot_offset = Vector2( 116.901, -0.362253 )
custom_colors/font_color = Color( 0.0235294, 0.792157, 0, 1 )
custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_offset_x = -2
custom_constants/shadow_offset_y = 2
custom_fonts/font = SubResource( 3 )
text = "0"
align = 1
valign = 1
uppercase = true
[node name="day_timer" type="Timer" parent="."]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://scenes/coin_machine.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/item_holder.tscn" type="PackedScene" id=2]
@ -7,6 +7,30 @@
[ext_resource path="res://scenes/status_light.tscn" type="PackedScene" id=5]
[ext_resource path="res://item_types/gem.tres" type="Resource" id=6]
[ext_resource path="res://item_types/ore.tres" type="Resource" id=7]
[ext_resource path="res://assets/UI/Meter_Completion.png" type="Texture" id=8]
[sub_resource type="Shader" id=1]
code = "shader_type canvas_item; //2D shader
render_mode unshaded, blend_disabled; // no bells and wistles
uniform sampler2D palette; //Uses palletes with colors in rows
uniform float palette_count = 1.0; //Tells the shader how many palettes you have
uniform float palette_index = 0.0; //Telss the shader which palette to choose
void fragment(){
float increment = 1.0/palette_count; //Value for getting palette index
float y = increment * palette_index + increment * 0.5; // + safety measure for floating point imprecision
vec4 color = texture(TEXTURE, UV); //Original graysscale color used as collumn index
vec4 new_color = texture(palette, vec2(color.r, y)); //get color from palette texture
float a = step(0.00392, color.a); //check if transparent color is less than 1/255 for backgrounds
new_color.a *= a; //if BG is transparent, then alpha is multiplied by 0
COLOR = new_color; //set new color from palette
}"
[sub_resource type="ShaderMaterial" id=2]
shader = SubResource( 1 )
shader_param/palette_count = 1.0
shader_param/palette_index = 0.0
[node name="item_generator" type="Spatial"]
transform = Transform( 1, 0, 3.57628e-07, 0, 1, 0, -3.57628e-07, 0, 1, 0.330428, 0, -8.57503 )
@ -47,6 +71,12 @@ visible = false
modulate = Color( 0, 0, 0, 1 )
text = "Progress: 20%"
[node name="Sprite3D" type="Sprite3D" parent="."]
transform = Transform( 0.132773, 0, -1.72258e-08, 0, 0.132773, 0, -1.72258e-08, 0, 0.18094, -0.0166484, 2.48385, 2.79593 )
material_override = SubResource( 2 )
billboard = 1
texture = ExtResource( 8 )
[connection signal="coin_requirement_met" from="coin_machine" to="." method="_on_coin_machine_coin_requirement_met"]
[connection signal="timeout" from="gen_timer" to="." method="_on_gen_timer_timeout"]
[connection signal="item_dump_completed" from="item_dump" to="." method="_on_item_dump_item_dump_completed"]

View File

@ -6,6 +6,7 @@ export var time_per_day : float = 600.0
onready var player = get_tree().get_nodes_in_group("player")[0]
onready var day_timer = $"%day_timer"
onready var day_timer_text = $"%day_timer_text"
onready var current_coins_text = $"%current_coins_text"
onready var pause_menu = $"%pause_menu"
func _ready():
@ -17,7 +18,8 @@ func _process(delta):
var time_left : int = day_timer.time_left
var minutes : int = time_left / 60
var seconds : int = time_left % 60
day_timer_text.text = "Time Left: %0*d:%0*d" % [2, minutes, 2, seconds]
day_timer_text.text = "%0*d:%0*d" % [2, minutes, 2, seconds]
current_coins_text.text = "%d" % player.get_item_from_inventory("coins")
func _unhandled_input(event):
if event.is_action_pressed("pause_game"):

View File

@ -69,11 +69,15 @@ func consume_food(item : Resource):
set_health(MAX_HEALTH)
print("player: Hunger Satisfied! Ate %s" % item.name)
func can_afford(item_name, item_amount):
assert(item_amount > 0)
func get_item_from_inventory(var item_name : String):
var current_amount : int = 0
if(inventory.has(item_name)):
current_amount = inventory[item_name]
return current_amount
func can_afford(item_name, item_amount):
assert(item_amount > 0)
var current_amount : int = get_item_from_inventory(item_name)
return current_amount >= item_amount
func modify_inventory(item_name, item_amount):

View File

@ -15,5 +15,5 @@ void fragment() {
float angle = atan2((UV.y - 0.5) , (UV.x - 0.5));
float alpha = step(percent * 3.14159 * 2.25, angle + 3.14159);
vec4 color = texture(TEXTURE, UV);
COLOR = vec4(color.rgb, color.a * alpha);
COLOR = vec4(color.rgb, 1.0);
}