pretty happy with hud minimap
This commit is contained in:
@@ -6,6 +6,16 @@ extends Control
|
||||
## SETTINGS
|
||||
const MINIMAP_POINT_RADIUS :float = 10.0
|
||||
const MINIMAP_DISPLAY_RADIUS : float = 200.0
|
||||
const MINIMAP_MAX_OPACITY : float = .75
|
||||
const ERASE_BUFFER_TIME = -10.0
|
||||
const MAX_PRIORITY_SIZE = 4
|
||||
|
||||
var draw_delta_time
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
position = hud.viewportCenter
|
||||
draw_delta_time = delta #this workaround sucks, fix it later
|
||||
queue_redraw()
|
||||
|
||||
func _draw() -> void:
|
||||
update_minimap()
|
||||
@@ -16,14 +26,26 @@ func update_minimap():
|
||||
|
||||
for key in minimap_points:
|
||||
var point = minimap_points[key]
|
||||
var player_pos_h = Vector2(player.global_position.x,player.global_position.z)
|
||||
var point_pos_h = Vector2(point["position"].x,point["position"].z)
|
||||
var h_direction = (point_pos_h - player_pos_h).normalized()
|
||||
var v_direction = point["position"].y - player.global_position.y
|
||||
|
||||
|
||||
#var desired_rotation = object.global_transform.looking_at(target_positon,Vector3.UP).basis.get_euler()
|
||||
|
||||
#var point_pos =
|
||||
|
||||
draw_circle(point_pos,MINIMAP_POINT_RADIUS,point["color"],true)
|
||||
if point["timer"] > 0:
|
||||
point["timer"] -= draw_delta_time
|
||||
var player_pos_h = Vector2(player.global_position.x,player.global_position.z)
|
||||
var point_pos_h = Vector2(point["position"].x,point["position"].z)
|
||||
var h_direction = player.global_transform.looking_at(point["position"],Vector3.UP).basis.get_euler().y
|
||||
|
||||
var alpha_fade = clamp(MINIMAP_MAX_OPACITY * clamp(point["timer"],0,1),0,MINIMAP_MAX_OPACITY)
|
||||
var color_modified = Color(point["color"].r,point["color"].g,point["color"].b,alpha_fade)
|
||||
|
||||
var offset = player.global_rotation.y - (TAU * .25)
|
||||
|
||||
var x = MINIMAP_DISPLAY_RADIUS * cos(-h_direction + offset)
|
||||
var y = MINIMAP_DISPLAY_RADIUS * sin(-h_direction + offset)
|
||||
var point_pos = Vector2(x,y)
|
||||
|
||||
var priority_clamped = clamp(point["priority"],1,MAX_PRIORITY_SIZE)
|
||||
|
||||
draw_circle(point_pos,MINIMAP_POINT_RADIUS * priority_clamped,color_modified,true)
|
||||
else:
|
||||
if point["timer"] > ERASE_BUFFER_TIME:
|
||||
point["timer"] -= draw_delta_time
|
||||
else:
|
||||
minimap_points.erase(key)
|
||||
|
||||
Reference in New Issue
Block a user