Added effects manager and two effects to test attached to the player

scene.
This commit is contained in:
Henry Faber 2026-06-24 14:48:02 +01:00
parent 1200ac7e32
commit b4c4a66ce8
19 changed files with 322 additions and 40 deletions

View file

@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://bq3xhbfgkt22l"]
[ext_resource type="Script" uid="uid://65d3hbrpm21x" path="res://scripts/effects_component.gd" id="1_ee0kt"]
[ext_resource type="Script" uid="uid://65d3hbrpm21x" path="res://scripts/effects/effects_component.gd" id="1_ee0kt"]
[node name="EffectsComponent" type="Node2D" unique_id=1393438576]
[node name="EffectsComponent" type="Node" unique_id=1393438576]
script = ExtResource("1_ee0kt")

View file

@ -1,27 +0,0 @@
class_name FlashEffect
extends BaseEffect
@export var flash_color: Color = Color.WHITE
@export var flash_speed: float = 10.0
var _timer: float = 0.0
var _original_material: Material
func start(target: Node) -> void:
_timer = 0.0
if target is CanvasItem:
_original_material = target.material
# Apply a ShaderMaterial that handles the flash
var flash_material = ShaderMaterial.new()
flash_material.shader = preload("res://shaders/flash.gdshader")
target.material = flash_material
func process(delta: float, target: Node) -> void:
_timer += delta
if target.material is ShaderMaterial:
var intensity = (sin(_timer * flash_speed) + 1.0) / 2.0
target.material.set_shader_parameter("flash_intensity", intensity)
func stop(target: Node) -> void:
if target is CanvasItem:
target.material = _original_material

View file

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

View file

@ -19,6 +19,10 @@ var previous_position: Vector2
var ship_displacement: float
var travel: float = 0
# Effects Testing
var flash_effect = preload("res://resources/effects/flash_weapon_change.tres")
var blink_effect = preload("res://resources/effects/invincibility_blink.tres")
func _ready() -> void:
## Set initial start position
@ -50,3 +54,4 @@ func _process(delta) -> void:
# Cycle weapon (testing key)
if input_component.cycle_weapon:
weapon_component.cycle_weapon()
$EffectsComponent.apply_effect(flash_effect)

View file

@ -12,6 +12,7 @@
[ext_resource type="Resource" uid="uid://bhc6aja38vyr" path="res://resources/player_weapon_resources/vanguard.tres" id="9_ur7pv"]
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://scripts/weapon_shot.gd" id="10_d2wvv"]
[ext_resource type="Resource" uid="uid://cck3gmnhu5agc" path="res://resources/player_weapon_resources/tri.tres" id="11_3v2ag"]
[ext_resource type="Script" uid="uid://65d3hbrpm21x" path="res://scripts/effects/effects_component.gd" id="12_effcomp"]
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
atlas = ExtResource("5_qlg0r")
@ -92,6 +93,8 @@ size = Vector2(24, 30)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dqkch"]
size = Vector2(6, 5.75)
[sub_resource type="Resource" id="Resource_jej6c"]
[node name="Player" type="Area2D" unique_id=652131079]
script = ExtResource("1_ur7pv")
@ -155,6 +158,13 @@ unique_name_in_owner = true
script = ExtResource("7_d2wvv")
weapon_data = ExtResource("8_stock")
available_weapons = Array[ExtResource("10_d2wvv")]([ExtResource("8_stock"), ExtResource("11_3v2ag"), ExtResource("9_ur7pv")])
weapon_change_flash = SubResource("Resource_jej6c")
metadata/_custom_type_script = "uid://ylmao2ndp22y"
[node name="EffectsComponent" type="Node" parent="." unique_id=1393438576 node_paths=PackedStringArray("target_node")]
unique_name_in_owner = true
script = ExtResource("12_effcomp")
target_node = NodePath("../Ship")
metadata/_custom_type_script = "uid://65d3hbrpm21x"
[connection signal="timeout" from="WeaponCooldown" to="." method="_on_weapon_cooldown_timeout"]

View file

@ -14,6 +14,11 @@
script = ExtResource("2_k0juu")
notification_scene = ExtResource("3_71j4m")
[node name="FPS" type="Label" parent="UI" unique_id=1606313100]
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
[node name="Level" type="Node2D" parent="." unique_id=934289771]
[node name="Background" type="Node2D" parent="Level" unique_id=485120278]