Star parallax that looks so fucking good oh my god
This commit is contained in:
parent
8ce7c43009
commit
106880a421
3 changed files with 29 additions and 1 deletions
File diff suppressed because one or more lines are too long
|
|
@ -66,7 +66,7 @@ func _ready() -> void:
|
|||
$Player.rotation = spawn_points[global.stats.location].rotation
|
||||
|
||||
var i = 0
|
||||
while i < 512:
|
||||
while i < 1024 / 3:
|
||||
var star = star_scene.instantiate()
|
||||
star.position = Vector2(-99999999999999999, -9999999999999999999)
|
||||
|
||||
|
|
@ -74,6 +74,26 @@ func _ready() -> void:
|
|||
|
||||
i += 1
|
||||
|
||||
i = 0
|
||||
while i < 1024 / 3:
|
||||
var star = star_scene.instantiate()
|
||||
star.position = Vector2(-99999999999999999, -9999999999999999999)
|
||||
star.parallax = 0.2
|
||||
|
||||
$Stars.add_child(star)
|
||||
|
||||
i += 1
|
||||
|
||||
i = 0
|
||||
while i < 1024 / 3:
|
||||
var star = star_scene.instantiate()
|
||||
star.position = Vector2(-99999999999999999, -9999999999999999999)
|
||||
star.parallax = 0.5
|
||||
|
||||
$Stars.add_child(star)
|
||||
|
||||
i += 1
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if get_tree().paused:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
extends Sprite2D
|
||||
|
||||
@onready var player = get_parent().get_parent().get_node("Player")
|
||||
var parallax = 0
|
||||
@onready var last_position = player.position
|
||||
|
||||
func random_respawn(distance_min = 2000):
|
||||
var random_rotation = randf_range(-7, 7)
|
||||
var random_distance = randi_range(distance_min, 2000)
|
||||
var random_size = randf_range(0.02, 0.5)
|
||||
|
||||
parallax = randf_range(0, 0.5)
|
||||
|
||||
global_position = player.global_position + (Vector2.UP.rotated(random_rotation) * random_distance)
|
||||
global_position += (Vector2.RIGHT * randi_range(-random_distance, random_distance)).rotated(random_rotation)
|
||||
|
||||
|
|
@ -30,6 +34,9 @@ func _ready() -> void:
|
|||
random_respawn(0)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
position += (player.position - last_position) * parallax
|
||||
last_position = player.position
|
||||
|
||||
var distance = abs((player.global_position - global_position).length())
|
||||
|
||||
if distance > 2100:
|
||||
|
|
|
|||
Loading…
Reference in a new issue