34 lines
944 B
GDScript
34 lines
944 B
GDScript
extends Node2D
|
|
class_name Star
|
|
# Parametry ustawiane w Inspektorze (łatwe do edycji!)
|
|
@export var radius: float = 300.0 # Promień okręgu
|
|
@export var color: Color = Color.GRAY
|
|
@export var thickness: float = 0.5 # Grubość linii konturu
|
|
@export var segments: int = 64
|
|
@onready var label = $Label
|
|
@export var star_name: String = ""
|
|
@export var planet_count: int = 0
|
|
var planets: Array = []
|
|
var texture: Texture2D
|
|
|
|
func _ready():
|
|
#print("Gwiazda %s z %d planetami" % [star_name, planet_count])
|
|
label.text = star_name
|
|
|
|
# Stała do rysowania pełnego okręgu
|
|
const TAU = 6.2831853 # 2 * PI
|
|
|
|
# Funkcja _draw() jest automatycznie wywoływana przez Godot, aby narysować węzeł
|
|
func _draw():
|
|
# draw_arc() rysuje kontur okręgu/łuku w Godot 4.x
|
|
# Argumenty: centrum, promień, kąt początkowy (0), kąt końcowy (TAU), liczba segmentów, kolor, grubość
|
|
draw_arc(
|
|
Vector2.ZERO,
|
|
radius,
|
|
0.0,
|
|
TAU,
|
|
segments,
|
|
color,
|
|
thickness
|
|
)
|