Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Sprite2D
- var health = 100.0
- # 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):
- position = get_global_mouse_position()
- health_update()
- func health_update():
- health -= .1
- $ProgressBar.value = health
- if health < 20:
- $ProgressBar.get("theme_override_styles/fill").bg_color = Color.RED
- elif health < 50:
- $ProgressBar.get("theme_override_styles/fill").bg_color =Color.ORANGE
- elif health < 80:
- $ProgressBar.get("theme_override_styles/fill").bg_color = Color.YELLOW
- else:
- $ProgressBar.get("theme_override_styles/fill").bg_color = Color.GREEN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement