initial and starry sky

This commit is contained in:
Kirill
2025-11-12 13:28:57 +03:00
commit 7c5867f606
12 changed files with 307 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
extends Node2D
@export var Parallax_2d: Parallax2D
@export var Node_2d: Node2D
var x_offset: int = 40
var y_offset: int = 40
var _random
func _ready() -> void:
_random = RandomNumberGenerator.new()
x_offset = _random_offset_x() * _random_sign()
y_offset = _random_offset_y() * _random_sign()
func _process(delta: float) -> void:
Parallax_2d.scroll_offset.x += x_offset * delta
Parallax_2d.scroll_offset.y += y_offset * delta
if _random.randi_range(0, 2096) == 0:
if _random_sign() == 1:
x_offset = _random_offset_x() * _random_sign()
else:
y_offset = _random_offset_y() * _random_sign()
func _random_offset_x() -> int:
return _random.randi_range(30, 50)
func _random_offset_y() -> int:
return _random.randi_range(5, 15)
func _random_sign() -> int:
if _random.randi_range(1, 2) == 1:
return 1
else:
return -1