added enemy health bar and target with markers
This commit is contained in:
@@ -1,7 +1,25 @@
|
||||
extends Control
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
queue_redraw()
|
||||
|
||||
@onready var sub_viewport: SubViewport = $".."
|
||||
@onready var health_bar_sprite: Sprite3D = $"../.."
|
||||
|
||||
var center = Vector2.ZERO
|
||||
var current_health : float
|
||||
|
||||
const MARGIN = 20
|
||||
|
||||
func _ready() -> void:
|
||||
center = Vector2(sub_viewport.size.x/2,sub_viewport.size.y/2)
|
||||
|
||||
func _draw() -> void:
|
||||
draw_circle(Vector2.ZERO,0,Color(1,1,1,1),true,10,true)
|
||||
print("CHARACTER HEALTH : ")
|
||||
var health_percentage : float = health_bar_sprite.character.health/health_bar_sprite.character.start_health
|
||||
#background
|
||||
draw_line(Vector2(0,center.y),Vector2(sub_viewport.size.x,center.y),Color(.5,.5,.5,.75),MARGIN * 2,true)
|
||||
|
||||
#health
|
||||
for i in range(health_bar_sprite.character.health):
|
||||
var width = sub_viewport.size.x / health_bar_sprite.character.start_health
|
||||
var from = width * i + MARGIN/2
|
||||
var to = width * (i+1) - MARGIN/2
|
||||
draw_line(Vector2(from,center.y),Vector2(to,center.y),ColorSwatch.RED_COLOR,30,true)
|
||||
|
||||
Reference in New Issue
Block a user