ld-39-jam/Minimap.gd

36 lines
809 B
GDScript3
Raw Normal View History

extends Control
var offset_pos = Vector2(32, 32)
onready var render_target = get_node("Viewport")
onready var tex_frame = get_node("TextureFrame")
var entities = Array()
func _ready():
set_fixed_process(true)
tex_frame.set_texture(render_target.get_render_target_texture())
render_target.init(entities)
set_pos(Vector2(32, 32))
func register_entity(e):
entities.append(weakref(e))
render_target.init(entities)
func collect_entities():
var to_remove
for i in range(0, entities.size()):
if not entities[i].get_ref():
if to_remove == null:
to_remove = Array()
to_remove.push_back(i)
func _fixed_process(delta):
collect_entities()
func _draw():
if entities.size() > 0:
render_target.render_target_clear()
2017-07-30 19:11:15 +01:00
render_target.it_changed()
# gc the shit out of em
collect_entities()