Compare commits
21 commits
feature-no
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ac71cc104 | |||
| fa882502b4 | |||
| a655f9332f | |||
| 9554af183c | |||
| 64e685a3c1 | |||
| 99a5d9838d | |||
| 6c5a0a0bae | |||
| 3303d937fd | |||
| 313e013543 | |||
| 2db5f37975 | |||
| 62e02d2555 | |||
| 122f7bed5f | |||
| 30619bc7c1 | |||
| 4f3839448b | |||
| 4f90c82b8f | |||
| dd4652b732 | |||
| 389485e82c | |||
| 650239a9e8 | |||
| b4c4a66ce8 | |||
| 1200ac7e32 | |||
| 8e821ead28 |
40 changed files with 839 additions and 77 deletions
BIN
graphics/spread.png
Normal file
BIN
graphics/spread.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 259 B |
40
graphics/spread.png.import
Normal file
40
graphics/spread.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dwc5fjwhqikoo"
|
||||
path="res://.godot/imported/spread.png-77a3efff77439dd55f282fc699502b2f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graphics/spread.png"
|
||||
dest_files=["res://.godot/imported/spread.png-77a3efff77439dd55f282fc699502b2f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
|
@ -13,6 +13,7 @@ config_version=5
|
|||
config/name="Facsimile Wing"
|
||||
run/main_scene="uid://bj4fytc3sy482"
|
||||
config/features=PackedStringArray("4.7", "Forward Plus")
|
||||
run/max_fps=60
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
|
|
|||
8
resources/effects/flash_weapon_change.tres
Normal file
8
resources/effects/flash_weapon_change.tres
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[gd_resource type="Resource" script_class="FlashEffect" format=3 uid="uid://c86rdr6gtto66"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://dp4svqyxg1dum" path="res://shaders/flash.gdshader" id="1_37i75"]
|
||||
[ext_resource type="Script" uid="uid://deak7vcr7ss5l" path="res://scripts/effects/flash_effect.gd" id="2_y51sa"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_y51sa")
|
||||
metadata/_custom_type_script = "uid://deak7vcr7ss5l"
|
||||
13
resources/effects/invincibility_blink.tres
Normal file
13
resources/effects/invincibility_blink.tres
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="BlinkerEffect" format=3 uid="uid://bld2k7san214b"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cj4grtaun2h5a" path="res://scripts/effects/blinker_effect.gd" id="1_blink"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_blink")
|
||||
blink_frequency = 12.0
|
||||
blink_length = 0.2
|
||||
min_alpha = 0.1
|
||||
start_ease = 0.1
|
||||
start_ease_mode = 0
|
||||
end_ease_mode = 0
|
||||
duration = 0.75
|
||||
10
resources/player_weapon_resources/patterns/fwd.tres
Normal file
10
resources/player_weapon_resources/patterns/fwd.tres
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[gd_resource type="Resource" script_class="WeaponProjectileGroup" format=3 uid="uid://tdmd8jq8cm4y"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0ios82vubijg" path="res://scripts/weapon_projectile_group.gd" id="1_mhej7"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_mhej7")
|
||||
pattern_name = "fwd"
|
||||
bullet_count = 5
|
||||
group_delay = 5.0
|
||||
stagger_offset = 2.0
|
||||
12
resources/player_weapon_resources/patterns/phallanx.tres
Normal file
12
resources/player_weapon_resources/patterns/phallanx.tres
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_resource type="Resource" script_class="WeaponProjectileGroup" format=3 uid="uid://ch8qch6lx1mdx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0ios82vubijg" path="res://scripts/weapon_projectile_group.gd" id="1_m23g4"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_m23g4")
|
||||
spread_angle = 3.0
|
||||
angle_offset = 8.0
|
||||
horizontal_offset = 20.0
|
||||
group_delay = 0.25
|
||||
stagger_offset = 0.5
|
||||
mirror = true
|
||||
18
resources/player_weapon_resources/spread.tres
Normal file
18
resources/player_weapon_resources/spread.tres
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[gd_resource type="Resource" script_class="WeaponShot" format=3 uid="uid://ds53sryglmf27"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ddpclu2vdy2ve" path="res://scenes/player_weapons/weapon_stock.tscn" id="1_pn64g"]
|
||||
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://scripts/weapon_shot.gd" id="2_4b7mw"]
|
||||
[ext_resource type="Script" uid="uid://d0ios82vubijg" path="res://scripts/weapon_projectile_group.gd" id="2_ak5x4"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_4b7mw")
|
||||
shot_name = "spread"
|
||||
bullet_scene = ExtResource("1_pn64g")
|
||||
damage = 5
|
||||
speed = 720
|
||||
projectiles = 5
|
||||
horizontal_offset = 8.25
|
||||
spread_angle = 25.0
|
||||
stagger_offset = 0.5
|
||||
stagger_animation = true
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="WeaponShot" format=3 uid="uid://b75ae840k03dy"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ddpclu2vdy2ve" path="res://scenes/player_weapons/weapon_stock.tscn" id="1_lcw6o"]
|
||||
[ext_resource type="Script" uid="uid://d0ios82vubijg" path="res://scripts/weapon_projectile_group.gd" id="2_e245k"]
|
||||
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://scripts/weapon_shot.gd" id="2_ym48c"]
|
||||
|
||||
[resource]
|
||||
|
|
@ -8,9 +9,7 @@ script = ExtResource("2_ym48c")
|
|||
shot_name = "stock"
|
||||
bullet_scene = ExtResource("1_lcw6o")
|
||||
damage = 2
|
||||
speed = 500
|
||||
spacing = 25.0
|
||||
origin = -15
|
||||
horizontal_offset = 10.0
|
||||
stagger_offset = 0.35
|
||||
speed = 650
|
||||
horizontal_offset = 12.0
|
||||
stagger_offset = 0.0
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="WeaponShot" format=3 uid="uid://cck3gmnhu5agc"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://clpyd8qfwthk2" path="res://scenes/player_weapons/weapon_spreadshot.tscn" id="1_07hyh"]
|
||||
[ext_resource type="Script" uid="uid://d0ios82vubijg" path="res://scripts/weapon_projectile_group.gd" id="2_bhv8k"]
|
||||
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://scripts/weapon_shot.gd" id="2_syw6j"]
|
||||
|
||||
[resource]
|
||||
|
|
@ -8,11 +9,9 @@ script = ExtResource("2_syw6j")
|
|||
shot_name = "tri"
|
||||
bullet_scene = ExtResource("1_07hyh")
|
||||
damage = 3
|
||||
speed = 450
|
||||
speed = 700
|
||||
projectiles = 3
|
||||
spacing = 30.0
|
||||
origin = -15
|
||||
horizontal_offset = 8.5
|
||||
stagger_offset = 0.2
|
||||
horizontal_offset = 12.5
|
||||
stagger_offset = 0.35
|
||||
stagger_animation = true
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
|
|
|
|||
21
resources/player_weapon_resources/vanguard+.tres
Normal file
21
resources/player_weapon_resources/vanguard+.tres
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[gd_resource type="Resource" script_class="WeaponShot" format=3 uid="uid://c41aoyka7nfr8"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ddpclu2vdy2ve" path="res://scenes/player_weapons/weapon_stock.tscn" id="1_lqlv8"]
|
||||
[ext_resource type="Script" uid="uid://d0ios82vubijg" path="res://scripts/weapon_projectile_group.gd" id="2_qeb4b"]
|
||||
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://scripts/weapon_shot.gd" id="3_fh2eq"]
|
||||
[ext_resource type="Resource" uid="uid://ch8qch6lx1mdx" path="res://resources/player_weapon_resources/patterns/phallanx.tres" id="3_qeb4b"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("3_fh2eq")
|
||||
shot_name = "vanguard+"
|
||||
bullet_scene = ExtResource("1_lqlv8")
|
||||
damage = 5
|
||||
speed = 500
|
||||
projectiles = 5
|
||||
horizontal_offset = 8.25
|
||||
stagger_offset = 0.5
|
||||
compensate_spawn_geometry = true
|
||||
stagger_animation = true
|
||||
follow_angle = true
|
||||
groups = Array[ExtResource("2_qeb4b")]([ExtResource("3_qeb4b")])
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
[ext_resource type="PackedScene" uid="uid://ddpclu2vdy2ve" path="res://scenes/player_weapons/weapon_stock.tscn" id="1_hm46f"]
|
||||
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://scripts/weapon_shot.gd" id="2_w7xlm"]
|
||||
[ext_resource type="Script" uid="uid://d0ios82vubijg" path="res://scripts/weapon_projectile_group.gd" id="2_xf183"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_w7xlm")
|
||||
|
|
@ -10,8 +11,6 @@ bullet_scene = ExtResource("1_hm46f")
|
|||
damage = 5
|
||||
speed = 500
|
||||
projectiles = 5
|
||||
spacing = 30.0
|
||||
origin = -15
|
||||
horizontal_offset = 8.25
|
||||
stagger_offset = 0.5
|
||||
stagger_animation = true
|
||||
|
|
|
|||
6
scenes/EffectComponent.tscn
Normal file
6
scenes/EffectComponent.tscn
Normal file
|
|
@ -0,0 +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"]
|
||||
|
||||
[node name="EffectsComponent" type="Node" unique_id=1393438576]
|
||||
script = ExtResource("1_ee0kt")
|
||||
|
|
@ -11,7 +11,8 @@ icon = NodePath("HBoxContainer/Icon")
|
|||
label = NodePath("HBoxContainer/Label")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=228546504]
|
||||
layout_mode = 0
|
||||
layout_mode = 1
|
||||
theme_override_constants/separator = 4
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="HBoxContainer" unique_id=3]
|
||||
custom_minimum_size = Vector2(16, 16)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -10,8 +10,12 @@
|
|||
[ext_resource type="Script" uid="uid://ylmao2ndp22y" path="res://scripts/weapon_component.gd" id="7_d2wvv"]
|
||||
[ext_resource type="Resource" uid="uid://b75ae840k03dy" path="res://resources/player_weapon_resources/stock.tres" id="8_stock"]
|
||||
[ext_resource type="Resource" uid="uid://bhc6aja38vyr" path="res://resources/player_weapon_resources/vanguard.tres" id="9_ur7pv"]
|
||||
[ext_resource type="Script" uid="uid://znfh8unmdxkvv" path="res://scripts/weapon_fire_helper.gd" id="15_firehelper"]
|
||||
[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_component.gd" id="12_effcomp"]
|
||||
[ext_resource type="Resource" uid="uid://ds53sryglmf27" path="res://resources/player_weapon_resources/spread.tres" id="13_f1ej7"]
|
||||
[ext_resource type="Resource" uid="uid://c41aoyka7nfr8" path="res://resources/player_weapon_resources/vanguard+.tres" id="14_oprun"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
||||
atlas = ExtResource("5_qlg0r")
|
||||
|
|
@ -92,6 +96,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")
|
||||
|
||||
|
|
@ -146,6 +152,10 @@ player = NodePath("..")
|
|||
speed = 200.0
|
||||
metadata/_custom_type_script = "uid://c0rikbakpcags"
|
||||
|
||||
[node name="WeaponFireHelper" type="Node" parent="." unique_id=623642426]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("15_firehelper")
|
||||
|
||||
[node name="ShootComponent" type="Node" parent="." unique_id=623642425]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("6_y4r1p")
|
||||
|
|
@ -154,7 +164,14 @@ script = ExtResource("6_y4r1p")
|
|||
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")])
|
||||
available_weapons = Array[ExtResource("10_d2wvv")]([ExtResource("8_stock"), ExtResource("11_3v2ag"), ExtResource("9_ur7pv"), ExtResource("13_f1ej7"), ExtResource("14_oprun")])
|
||||
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"]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ var time_offset: float = 0.5
|
|||
# When this bullet should fire (absolute time)
|
||||
var fire_time: float = 0.0
|
||||
|
||||
# Angle offset for spread shots (in degrees)
|
||||
var angle: float = 0.0
|
||||
|
||||
# Track if this bullet is currently active in the shot
|
||||
var is_active: bool = false
|
||||
|
||||
|
|
@ -20,8 +23,13 @@ func _process(delta):
|
|||
if !is_active and current_time >= fire_time:
|
||||
activate()
|
||||
|
||||
# Move the bullet
|
||||
position.y -= shot_data.speed * delta
|
||||
# Move the bullet every frame; stagger controls visibility, not movement
|
||||
var velocity = Vector2.UP.rotated(deg_to_rad(angle)) * shot_data.speed
|
||||
position += velocity * delta
|
||||
|
||||
# Rotate sprite to face travel direction when conditions are met
|
||||
if shot_data.follow_angle and shot_data.projectiles > 2 and shot_data.spread_angle > 0:
|
||||
$AnimatedSprite2D.rotation = deg_to_rad(angle)
|
||||
|
||||
func activate():
|
||||
is_active = true
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ animations = [{
|
|||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
|
||||
size = Vector2(6.666667, 14)
|
||||
size = Vector2(10, 16)
|
||||
|
||||
[node name="StockWeapon" type="Area2D" unique_id=1832200900]
|
||||
script = ExtResource("1_u1d5o")
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://b3dqvd23nbmrm" path="res://graphics/cloud layers.png" id="3_4wyf3"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3scm07fgpkcp" path="res://scenes/notification_display.tscn" id="3_71j4m"]
|
||||
[ext_resource type="PackedScene" uid="uid://6wq3ynesnsha" path="res://scenes/player.tscn" id="3_k0juu"]
|
||||
[ext_resource type="Script" uid="uid://eblemtukrey6" path="res://scripts/utility/fps_display.gd" id="4_qfnet"]
|
||||
|
||||
[node name="World" type="Node2D" unique_id=1317852169]
|
||||
|
||||
|
|
@ -14,6 +15,13 @@
|
|||
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
|
||||
theme_override_font_sizes/font_size = 8
|
||||
script = ExtResource("4_qfnet")
|
||||
|
||||
[node name="Level" type="Node2D" parent="." unique_id=934289771]
|
||||
|
||||
[node name="Background" type="Node2D" parent="Level" unique_id=485120278]
|
||||
|
|
|
|||
22
scripts/effects/base_effect.gd
Normal file
22
scripts/effects/base_effect.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class_name BaseEffect
|
||||
extends Resource
|
||||
|
||||
@export var duration: float = 0.5
|
||||
|
||||
var _elapsed: float = 0.0
|
||||
|
||||
# Called when the effect is applied
|
||||
func start(target: Node) -> void:
|
||||
_elapsed = 0.0
|
||||
|
||||
# Called every frame (if needed)
|
||||
func process(delta: float, target: Node) -> void:
|
||||
_elapsed += delta
|
||||
|
||||
# Clean up any changes to the target
|
||||
func stop(target: Node) -> void:
|
||||
pass
|
||||
|
||||
# Returns true when the effect has run its course
|
||||
func is_finished() -> bool:
|
||||
return _elapsed >= duration
|
||||
1
scripts/effects/base_effect.gd.uid
Normal file
1
scripts/effects/base_effect.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cs7xpxd1vpl56
|
||||
90
scripts/effects/blinker_effect.gd
Normal file
90
scripts/effects/blinker_effect.gd
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
class_name BlinkerEffect
|
||||
extends BaseEffect
|
||||
|
||||
## How many blink cycles per second.
|
||||
@export_range(0.0, 60.0) var blink_frequency: float = 8.0
|
||||
|
||||
## Fraction of each cycle the sprite is visible (0.0–1.0).
|
||||
@export_range(0.0, 1.0) var blink_length: float = 0.5
|
||||
|
||||
## Minimum alpha when "off" (0.0 = fully invisible, 1.0 = fully visible).
|
||||
@export_range(0.0, 1.0) var min_alpha: float = 0.0
|
||||
|
||||
## Maximum alpha when "on" (0.0–1.0).
|
||||
@export_range(0.0, 1.0) var max_alpha: float = 1.0
|
||||
|
||||
## Duration of the fade-in at the start of the effect (seconds).
|
||||
@export_range(0.0, 5.0) var start_ease: float = 0.0
|
||||
|
||||
## Easing curve for the fade-in.
|
||||
@export_enum("Linear", "Smooth", "Ease-In", "Ease-Out", "Ease-In-Out") var start_ease_mode: int = 1
|
||||
|
||||
## Duration of the fade-out at the end of the effect (seconds).
|
||||
@export_range(0.0, 5.0) var end_ease: float = 0.0
|
||||
|
||||
## Easing curve for the fade-out.
|
||||
@export_enum("Linear", "Smooth", "Ease-In", "Ease-Out", "Ease-In-Out") var end_ease_mode: int = 1
|
||||
|
||||
var _original_modulate: Color
|
||||
|
||||
|
||||
func start(target: Node) -> void:
|
||||
super.start(target)
|
||||
if target is CanvasItem:
|
||||
_original_modulate = target.modulate
|
||||
|
||||
|
||||
func process(delta: float, target: Node) -> void:
|
||||
super.process(delta, target)
|
||||
if target is CanvasItem:
|
||||
var alpha: float = _compute_alpha(_elapsed)
|
||||
target.modulate = Color(_original_modulate.r, _original_modulate.g, _original_modulate.b, alpha)
|
||||
|
||||
|
||||
func stop(target: Node) -> void:
|
||||
if target is CanvasItem:
|
||||
target.modulate = _original_modulate
|
||||
|
||||
|
||||
## Compute the combined eased alpha for a given elapsed time.
|
||||
func _compute_alpha(elapsed: float) -> float:
|
||||
if duration <= 0.0:
|
||||
return 1.0
|
||||
|
||||
var t: float = min(elapsed, duration)
|
||||
|
||||
# Blink pulse: on/off cycling at the given frequency and duty cycle
|
||||
var period := 1.0 / blink_frequency if blink_frequency > 0.0 else 1.0
|
||||
var phase := fmod(t, period) / period
|
||||
|
||||
var pulse: float = min_alpha
|
||||
if phase < blink_length:
|
||||
var pulse_progress = phase / blink_length if blink_length > 0.0 else 1.0
|
||||
if pulse_progress < 0.5:
|
||||
pulse = min_alpha + (max_alpha - min_alpha) * _ease_value(pulse_progress * 2.0, 2)
|
||||
else:
|
||||
pulse = min_alpha + (max_alpha - min_alpha) * _ease_value((1.0 - pulse_progress) * 2.0, 3)
|
||||
|
||||
# Start ease: fade from fully visible into the blink pattern
|
||||
if t < start_ease and start_ease > 0.0:
|
||||
var fade_in = _ease_value(t / start_ease, start_ease_mode)
|
||||
return lerp(max_alpha, pulse, fade_in)
|
||||
|
||||
# End ease: fade from blink pattern back to fully visible
|
||||
if t > duration - end_ease and end_ease > 0.0:
|
||||
var fade_progress = (t - (duration - end_ease)) / end_ease
|
||||
var fade_out = _ease_value(fade_progress, end_ease_mode)
|
||||
return lerp(pulse, max_alpha, fade_out)
|
||||
|
||||
return pulse
|
||||
|
||||
|
||||
## Apply easing to a 0.0–1.0 normalized value based on the selected mode.
|
||||
func _ease_value(value: float, mode: int) -> float:
|
||||
match mode:
|
||||
0: return value # Linear
|
||||
1: return smoothstep(0.0, 1.0, value) # Smooth
|
||||
2: return ease(value, -2.0) # Ease-In (accelerating)
|
||||
3: return ease(value, 2.0) # Ease-Out (decelerating)
|
||||
4: return ease(value, 3.0) # Ease-In-Out (S-curve)
|
||||
return value
|
||||
1
scripts/effects/blinker_effect.gd.uid
Normal file
1
scripts/effects/blinker_effect.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cj4grtaun2h5a
|
||||
105
scripts/effects/flash_effect.gd
Normal file
105
scripts/effects/flash_effect.gd
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
class_name FlashEffect
|
||||
extends BaseEffect
|
||||
|
||||
## Shader applied to the target sprite during the flash.
|
||||
@export var flash_shader: Shader = preload("res://shaders/flash.gdshader")
|
||||
|
||||
## Color of the flash overlay.
|
||||
@export var flash_color: Color = Color.WHITE
|
||||
|
||||
## How many flash cycles per second.
|
||||
@export_range(0.0, 60.0) var flash_frequency: float = 10.0
|
||||
|
||||
## Fraction of each cycle the flash is visible (0.0–1.0, i.e. duty cycle).
|
||||
@export_range(0.0, 1.0) var flash_length: float = 0.5
|
||||
|
||||
## How the flash blends with the original sprite.
|
||||
@export_enum("Mix", "Additive", "Screen") var blend_mode: int = 0
|
||||
|
||||
## Additional brightness added to the flash color (0.0 = none, 1.0 = double).
|
||||
@export_range(0.0, 1.0) var brightness_boost: float = 0.0
|
||||
|
||||
## Duration of the fade-in at the start of the effect (seconds).
|
||||
@export_range(0.0, 5.0) var start_ease: float = 0.0
|
||||
|
||||
## Easing curve for the fade-in.
|
||||
@export_enum("Linear", "Smooth", "Ease-In", "Ease-Out", "Ease-In-Out") var start_ease_mode: int = 1
|
||||
|
||||
## Duration of the fade-out at the end of the effect (seconds).
|
||||
@export_range(0.0, 5.0) var end_ease: float = 0.0
|
||||
|
||||
## Easing curve for the fade-out.
|
||||
@export_enum("Linear", "Smooth", "Ease-In", "Ease-Out", "Ease-In-Out") var end_ease_mode: int = 1
|
||||
|
||||
var _original_material: Material
|
||||
|
||||
|
||||
func start(target: Node) -> void:
|
||||
super.start(target)
|
||||
if target is CanvasItem:
|
||||
_original_material = target.material
|
||||
var flash_material := ShaderMaterial.new()
|
||||
flash_material.shader = flash_shader
|
||||
flash_material.set_shader_parameter("flash_color", flash_color)
|
||||
flash_material.set_shader_parameter("flash_intensity", 0.0)
|
||||
flash_material.set_shader_parameter("blend_mode", blend_mode)
|
||||
flash_material.set_shader_parameter("brightness_boost", brightness_boost)
|
||||
target.material = flash_material
|
||||
|
||||
|
||||
func process(delta: float, target: Node) -> void:
|
||||
super.process(delta, target)
|
||||
if target.material is ShaderMaterial:
|
||||
var intensity := _compute_intensity(_elapsed)
|
||||
target.material.set_shader_parameter("flash_intensity", intensity)
|
||||
|
||||
|
||||
func stop(target: Node) -> void:
|
||||
if target is CanvasItem:
|
||||
target.material = _original_material
|
||||
|
||||
|
||||
## Compute the combined eased flash intensity for a given elapsed time.
|
||||
## Returns a value 0.0–1.0 where 1.0 means full flash visibility.
|
||||
func _compute_intensity(elapsed: float) -> float:
|
||||
if duration <= 0.0:
|
||||
return 0.0
|
||||
|
||||
# Clamp elapsed to duration to avoid overshoot on the final frame
|
||||
var t: float = min(elapsed, duration)
|
||||
|
||||
# Overall envelope: fade in during start_ease, hold, fade out during end_ease
|
||||
var envelope: float = 1.0
|
||||
if t < start_ease and start_ease > 0.0:
|
||||
envelope = _ease_value(t / start_ease, start_ease_mode)
|
||||
elif t > duration - end_ease and end_ease > 0.0:
|
||||
var fade_progress = (t - (duration - end_ease)) / end_ease
|
||||
envelope = 1.0 - _ease_value(fade_progress, end_ease_mode)
|
||||
|
||||
# Flash pattern: on/off cycling at the given frequency and duty cycle
|
||||
# Each flash pulse also eases in and out for a smoother look
|
||||
var period := 1.0 / flash_frequency if flash_frequency > 0.0 else 1.0
|
||||
var phase := fmod(t, period) / period # 0.0–1.0 position within the current cycle
|
||||
|
||||
var pulse: float = 0.0
|
||||
if phase < flash_length:
|
||||
# Inside the "on" portion of this cycle — ease within the pulse itself
|
||||
var pulse_progress = phase / flash_length if flash_length > 0.0 else 1.0
|
||||
# Ease in for the first half of the pulse (build up), ease out for the second (fade down)
|
||||
if pulse_progress < 0.5:
|
||||
pulse = _ease_value(pulse_progress * 2.0, 2) # Ease-In (build up)
|
||||
else:
|
||||
pulse = _ease_value((1.0 - pulse_progress) * 2.0, 3) # Ease-Out (fade down)
|
||||
|
||||
return envelope * pulse
|
||||
|
||||
|
||||
## Apply easing to a 0.0–1.0 normalized value based on the selected mode.
|
||||
func _ease_value(value: float, mode: int) -> float:
|
||||
match mode:
|
||||
0: return value # Linear
|
||||
1: return smoothstep(0.0, 1.0, value) # Smooth
|
||||
2: return ease(value, -2.0) # Ease-In (accelerating)
|
||||
3: return ease(value, 2.0) # Ease-Out (decelerating)
|
||||
4: return ease(value, 3.0) # Ease-In-Out (S-curve)
|
||||
return value
|
||||
1
scripts/effects/flash_effect.gd.uid
Normal file
1
scripts/effects/flash_effect.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://deak7vcr7ss5l
|
||||
34
scripts/effects_component.gd
Normal file
34
scripts/effects_component.gd
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class_name EffectComponent
|
||||
extends Node
|
||||
|
||||
## The node this component applies effects to.
|
||||
## If left null, defaults to the first parent CanvasItem.
|
||||
@export var target_node: Node = null
|
||||
|
||||
var active_effects: Array[BaseEffect] = []
|
||||
|
||||
func _ready() -> void:
|
||||
if target_node == null:
|
||||
# Auto-resolve to the parent if nothing is set
|
||||
target_node = get_parent()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if target_node == null:
|
||||
return
|
||||
|
||||
# Process all active effects backwards so we can safely remove finished ones
|
||||
for i in range(active_effects.size() - 1, -1, -1):
|
||||
var effect = active_effects[i]
|
||||
effect.process(delta, target_node)
|
||||
|
||||
if effect.is_finished():
|
||||
remove_effect(effect)
|
||||
|
||||
func apply_effect(effect: BaseEffect) -> void:
|
||||
var instance = effect.duplicate()
|
||||
instance.start(target_node)
|
||||
active_effects.append(instance)
|
||||
|
||||
func remove_effect(effect: BaseEffect) -> void:
|
||||
effect.stop(target_node)
|
||||
active_effects.erase(effect)
|
||||
1
scripts/effects_component.gd.uid
Normal file
1
scripts/effects_component.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://65d3hbrpm21x
|
||||
|
|
@ -22,7 +22,7 @@ func tick(delta: float):
|
|||
# Calculate ship to bullet displacement
|
||||
player.ship_displacement = player.position.y - player.previous_position.y
|
||||
player.travel += abs(weapon_system.speed) * delta + (player.ship_displacement)
|
||||
player.travel = clamp(player.travel, 0, 1.9 * weapon_system.spacing)
|
||||
player.travel = clamp(player.travel, 0, 1.9 * weapon_system.projectile_vertical_spacing)
|
||||
|
||||
# Thruster animation in relation to player movement
|
||||
if input.x > 0:
|
||||
|
|
@ -30,16 +30,19 @@ func tick(delta: float):
|
|||
%Ship.frame = 2
|
||||
%Ship/Thrusters.flip_h = true
|
||||
%Ship/Thrusters.animation = "banked"
|
||||
%Ship/Thrusters.position.x = %Ship.position.x+1
|
||||
elif input.x < 0:
|
||||
player.position.x = player.position.x-1
|
||||
%Ship.frame = 1
|
||||
%Ship/Thrusters.flip_h = false
|
||||
%Ship/Thrusters.animation = "banked"
|
||||
%Ship/Thrusters.position.x = %Ship.position.x-1
|
||||
else:
|
||||
%Ship.frame = 0
|
||||
player.position.x = player.position.x
|
||||
%Ship/Thrusters.flip_h = false
|
||||
%Ship/Thrusters.animation = "fwd"
|
||||
%Ship/Thrusters.position.x = %Ship.position.x-0.3
|
||||
|
||||
# Get previous positon for equidistant bullet calculation
|
||||
player.previous_position = player.position
|
||||
|
|
|
|||
|
|
@ -13,7 +13,19 @@ var _connector_line: Line2D = null
|
|||
var _connector_visible: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Start fully transparent so the initial (0,0) position is invisible.
|
||||
# This runs during add_child() before any rendering occurs.
|
||||
modulate.a = 0.0
|
||||
|
||||
# 4px horizontal padding inside the background box
|
||||
_container.add_theme_constant_override("margin_left", 4)
|
||||
_container.add_theme_constant_override("margin_right", 4)
|
||||
|
||||
|
||||
func show_notification(weapon_name: String, player_node: Node2D, player_sprite_size: Vector2, origin_offset: float) -> void:
|
||||
modulate.a = 0.0
|
||||
|
||||
label.add_theme_font_size_override("font_size", 8)
|
||||
label.text = weapon_name
|
||||
|
||||
|
|
@ -40,16 +52,23 @@ func show_notification(weapon_name: String, player_node: Node2D, player_sprite_s
|
|||
_update_position()
|
||||
var target_pos = position
|
||||
|
||||
# Start 10px above destination, fully transparent
|
||||
# Start 10px above destination (already transparent from line 17)
|
||||
position.y = target_pos.y - 10.0
|
||||
modulate.a = 0.0
|
||||
|
||||
# Create connector line immediately so it fades in with the notification
|
||||
_connector_line = Line2D.new()
|
||||
_connector_line.default_color = Color(1.0, 1.0, 1.0, 0.0)
|
||||
_connector_line.width = 1.0
|
||||
add_child(_connector_line)
|
||||
_connector_visible = true
|
||||
|
||||
# Pause following during fade-in so the tween isn't overridden by _process
|
||||
_follow_player = false
|
||||
|
||||
# Fade in and slide into position with overshoot
|
||||
# Fade in notification and connector together, slide into position with overshoot
|
||||
var tween = create_tween().set_parallel()
|
||||
tween.tween_property(self, "modulate:a", 1.0, 0.3)
|
||||
tween.tween_property(_connector_line, "default_color:a", 1.0, 0.3)
|
||||
var move_tween = tween.tween_property(self, "position:y", target_pos.y, 0.3)
|
||||
move_tween.set_trans(Tween.TRANS_ELASTIC).set_ease(Tween.EASE_OUT)
|
||||
|
||||
|
|
@ -57,13 +76,6 @@ func show_notification(weapon_name: String, player_node: Node2D, player_sprite_s
|
|||
await tween.finished
|
||||
_follow_player = true
|
||||
|
||||
# Create connector line from notification to player origin
|
||||
_connector_line = Line2D.new()
|
||||
_connector_line.default_color = Color.WHITE
|
||||
_connector_line.width = 1.0
|
||||
add_child(_connector_line)
|
||||
_connector_visible = true
|
||||
|
||||
# Stay fully visible for a moment before fading
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
|
||||
|
|
|
|||
|
|
@ -2,48 +2,89 @@ class_name ShootComponent extends Node
|
|||
|
||||
@onready var weapon_component: Node = %WeaponComponent
|
||||
@onready var player = $".."
|
||||
@onready var ship: Sprite2D = get_node("../Ship")
|
||||
@onready var fire_helper: WeaponFireHelper = %WeaponFireHelper
|
||||
|
||||
func shoot():
|
||||
var weapon_data = weapon_component.weapon_data
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
var total_projectiles = weapon_data.projectiles
|
||||
|
||||
if player.travel > weapon_data.spacing:
|
||||
if player.travel > weapon_data.projectile_vertical_spacing:
|
||||
_shoot_standard(weapon_data, current_time)
|
||||
_shoot_grouped(weapon_data, current_time)
|
||||
|
||||
# Calculate center index for symmetrical staggering
|
||||
var center_index = (total_projectiles - 1) / 2.0
|
||||
# Reset travel after firing to prevent multiple bursts per tap
|
||||
player.travel = 0.0
|
||||
|
||||
|
||||
func _get_spawn_position(weapon_data: WeaponShot) -> Vector2:
|
||||
# Determine sprite height with a region_rect → texture fallback.
|
||||
var sprite_height: float = 0.0
|
||||
if ship.region_rect.has_area():
|
||||
sprite_height = ship.region_rect.size.y
|
||||
else:
|
||||
sprite_height = ship.texture.get_height()
|
||||
|
||||
# Top edge of the sprite in world space, then offset by origin.
|
||||
var top_edge = ship.global_position.y - (sprite_height / 2.0)
|
||||
return Vector2(ship.global_position.x, top_edge + weapon_data.origin)
|
||||
|
||||
|
||||
# Standard projectile logic (delegates to WeaponFireHelper)
|
||||
func _shoot_standard(weapon_data: WeaponShot, current_time: float):
|
||||
var total_projectiles: int = weapon_data.projectiles
|
||||
|
||||
if total_projectiles > 0:
|
||||
for b in range(total_projectiles):
|
||||
var bullet := weapon_data.bullet_scene.instantiate() as Area2D
|
||||
get_tree().root.add_child(bullet)
|
||||
|
||||
# Calculate index relative to center (0 = center, -1/+1 = first from center)
|
||||
var index_from_center: float = b - center_index
|
||||
|
||||
# Calculate timing offset for staggered firing
|
||||
var time_offset: float = index_from_center * weapon_data.stagger_offset
|
||||
|
||||
# Calculate horizontal offset for this bullet (symmetrical: left=-ve, right=+ve)
|
||||
var bullet_horizontal_offset: float = index_from_center * weapon_data.horizontal_offset
|
||||
|
||||
# Calculate vertical offset from center point (symmetrical vertical spread)
|
||||
var distance_from_center: float = abs(index_from_center)
|
||||
var vertical_offset: float = (distance_from_center * weapon_data.origin * -1) / 2
|
||||
|
||||
# Final position combines symmetrical horizontal spread with symmetrical vertical spacing
|
||||
bullet.position = player.position + Vector2(bullet_horizontal_offset, weapon_data.origin + (vertical_offset + weapon_data.origin - total_projectiles))
|
||||
|
||||
# Set timing properties on the bullet
|
||||
bullet.time_offset = time_offset
|
||||
bullet.fire_time = current_time + time_offset
|
||||
# Delegate math to the helper
|
||||
var spawn_position = _get_spawn_position(weapon_data)
|
||||
var props = fire_helper.compute_standard_props(weapon_data, b, spawn_position, current_time)
|
||||
bullet.position = props.position
|
||||
bullet.angle = props.angle
|
||||
bullet.time_offset = props.time_offset
|
||||
bullet.fire_time = props.fire_time
|
||||
|
||||
# Set the bullet data
|
||||
bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)
|
||||
|
||||
# Offset animation playback per projectile if enabled
|
||||
if weapon_data.stagger_animation:
|
||||
bullet.set_animation_offset(index_from_center * weapon_data.stagger_offset)
|
||||
bullet.set_animation_offset(props.animation_offset)
|
||||
|
||||
# Subtract projectile spacing from current Player travel for next shot
|
||||
player.travel -= weapon_data.spacing
|
||||
|
||||
# Grouped projectile logic (delegates to WeaponFireHelper)
|
||||
func _shoot_grouped(weapon_data: WeaponShot, current_time: float):
|
||||
for group: WeaponProjectileGroup in weapon_data.groups.filter(func(g): return g != null):
|
||||
for b in range(group.bullet_count):
|
||||
var bullet := weapon_data.bullet_scene.instantiate() as Area2D
|
||||
get_tree().root.add_child(bullet)
|
||||
|
||||
# Apply computed properties for the original bullet
|
||||
var spawn_position = _get_spawn_position(weapon_data)
|
||||
var props = fire_helper.compute_grouped_props(group, weapon_data, b, spawn_position, current_time, false)
|
||||
bullet.position = props.position
|
||||
bullet.angle = props.angle
|
||||
bullet.time_offset = props.time_offset
|
||||
bullet.fire_time = props.fire_time
|
||||
bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)
|
||||
if weapon_data.stagger_animation:
|
||||
bullet.set_animation_offset(props.animation_offset)
|
||||
|
||||
# If mirroring is enabled, fire a mirrored copy
|
||||
if group.mirror:
|
||||
var mirror_bullet := weapon_data.bullet_scene.instantiate() as Area2D
|
||||
get_tree().root.add_child(mirror_bullet)
|
||||
|
||||
# Apply computed properties for the mirrored bullet
|
||||
var mirror_spawn = _get_spawn_position(weapon_data)
|
||||
var mirror_props = fire_helper.compute_grouped_props(group, weapon_data, b, mirror_spawn, current_time, true)
|
||||
mirror_bullet.position = mirror_props.position
|
||||
mirror_bullet.angle = mirror_props.angle
|
||||
mirror_bullet.time_offset = mirror_props.time_offset
|
||||
mirror_bullet.fire_time = mirror_props.fire_time
|
||||
mirror_bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)
|
||||
if weapon_data.stagger_animation:
|
||||
mirror_bullet.set_animation_offset(mirror_props.animation_offset)
|
||||
|
|
|
|||
15
scripts/utility/fps_display.gd
Normal file
15
scripts/utility/fps_display.gd
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
extends Label
|
||||
|
||||
var last_time = 0
|
||||
var frame_count = 0
|
||||
var fps = 0
|
||||
|
||||
func _process(delta):
|
||||
frame_count += 1
|
||||
last_time += delta
|
||||
|
||||
if last_time >= 1.0: # Update every second
|
||||
fps = frame_count
|
||||
text = " " + str(fps) + " FPS"
|
||||
last_time = 0
|
||||
frame_count = 0
|
||||
1
scripts/utility/fps_display.gd.uid
Normal file
1
scripts/utility/fps_display.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://eblemtukrey6
|
||||
|
|
@ -2,9 +2,12 @@ class_name WeaponComponent extends Node
|
|||
|
||||
@export var weapon_data: WeaponShot = null
|
||||
@export var available_weapons: Array[WeaponShot] = []
|
||||
@export var weapon_change_flash: BaseEffect = null
|
||||
|
||||
var _current_weapon_index: int = 0
|
||||
|
||||
@onready var effects_component: EffectComponent = %EffectsComponent
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
# Set the default weapon to be stock, i.e. index 1
|
||||
|
|
@ -18,7 +21,7 @@ func _ready() -> void:
|
|||
func _emit_weapon_changed() -> void:
|
||||
var ship: Sprite2D = get_parent().get_node("Ship")
|
||||
var sprite_size = ship.get_rect().size
|
||||
var origin_offset = weapon_data.origin if weapon_data else 0.0
|
||||
var origin_offset: float = weapon_data.origin if weapon_data else 0.0
|
||||
EventBus.weapon_changed.emit(weapon_data.shot_name, get_parent(), sprite_size, origin_offset)
|
||||
|
||||
|
||||
|
|
@ -28,18 +31,24 @@ func get_bullet_scene() -> PackedScene:
|
|||
func get_weapon_resource() -> Resource:
|
||||
return weapon_data
|
||||
|
||||
func select_weapon_by_name(name: String) -> bool:
|
||||
func select_weapon_by_name(weapon_name: String) -> bool:
|
||||
for i in range(available_weapons.size()):
|
||||
if available_weapons[i].shot_name == name:
|
||||
if available_weapons[i].shot_name == weapon_name:
|
||||
_current_weapon_index = i
|
||||
weapon_data = available_weapons[i]
|
||||
print("Switched to: ", name)
|
||||
print("Switched to: ", weapon_name)
|
||||
|
||||
_emit_weapon_changed()
|
||||
_trigger_change_flash()
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _trigger_change_flash() -> void:
|
||||
if weapon_change_flash and effects_component:
|
||||
effects_component.apply_effect(weapon_change_flash)
|
||||
|
||||
|
||||
|
||||
func cycle_weapon() -> void: # Used for testing weapon cycling
|
||||
if available_weapons.is_empty():
|
||||
|
|
@ -50,3 +59,4 @@ func cycle_weapon() -> void: # Used for testing weapon cycling
|
|||
print("Switched to: ", weapon_data.shot_name)
|
||||
|
||||
_emit_weapon_changed()
|
||||
_trigger_change_flash()
|
||||
|
|
|
|||
129
scripts/weapon_fire_helper.gd
Normal file
129
scripts/weapon_fire_helper.gd
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
class_name WeaponFireHelper extends Node
|
||||
|
||||
|
||||
## Compute bullet properties for a standard shot.
|
||||
## Returns a Dictionary with: position, angle, fire_time, time_offset, index_from_center, animation_offset
|
||||
func compute_standard_props(weapon_data: WeaponShot, projectile_index: int, spawn_position: Vector2, current_time: float) -> Dictionary:
|
||||
var total_projectiles: int = weapon_data.projectiles
|
||||
var center_index: float = (total_projectiles - 1) / 2.0
|
||||
|
||||
var index_from_center: float = projectile_index - center_index
|
||||
|
||||
# Horizontal offset (symmetrical: left=-ve, right=+ve)
|
||||
var bullet_horizontal_offset: float = index_from_center * weapon_data.horizontal_offset
|
||||
|
||||
# Timing: center-first, pairs outward
|
||||
var time_offset: float = abs(index_from_center) * weapon_data.stagger_offset
|
||||
|
||||
# Angle (only when projectiles >= 3, division-by-zero guard)
|
||||
# Moved before vertical offset to support compensation
|
||||
var bullet_angle: float = 0.0
|
||||
if total_projectiles >= 3:
|
||||
bullet_angle = (index_from_center / center_index) * (weapon_data.spread_angle / 2.0)
|
||||
|
||||
# Vertical spacing creates the ^ (inverted-V) geometry: outer projectiles fire lower
|
||||
# (higher Y values, further from the player) than the center projectile, which sits
|
||||
# higher on screen (lower Y values). This creates a ^ pattern relative to the origin.
|
||||
# When compensate_spawn_geometry is enabled and spread_angle > 0, compute vertical
|
||||
# offsets to align the geometric spread with velocity vectors.
|
||||
var vertical_offset: float
|
||||
if weapon_data.compensate_spawn_geometry and weapon_data.spread_angle > 0 and total_projectiles >= 3:
|
||||
var velocity_angle_rad: float = abs(bullet_angle) * PI / 180.0
|
||||
if index_from_center == 0:
|
||||
# Center bullet in compensated mode: use full projectile_vertical_spacing
|
||||
# so the V-shape stays visually smooth (center = 35, outer ≈ 75)
|
||||
# instead of a broken gap (center = 8.75, outer ≈ 75).
|
||||
vertical_offset = weapon_data.projectile_vertical_spacing
|
||||
elif velocity_angle_rad > 0.1: # Guard against division by zero for very small angles
|
||||
vertical_offset = abs(bullet_horizontal_offset) / tan(velocity_angle_rad)
|
||||
else:
|
||||
# Very small angle: fall back to full spacing
|
||||
vertical_offset = weapon_data.projectile_vertical_spacing
|
||||
else:
|
||||
vertical_offset = (abs(index_from_center) * weapon_data.projectile_vertical_spacing) / 2.0
|
||||
var position: Vector2 = spawn_position + Vector2(bullet_horizontal_offset, +vertical_offset)
|
||||
|
||||
# Fire time
|
||||
var fire_time: float = current_time + time_offset
|
||||
|
||||
# Animation offset (if staggered animation is enabled)
|
||||
var animation_offset: float = index_from_center * weapon_data.stagger_offset
|
||||
|
||||
return {
|
||||
"position": position,
|
||||
"angle": bullet_angle,
|
||||
"fire_time": fire_time,
|
||||
"time_offset": time_offset,
|
||||
"index_from_center": index_from_center,
|
||||
"animation_offset": animation_offset,
|
||||
}
|
||||
|
||||
|
||||
## Compute bullet properties for a grouped shot, with optional mirroring.
|
||||
## Returns a Dictionary with: position, angle, fire_time, time_offset, index_from_center, animation_offset
|
||||
func compute_grouped_props(group: WeaponProjectileGroup, weapon_data: WeaponShot,
|
||||
bullet_index: int, spawn_position: Vector2, current_time: float,
|
||||
mirror: bool = false) -> Dictionary:
|
||||
var center_index: float = (group.bullet_count - 1) / 2.0
|
||||
var index_from_center: float = bullet_index - center_index
|
||||
|
||||
# Horizontal offset: group offset + within-group spread
|
||||
var bullet_horizontal_offset: float = group.horizontal_offset + index_from_center * group.horizontal_spacing
|
||||
if mirror:
|
||||
bullet_horizontal_offset = -bullet_horizontal_offset
|
||||
|
||||
# Base angle: group angle (negated when mirrored) + within-group spread
|
||||
var bullet_angle: float = group.angle_offset
|
||||
if mirror:
|
||||
bullet_angle = -group.angle_offset
|
||||
|
||||
# Symmetrical spread (guard against < 3 bullets)
|
||||
var spread_contribution: float = 0.0
|
||||
if group.bullet_count >= 3:
|
||||
spread_contribution = (index_from_center / center_index) * (group.spread_angle / 2.0)
|
||||
if mirror:
|
||||
bullet_angle -= spread_contribution
|
||||
else:
|
||||
bullet_angle += spread_contribution
|
||||
|
||||
# Vertical spacing creates the ^ (inverted-V) geometry: outer projectiles fire lower
|
||||
# (higher Y values, further from the player) than the center projectile, which sits
|
||||
# higher on screen (lower Y values). This creates a ^ pattern relative to the origin.
|
||||
# When compensate_spawn_geometry is enabled and group.spread_angle > 0, compute
|
||||
# vertical offsets to preserve the within-group V-shape independently of
|
||||
# angle_offset, which handles global tilt.
|
||||
#
|
||||
# angle_offset tilts the entire group — mixing it into the compensation formula
|
||||
# breaks the V-shape because the formula assumes velocity vectors converge at the
|
||||
# origin, but with angle_offset > 0 they fan out from an offset line instead.
|
||||
# Solution: calculate compensation using only within-group parameters.
|
||||
var vertical_offset: float
|
||||
if weapon_data.compensate_spawn_geometry and group.spread_angle > 0 and group.bullet_count >= 3 and index_from_center != 0:
|
||||
var within_group_angle: float = abs(spread_contribution) # exclude angle_offset
|
||||
var within_group_angle_rad: float = within_group_angle * PI / 180.0
|
||||
var within_group_horizontal: float = abs(index_from_center * group.horizontal_spacing) # exclude group.horizontal_offset
|
||||
if within_group_angle_rad > 0.1: # Guard against division by zero for very small angles
|
||||
vertical_offset = within_group_horizontal / tan(within_group_angle_rad)
|
||||
else:
|
||||
vertical_offset = (abs(index_from_center) * weapon_data.projectile_vertical_spacing) / 2.0
|
||||
else:
|
||||
vertical_offset = (abs(index_from_center) * weapon_data.projectile_vertical_spacing) / 2.0
|
||||
var position: Vector2 = spawn_position + Vector2(bullet_horizontal_offset, +vertical_offset)
|
||||
|
||||
# Timing: group delay + within-group stagger
|
||||
var time_offset: float = group.group_delay + abs(index_from_center) * group.stagger_offset
|
||||
|
||||
# Fire time
|
||||
var fire_time: float = current_time + time_offset
|
||||
|
||||
# Animation offset (if staggered animation is enabled)
|
||||
var animation_offset: float = index_from_center * weapon_data.stagger_offset
|
||||
|
||||
return {
|
||||
"position": position,
|
||||
"angle": bullet_angle,
|
||||
"fire_time": fire_time,
|
||||
"time_offset": time_offset,
|
||||
"index_from_center": index_from_center,
|
||||
"animation_offset": animation_offset,
|
||||
}
|
||||
1
scripts/weapon_fire_helper.gd.uid
Normal file
1
scripts/weapon_fire_helper.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bpcv2ojtyityc
|
||||
23
scripts/weapon_projectile_group.gd
Normal file
23
scripts/weapon_projectile_group.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
class_name WeaponProjectileGroup
|
||||
extends Resource
|
||||
|
||||
@export_category("Identification")
|
||||
@export var pattern_name: String = ""
|
||||
@export_category("Group Settings")
|
||||
@export var bullet_count: int = 3
|
||||
# Horizontal distance between bullets in this group
|
||||
@export var horizontal_spacing: float = 6.5
|
||||
# Total spread angle for bullets in this group (in degrees)
|
||||
@export var spread_angle: float = 0.0
|
||||
# Angle of the entire group from the shot origin (positive = right/up, negative = left)
|
||||
@export var angle_offset: float = 0.0
|
||||
# Horizontal offset from the center line (positive = right, negative = left)
|
||||
@export var horizontal_offset: float = 0.0
|
||||
@export_category("Timing")
|
||||
# Time delay for this group's first bullet (relative to shot start)
|
||||
@export var group_delay: float = 0.0
|
||||
# Stagger delay between bullets within this group
|
||||
@export var stagger_offset: float = 0.25
|
||||
@export_category("Mirroring")
|
||||
# If true, duplicate this group's bullets mirrored across the ship's vertical axis
|
||||
@export var mirror: bool = false
|
||||
1
scripts/weapon_projectile_group.gd.uid
Normal file
1
scripts/weapon_projectile_group.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d0ios82vubijg
|
||||
|
|
@ -1,23 +1,84 @@
|
|||
class_name WeaponShot
|
||||
extends Resource
|
||||
|
||||
@export_category("Parameters")
|
||||
|
||||
@export_group("Weapon")
|
||||
|
||||
|
||||
# Human-readable name for reference in UI and logs.
|
||||
@export var shot_name: String
|
||||
@export var bullet_scene: PackedScene = null
|
||||
@export var damage: int = 1
|
||||
@export var speed: int = 135
|
||||
@export var projectiles: int = 2
|
||||
# Vertical spacing between projectiles
|
||||
@export var spacing: float = 35
|
||||
# Origin offset from center of player
|
||||
@export var origin: int = -23
|
||||
|
||||
@export_category("Spread")
|
||||
# Horizontal distance between projectiles
|
||||
@export var horizontal_offset: float = 6.5
|
||||
# Time delay per projectile index
|
||||
@export var stagger_offset: float = 0.25
|
||||
# PackedScene reference to the bullet / projectile scene instantiated on fire.
|
||||
@export var bullet_scene: PackedScene
|
||||
|
||||
@export_category("Effects")
|
||||
# Offset animation playback per projectile index
|
||||
|
||||
@export_subgroup("Launch")
|
||||
|
||||
|
||||
# Damage dealt by a single projectile instance.
|
||||
@export_range(1, 100, 1) var damage: int = 1
|
||||
|
||||
# Travel speed of projectiles in pixels per second.
|
||||
@export_range(50, 2000, 10) var speed: int = 135
|
||||
|
||||
# Number of projectiles fired in a burst pattern.
|
||||
@export_range(1, 20, 1) var projectiles: int = 2
|
||||
|
||||
|
||||
@export_subgroup("Spawn Geometry")
|
||||
|
||||
|
||||
# Vertical spacing between projectiles in a burst (used by WeaponFireHelper to compute the ^ pattern).
|
||||
# This parameter has a dual role: spatial (computing the ^ burst geometry) and temporal
|
||||
# (serving as the burst-gating threshold in ShootComponent.shoot()). When compensate_spawn_geometry
|
||||
# is enabled, this parameter is overridden by geometric compensation for spatial calculations;
|
||||
# temporal behavior remains unchanged and continues to use this value.
|
||||
@export_range(10, 200, 0.5) var projectile_vertical_spacing: float = 35
|
||||
|
||||
# Vertical offset from the top of the player's sprite where bullets spawn.
|
||||
# Measured in pixels; negative values fire in front of (above) the ship,
|
||||
# positive values fire behind (below) it. The default of -25 places the
|
||||
# burst 25 pixels above the sprite's top edge.
|
||||
@export_range(-200, 200, 0.5) var origin: float = -25.0
|
||||
|
||||
|
||||
@export_subgroup("Spread")
|
||||
|
||||
|
||||
# Horizontal distance between adjacent projectiles in a burst.
|
||||
@export_range(0, 100, 0.25) var horizontal_offset: float = 6.5
|
||||
|
||||
# Total spread angle in degrees (only applied when projectiles >= 3).
|
||||
@export_range(0, 360, 0.5) var spread_angle: float = 0.0
|
||||
|
||||
# Time delay per projectile index in a burst.
|
||||
@export_range(0.01, 5.0, 0.05) var stagger_offset: float = 0.25
|
||||
|
||||
# When enabled, adjusts spawn vertical offsets so the geometric line
|
||||
# from the center bullet to each outer bullet matches their velocity
|
||||
# direction. Eliminates the optical illusion where the spread appears
|
||||
# wider than the actual bullet trajectories (e.g. vanguard+). See the
|
||||
# Debugging Checklist for the vertical offset pitfall on standard shots.
|
||||
## WARNING: This flag uses a trigonometric formula (horizontal_offset / tan(angle)) that evaluates independently-tuned horizontal and spread angles in grouped shots ONLY!
|
||||
@export var compensate_spawn_geometry: bool = false
|
||||
|
||||
|
||||
@export_subgroup("Timing")
|
||||
|
||||
|
||||
# Offset animation playback per projectile index.
|
||||
@export var stagger_animation: bool = false
|
||||
|
||||
|
||||
@export_subgroup("Effects")
|
||||
|
||||
|
||||
# Rotate projectiles to point along their travel direction (requires >2 projectiles and spread_angle > 0).
|
||||
@export var follow_angle: bool = false
|
||||
|
||||
|
||||
@export_subgroup("Groups")
|
||||
|
||||
|
||||
# Array of projectile groups defining layered, multi-directional fire patterns.
|
||||
@export var groups: Array[WeaponProjectileGroup] = []
|
||||
|
|
|
|||
44
shaders/flash.gdshader
Normal file
44
shaders/flash.gdshader
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
// Color of the flash overlay
|
||||
uniform vec4 flash_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Overall intensity of the flash (0.0 = none, 1.0 = full)
|
||||
// Set dynamically by FlashEffect.gd each frame
|
||||
uniform float flash_intensity : hint_range(0.0, 1.0) = 0.0;
|
||||
|
||||
// How the flash blends with the original sprite
|
||||
uniform int blend_mode : hint_enum("Mix", "Additive", "Screen") = 0;
|
||||
|
||||
// Additional brightness added to the flash color (0.0 = none, 1.0 = double)
|
||||
uniform float brightness_boost : hint_range(0.0, 1.0) = 0.0;
|
||||
|
||||
void fragment() {
|
||||
vec4 original = texture(TEXTURE, UV);
|
||||
|
||||
vec3 flash_rgb = flash_color.rgb * (1.0 + brightness_boost);
|
||||
|
||||
vec3 result;
|
||||
float alpha = original.a;
|
||||
|
||||
if (original.a == 0.0) {
|
||||
// Skip processing for fully transparent pixels
|
||||
COLOR = original;
|
||||
} else if (blend_mode == 0) {
|
||||
// Mix: Linear interpolation between original and flash color
|
||||
result = mix(original.rgb, flash_rgb, flash_intensity);
|
||||
// Modulate alpha by flash intensity for a flickering transparency effect
|
||||
alpha = mix(original.a, flash_color.a, flash_intensity);
|
||||
} else if (blend_mode == 1) {
|
||||
// Additive: Flash adds light to the original, clamped to avoid HDR blowout
|
||||
result = clamp(original.rgb + flash_rgb * flash_intensity, 0.0, 1.0);
|
||||
// Additive naturally brightens, so boost alpha when flashing
|
||||
alpha = clamp(original.a + flash_color.a * flash_intensity, 0.0, 1.0);
|
||||
} else {
|
||||
// Screen: Brightens without washing out highlights
|
||||
result = original.rgb + (1.0 - original.rgb) * flash_rgb * flash_intensity;
|
||||
alpha = clamp(original.a + (1.0 - original.a) * flash_color.a * flash_intensity, 0.0, 1.0);
|
||||
}
|
||||
|
||||
COLOR = vec4(result, alpha);
|
||||
}
|
||||
1
shaders/flash.gdshader.uid
Normal file
1
shaders/flash.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dp4svqyxg1dum
|
||||
Loading…
Add table
Add a link
Reference in a new issue