Star Parallax
This commit is contained in:
parent
2c2c7fa0b3
commit
a1e0c3f8a7
5 changed files with 31 additions and 13 deletions
|
|
@ -1,14 +1,18 @@
|
|||
extends Node2D
|
||||
extends Node
|
||||
|
||||
@export var star : PackedScene
|
||||
@export var stars_amount = 1000
|
||||
@export var compress_space_amount = 0.5
|
||||
|
||||
func _ready():
|
||||
var map_width_halved = get_tree().current_scene.map_width / 2
|
||||
var map_height_halved = get_tree().current_scene.map_height / 2
|
||||
var compress_multiplier = 1-compress_space_amount
|
||||
|
||||
var map_width_halved = get_tree().current_scene.map_width * compress_multiplier
|
||||
var map_height_halved = get_tree().current_scene.map_height * compress_multiplier
|
||||
for i in range(stars_amount):
|
||||
var star_inst = star.instantiate()
|
||||
var x = randi_range(-map_width_halved, map_width_halved)
|
||||
var y = randi_range(-map_height_halved, map_height_halved)
|
||||
add_child(star_inst)
|
||||
var distance = randi_range(0,get_child_count()-1)
|
||||
get_children()[distance].add_child(star_inst)
|
||||
star_inst.position = Vector2(x, y)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue