godot_boids/examples/boid_2d/simple/example.gd
2024-08-19 16:53:54 +03:00

14 lines
385 B
GDScript

extends Node2D
func _ready() -> void:
for i in 100: spawnBoid()
func spawnBoid() -> void:
var boid: Boid = preload("../example_boid.tscn").instantiate()
var screensize := get_viewport_rect().size
boid.modulate = Color(randf(), randf(), randf(), 1)
boid.global_position = Vector2((randf_range(200, screensize.x - 200)), (randf_range(200, screensize.y - 200)))
add_child(boid)