fuzzyworld

godot-shooter / commit

Experimenting with a starfield background that's created with particle effects.

625d806b7b6cb005d38ebccbe3902392899dc320 · Pavel Safronov · 2023-11-01 10:08:01 -0700 · parents c727f3b081be

Experimenting with a starfield background that's created with particle effects.
 StarField.tscn | 34 ++++++++++++++++++++++++++++++++++
 World.tscn     |  8 +++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/StarField.tscn b/StarField.tscn
new file mode 100644
index 0000000..2b385a2
--- /dev/null
+++ b/StarField.tscn
@@ -0,0 +1,34 @@
+[gd_scene load_steps=7 format=2]
+
+[ext_resource path="res://kenney_simple-space/PNG/Default/star_medium.png" type="Texture" id=1]
+
+[sub_resource type="Gradient" id=1]
+offsets = PoolRealArray( 0, 0.325137, 0.669399, 0.997268 )
+colors = PoolColorArray( 1, 1, 1, 1, 0.0078125, 0, 1, 1, 1, 0, 0.0234375, 1, 1, 1, 1, 1 )
+
+[sub_resource type="GradientTexture" id=2]
+gradient = SubResource( 1 )
+
+[sub_resource type="Curve" id=3]
+_data = [ Vector2( 0, 0 ), 0.0, 0.0932435, 0, 0, Vector2( 0.294686, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.492754, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.743961, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
+
+[sub_resource type="CurveTexture" id=4]
+curve = SubResource( 3 )
+
+[sub_resource type="ParticlesMaterial" id=5]
+emission_shape = 2
+emission_box_extents = Vector3( 1000, 1000, 0 )
+flag_disable_z = true
+gravity = Vector3( 0, 0, 0 )
+orbit_velocity = 0.0
+orbit_velocity_random = 0.0
+angle = 720.0
+angle_random = 1.0
+scale_curve = SubResource( 4 )
+color_ramp = SubResource( 2 )
+
+[node name="StarField" type="Particles2D"]
+amount = 100
+lifetime = 6.0
+process_material = SubResource( 5 )
+texture = ExtResource( 1 )
diff --git a/World.tscn b/World.tscn
index d5e6f6e..b77f066 100644
--- a/World.tscn
+++ b/World.tscn
@@ -1,12 +1,18 @@
-[gd_scene load_steps=3 format=2]
+[gd_scene load_steps=4 format=2]
 
 [ext_resource path="res://Enemy.tscn" type="PackedScene" id=1]
 [ext_resource path="res://Player.tscn" type="PackedScene" id=2]
+[ext_resource path="res://StarField.tscn" type="PackedScene" id=3]
 
 [node name="World" type="Node2D"]
 
 [node name="Environment" type="Node2D" parent="."]
 
+[node name="StarField" parent="Environment" instance=ExtResource( 3 )]
+visible = false
+scale = Vector2( 0.5, 0.5 )
+preprocess = 414.78
+
 [node name="Player" parent="." groups=["player"] instance=ExtResource( 2 )]
 
 [node name="Enemy" parent="." instance=ExtResource( 1 )]