2025-11-12 13:28:57 +03:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
|
|
@export_group("Visual Settings")
|
|
|
|
|
@export var Star_Count: int = 5000: set = set_star_count
|
2025-11-15 08:22:49 +03:00
|
|
|
@export var Background_Image_Size: Vector2 = Vector2(4096, 4096):
|
|
|
|
|
set = set_Background_Image_Size
|
2025-11-12 13:28:57 +03:00
|
|
|
@export var background_color: Color = Color.BLACK
|
|
|
|
|
|
2025-11-15 08:22:49 +03:00
|
|
|
#@export_group("Animation")
|
|
|
|
|
#@export var auto_rotate: bool = false
|
|
|
|
|
#@export var rotation_speed: float = 0.1
|
2025-11-12 13:28:57 +03:00
|
|
|
|
|
|
|
|
var rotation_angle: float = 0.0
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
queue_redraw()
|
|
|
|
|
|
|
|
|
|
func _draw():
|
|
|
|
|
draw_rect(Rect2(Vector2.ZERO, Background_Image_Size), background_color)
|
|
|
|
|
|
|
|
|
|
# Сохраняем текущее состояние трансформации
|
|
|
|
|
var transform = Transform2D().rotated(rotation_angle)
|
|
|
|
|
draw_set_transform_matrix(transform)
|
|
|
|
|
|
|
|
|
|
draw_galaxy()
|
|
|
|
|
|
|
|
|
|
func draw_galaxy():
|
|
|
|
|
for ind1 in range(Star_Count):
|
|
|
|
|
var star_coords = Vector2(randi_range(0, Background_Image_Size.x),
|
|
|
|
|
randi_range(0, Background_Image_Size.y))
|
2025-11-15 08:22:49 +03:00
|
|
|
#draw_star(star_coords)
|
2025-11-12 13:28:57 +03:00
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
|
if Engine.is_editor_hint():
|
|
|
|
|
queue_redraw()
|
|
|
|
|
|
2025-11-15 08:22:49 +03:00
|
|
|
#func draw_star(star_coords: Vector2):
|
|
|
|
|
#var rnd_seed = randi_range(0, STAR_COLOR_DISTRIBUTION[-1][0])
|
|
|
|
|
#for item:Array in STAR_COLOR_DISTRIBUTION:
|
|
|
|
|
#if rnd_seed <= item[0]:
|
|
|
|
|
#var star_color = Color.html(item[1])
|
|
|
|
|
#draw_circle(star_coords, 1, star_color)
|
|
|
|
|
|
2025-11-12 13:28:57 +03:00
|
|
|
|
|
|
|
|
#region Сеттеры для автоматического обновления
|
|
|
|
|
func set_Background_Image_Size(value: Vector2):
|
|
|
|
|
Background_Image_Size = value
|
|
|
|
|
queue_redraw()
|
|
|
|
|
|
|
|
|
|
func set_star_count(value: int):
|
|
|
|
|
Star_Count = value
|
|
|
|
|
queue_redraw()
|
|
|
|
|
|
|
|
|
|
#endregion
|