Merge branch 'main' of https://git.mrdanielsnider.com/snider/project-dung
This commit is contained in:
commit
e80cd37534
@ -40,10 +40,13 @@ func change_state(new_state):
|
||||
state = new_state
|
||||
|
||||
func _process(delta):
|
||||
if health > 0:
|
||||
var hunger_timer = $"%hunger_timer"
|
||||
var stomach = $"%stomachs".get_child(health - 1)
|
||||
stomach.material.set_shader_param("percent", 1.0 - hunger_timer.time_left / hunger_timer.wait_time)
|
||||
var hunger_timer = $"%hunger_timer"
|
||||
for i in $"%stomachs".get_child_count():
|
||||
var stomach = $"%stomachs".get_child(i)
|
||||
if i == health - 1:
|
||||
stomach.material.set_shader_param("percent", 1.0 - hunger_timer.time_left / hunger_timer.wait_time)
|
||||
else:
|
||||
stomach.material.set_shader_param("percent", 0.0)
|
||||
|
||||
func _physics_process(delta):
|
||||
state.physics_process(delta)
|
||||
@ -53,6 +56,8 @@ func _on_hunger_timer_timeout():
|
||||
print("player: lost health to hunger tick")
|
||||
|
||||
func set_health(new_value):
|
||||
var hunger_timer = $"%hunger_timer"
|
||||
hunger_timer.start()
|
||||
health = min(new_value, MAX_HEALTH)
|
||||
for child in $"%stomachs".get_children():
|
||||
child.visible = child.get_index() < health
|
||||
|
Loading…
x
Reference in New Issue
Block a user