Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node2D
- onready var W_LIM = int($BackgroundPanel.rect_size.x)
- onready var H_LIM = int($BackgroundPanel.rect_size.y)
- onready var diagram
- onready var points = []
- func _ready():
- $TestToolNode.connect("map_generation_signal", self, "map_generation")
- func map_generation(points_cardinal, relax_cardinal):
- #DIAGRAM GENERATION
- var generator = Voronoi.new()
- for i in range(points_cardinal):
- point_generation()
- generator.set_points(points)
- generator.set_boundaries(Rect2(Vector2.ZERO, $BackgroundPanel.rect_size))
- generator.relax_points(relax_cardinal)
- diagram = generator.generate_diagram()
- update()
- #CALL TO MAP DRAWING
- draw_map()
- func draw_map():
- var background_scene = load("res://Scenes/TestBackgroundPanelScene.tscn")
- background_scene = background_scene.instance()
- background_scene.set_name("background_scene")
- self.add_child(background_scene)
- func point_generation():
- randomize()
- var rand_v = Vector2(randi()%W_LIM, randi()%H_LIM)
- points.append(rand_v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement