Added in background particles.

This commit is contained in:
Tanner Van Teeffelen 2026-04-24 01:45:03 -04:00
parent 8162b33c7d
commit c988769e98
9 changed files with 98 additions and 5 deletions

View file

@ -0,0 +1,11 @@
[gd_resource type="ParticleProcessMaterial" format=3 uid="uid://dhirstigqbwlc"]
[resource]
particle_flag_disable_z = true
emission_shape_offset = Vector3(0, -8, 0)
emission_shape = 1
emission_sphere_radius = 7.35
gravity = Vector3(0, -98, 0)
scale_max = 2.5
color = Color(0, 0, 0, 0.5137255)
collision_mode = 2

View file

@ -0,0 +1,11 @@
[gd_resource type="ParticleProcessMaterial" format=3 uid="uid://ch1r4nhrcpg3s"]
[resource]
particle_flag_disable_z = true
emission_shape_offset = Vector3(0, -8, 0)
emission_shape = 1
emission_sphere_radius = 7.35
gravity = Vector3(0, 98, 0)
scale_max = 2.5
color = Color(0, 0, 0, 0.5058824)
collision_mode = 2

View file

@ -1,15 +1,15 @@
[gd_scene load_steps=4 format=4 uid="uid://c6aveiahox475"]
[gd_scene format=4 uid="uid://c6aveiahox475"]
[ext_resource type="Script" uid="uid://bdoa8j4vedy8" path="res://Scripts/Levels/level_1.gd" id="1_3mqfk"]
[ext_resource type="TileSet" uid="uid://bxbrytgrtnaie" path="res://Sprites/Tile Sets/main.tres" id="2_iixi8"]
[ext_resource type="PackedScene" uid="uid://syx6ov00a585" path="res://Scenes/player.tscn" id="3_cyadu"]
[node name="Main" type="Node2D"]
[node name="Main" type="Node2D" unique_id=1790453106]
script = ExtResource("1_3mqfk")
[node name="TileMapLayer" type="TileMapLayer" parent="."]
[node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=1662317524]
tile_map_data = PackedByteArray("AAABAAwAAAAAAAEAAAACAAwAAAAAAAEAAAADAAwAAAAAAAEAAAAEAAwAAAAAAAEAAAAFAAwAAAAAAAEAAAAGAAwAAAAAAAEAAAAHAAwAAAAAAAEAAAAIAAwAAAAAAAEAAAAJAAwAAAAAAAEAAAAKAAwAAAAAAAEAAAALAAwAAAAAAAEAAAAMAAwAAAAAAAEAAAANAAwAAAAAAAEAAAAOAAwAAAAAAAEAAAAPAAwAAAAAAAEAAAAQAAwAAAAAAAEAAAARAAwAAAAAAAEAAAASAAwAAAAAAAEAAAATAAwAAAAAAAEAAAAUAAwAAAAAAAEAAAAVAAwAAAAAAAEAAAAWAAwAAAAAAAEAAAAXAAwAAAAAAAEAAAAYAAwAAAAAAAEAAAAYAAsAAAACAAAAAAA=")
tile_set = ExtResource("2_iixi8")
[node name="Player" parent="." instance=ExtResource("3_cyadu")]
[node name="Player" parent="." unique_id=748235082 instance=ExtResource("3_cyadu")]
position = Vector2(24, 184)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -5,6 +5,7 @@
[ext_resource type="Material" uid="uid://ck13qte606w1j" path="res://Materials/Particles/down_particles.tres" id="2_vgqql"]
[ext_resource type="Script" uid="uid://de1fdvk35epdt" path="res://Scripts/player_camera.gd" id="4_vgqql"]
[ext_resource type="PackedScene" uid="uid://botdddpmgoc8o" path="res://Scenes/scene_transition_rect.tscn" id="5_fkybt"]
[ext_resource type="Script" uid="uid://cbj4o4syiqn74" path="res://Scripts/background_particles.gd" id="6_x3wgy"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jjgbg"]
size = Vector2(16, 16)
@ -33,10 +34,15 @@ rect = Rect2(-8, -8, 16, 16)
top_level = true
script = ExtResource("4_vgqql")
[node name="BackgroundParticles" type="Node2D" parent="." unique_id=867705320]
script = ExtResource("6_x3wgy")
number_of_particles = 250
[node name="SceneTransitionRect" parent="." unique_id=726492614 instance=ExtResource("5_fkybt")]
offset_left = -5000.0
offset_top = -5000.0
offset_right = 5000.0
offset_bottom = 5000.0
[connection signal="input_event" from="." to="BackgroundParticles" method="_on_player_input_event"]
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]

View file

@ -0,0 +1,48 @@
extends Node2D
@export var number_of_particles : int
var particle_child : GPUParticles2D
var up_material : ParticleProcessMaterial = load("res://Materials/Particles/up_particles_bg.tres")
var down_material : ParticleProcessMaterial = load("res://Materials/Particles/down_particles_bg.tres")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
up_material = up_material.duplicate()
down_material = down_material.duplicate()
reloadParticles()
func _physics_process(delta: float) -> void:
if Input.is_action_just_pressed("flip"):
print("input detected")
reloadParticles()
func reloadParticles() -> void:
#If the particle node does not already exist, do the initial setup, and add it as a child node.
if !has_node("BGParticles"):
var bgparticle := GPUParticles2D.new()
bgparticle.amount = number_of_particles
bgparticle.emitting = true
bgparticle.top_level = true
bgparticle.name = "BGParticles"
add_child(bgparticle)
particle_child = get_node_or_null("BGParticles")
#Set up the material we want to set the particle node to, and set up a screen size variable.
var material : ParticleProcessMaterial
var size : Vector2 = get_viewport_rect().size
#Simple gravity direction detection.
if al_globals.y_gravity > 0:
material = up_material
elif al_globals.y_gravity < 0:
material = down_material
#Set the emission shape and the size, relative to size of screen.
material.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_BOX
material.emission_box_extents = Vector3(size.x, size.y, 0)
#Set the material of the particle child object to the created material.
particle_child.process_material = material

View file

@ -0,0 +1 @@
uid://cbj4o4syiqn74

View file

@ -34,6 +34,7 @@ enabled=PackedStringArray("res://addons/_Godot-IDE_/plugin.cfg")
folder_colors={
"res://addons/_Godot-IDE_/plugins": "blue",
"res://addons/_Godot-IDE_/plugins/": "blue",
"res://addons/_Godot-IDE_/shared_resources/": "teal"
}