Compare commits
4 commits
main
...
feature-pr
| Author | SHA1 | Date | |
|---|---|---|---|
| f427bb0c8d | |||
| a9af69e7bb | |||
| 029175ccde | |||
| 54efa89e4e |
65 changed files with 371 additions and 1398 deletions
|
|
@ -1,8 +1,8 @@
|
|||
extends Area2D
|
||||
|
||||
@onready var bullet: PackedScene = load("res://scenes/player_weapons/weapon_stock.tscn")
|
||||
@onready var bullet: PackedScene = load("res://scenes/weapon_stock.tscn")
|
||||
|
||||
@onready var shot_data: = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
|
||||
@onready var shot_data: = load("res://resources/player_weapons/weapon_shot_stock.tres")
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
|
|
|||
83
Scratch
Normal file
83
Scratch
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
@export_category("Stagger")
|
||||
@export var horizontal_offset: float = 6.5 # Horizontal distance between projectiles
|
||||
@export var stagger_offset: float = 5 # Time delay per projectile index
|
||||
@export var firing_angle: float = 0.0 # Angle in degrees (0 = straight up, positive = angled right)
|
||||
@export var num_groups: int = 1 # Number of symmetrical groups to fire (1 = single direction, 2 = left/right, 3 = left/center/right)
|
||||
|
||||
|
||||
---
|
||||
|
||||
func shoot():
|
||||
var weapon_data = weapon_component.data # WeaponShot resource configuration
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
var total_projectiles = weapon_data.projectiles
|
||||
|
||||
if player.travel > weapon_data.spacing:
|
||||
|
||||
# Calculate center index for symmetrical staggering
|
||||
var center_index = (total_projectiles - 1) / 2.0
|
||||
|
||||
if total_projectiles > 0:
|
||||
for group in range(num_groups):
|
||||
# Calculate projectile indices for this group
|
||||
# For 1 group: 0..N-1
|
||||
# For 2 groups: 0..N/2-1 and N/2..N-1
|
||||
# For 3 groups: 0..N/3-1 and N/3..2N/3-1 and 2N/3..N-1
|
||||
var group_start: int
|
||||
var group_end: int
|
||||
|
||||
if num_groups == 1:
|
||||
group_start = 0
|
||||
group_end = total_projectiles
|
||||
elif num_groups == 2:
|
||||
group_start = 0
|
||||
group_end = total_projectiles / 2 if total_projectiles % 2 == 0 else (total_projectiles - 1) / 2
|
||||
elif num_groups == 3:
|
||||
var third = total_projectiles / 3
|
||||
group_start = 0
|
||||
group_end = third if third > 0 else 1
|
||||
else:
|
||||
continue # Skip if num_groups > 3
|
||||
|
||||
for b in range(group_start, group_end):
|
||||
var bullet_scene = weapon_data.bullet_scene
|
||||
var bullet := bullet_scene.instantiate() as Node
|
||||
get_tree().root.add_child(bullet)
|
||||
|
||||
# Calculate index relative to group center for staggering
|
||||
var group_center: float = (group_start + group_end - 1) / 2.0
|
||||
var index_from_center: float = b - group_center
|
||||
|
||||
# Calculate timing offset for staggered firing
|
||||
var time_offset: float = abs(index_from_center) * stagger_offset
|
||||
|
||||
# Calculate horizontal offset for this bullet (symmetrical within group)
|
||||
var bullet_horizontal_offset: float = index_from_center * weapon_data.horizontal_offset
|
||||
|
||||
# Calculate vertical offset from center point (symmetrical vertical spread within group)
|
||||
var distance_from_center: float = abs(index_from_center)
|
||||
var vertical_offset: float = (distance_from_center * weapon_data.origin * -1) / 2
|
||||
|
||||
# Calculate final position based on firing angle using polar coordinates
|
||||
var angle_rad: float = weapon_data.firing_angle * 0.0174533 # Convert degrees to radians
|
||||
var spread_angle: float = -firing_angle * 0.0174533 # Spread opposite to firing angle
|
||||
|
||||
# Calculate position using polar coordinates from player origin
|
||||
var origin_x: float = weapon_data.origin * 0.5 # Distribute origin horizontally
|
||||
var origin_y: float = weapon_data.origin
|
||||
|
||||
var pos_x: float = player.position.x + origin_x + bullet_horizontal_offset
|
||||
var pos_y: float = player.position.y + origin_y + vertical_offset
|
||||
|
||||
# Apply angular offset
|
||||
var angle_offset_x: float = -weapon_data.origin * sin(spread_angle)
|
||||
var angle_offset_y: float = -weapon_data.origin * cos(spread_angle)
|
||||
|
||||
bullet.position = Vector2(pos_x + angle_offset_x, pos_y + angle_offset_y)
|
||||
|
||||
# Set timing properties on the bullet
|
||||
bullet.time_offset = time_offset
|
||||
bullet.fire_time = current_time + time_offset
|
||||
|
||||
# Subtract projectile spacing from current Player travel for next shot
|
||||
player.travel -= weapon_data.spacing
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 259 B |
|
|
@ -1,40 +0,0 @@
|
|||
[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
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 256 B |
|
|
@ -1,40 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dtggedl0127vk"
|
||||
path="res://.godot/imported/stock.png-0cb798b4967b33f195d444f0ce113e61.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graphics/stock.png"
|
||||
dest_files=["res://.godot/imported/stock.png-0cb798b4967b33f195d444f0ce113e61.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
|
||||
BIN
graphics/tri.png
BIN
graphics/tri.png
Binary file not shown.
|
Before Width: | Height: | Size: 271 B |
|
|
@ -1,40 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cne450xyao5xl"
|
||||
path="res://.godot/imported/tri.png-6a3868cfc07d960f5a88b231524dc08e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graphics/tri.png"
|
||||
dest_files=["res://.godot/imported/tri.png-6a3868cfc07d960f5a88b231524dc08e.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
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 254 B |
|
|
@ -1,40 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b34vaaw3u84ae"
|
||||
path="res://.godot/imported/vanguard.png-294c61db0141993beb875af311f8a1e3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graphics/vanguard.png"
|
||||
dest_files=["res://.godot/imported/vanguard.png-294c61db0141993beb875af311f8a1e3.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
|
||||
|
|
@ -12,19 +12,14 @@ config_version=5
|
|||
|
||||
config/name="Facsimile Wing"
|
||||
run/main_scene="uid://bj4fytc3sy482"
|
||||
config/features=PackedStringArray("4.7", "Forward Plus")
|
||||
run/max_fps=60
|
||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
EventBus="*uid://bv56i5pud2p3x"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=208
|
||||
window/size/viewport_width=216
|
||||
window/size/viewport_height=384
|
||||
window/size/window_width_override=1248
|
||||
window/size/window_width_override=1296
|
||||
window/size/window_height_override=2304
|
||||
window/subwindows/embed_subwindows=false
|
||||
window/stretch/mode="viewport"
|
||||
|
|
@ -57,11 +52,6 @@ shoot={
|
|||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
cycle={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
[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"
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
[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
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
[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
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
[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
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
[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,15 +0,0 @@
|
|||
[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]
|
||||
script = ExtResource("2_ym48c")
|
||||
shot_name = "stock"
|
||||
bullet_scene = ExtResource("1_lcw6o")
|
||||
damage = 2
|
||||
speed = 650
|
||||
horizontal_offset = 12.0
|
||||
stagger_offset = 0.0
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
[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]
|
||||
script = ExtResource("2_syw6j")
|
||||
shot_name = "tri"
|
||||
bullet_scene = ExtResource("1_07hyh")
|
||||
damage = 3
|
||||
speed = 700
|
||||
projectiles = 3
|
||||
horizontal_offset = 12.5
|
||||
stagger_offset = 0.35
|
||||
stagger_animation = true
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
[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"
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="WeaponShot" format=3 uid="uid://bhc6aja38vyr"]
|
||||
|
||||
[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")
|
||||
shot_name = "vanguard"
|
||||
bullet_scene = ExtResource("1_hm46f")
|
||||
damage = 5
|
||||
speed = 500
|
||||
projectiles = 5
|
||||
horizontal_offset = 8.25
|
||||
stagger_offset = 0.5
|
||||
stagger_animation = true
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
17
resources/player_weapon_resources/weapon_shot_stock.tres
Normal file
17
resources/player_weapon_resources/weapon_shot_stock.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[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_by0nb"]
|
||||
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://resources/weapon_shot.gd" id="2_by0nb"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_by0nb")
|
||||
shot_name = "Stock Shot"
|
||||
bullet_scene = ExtResource("1_by0nb")
|
||||
speed = 500
|
||||
projectiles = 5
|
||||
spacing = 20.0
|
||||
origin = -25
|
||||
horizontal_offset = 6.0
|
||||
stagger_offset = 5.5
|
||||
rotate_to_velocity = false
|
||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||
20
resources/weapon_shot.gd
Normal file
20
resources/weapon_shot.gd
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
class_name WeaponShot extends Resource
|
||||
|
||||
@export_category("Info")
|
||||
@export var shot_name: String
|
||||
@export var bullet_scene: PackedScene = null
|
||||
|
||||
@export_category("Shot Data")
|
||||
@export var damage: int = 1
|
||||
@export var speed: int = 135
|
||||
@export var projectiles: int = 2
|
||||
@export var spacing: float = 35
|
||||
@export var origin: int = -23
|
||||
|
||||
@export_category("Stagger")
|
||||
@export var horizontal_offset: float = 6.5 # Horizontal distance between projectiles
|
||||
@export var stagger_offset: float = 5 # Time delay per projectile index
|
||||
|
||||
# Angle in degrees, default is 0
|
||||
@export var angle: float = 0.0 # Angle at which the bullet should be fired
|
||||
@export var rotate_to_velocity: bool = true
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[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")
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
[gd_scene format=3 uid="uid://c3scm07fgpkcp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://3a0cypjsx5cq" path="res://scripts/notification_display.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://dtggedl0127vk" path="res://graphics/stock.png" id="2_nqp5d"]
|
||||
|
||||
[node name="NotificationDisplay" type="Control" unique_id=1 node_paths=PackedStringArray("icon", "label")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1")
|
||||
icon = NodePath("HBoxContainer/Icon")
|
||||
label = NodePath("HBoxContainer/Label")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=228546504]
|
||||
layout_mode = 1
|
||||
theme_override_constants/separator = 4
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="HBoxContainer" unique_id=3]
|
||||
custom_minimum_size = Vector2(16, 16)
|
||||
custom_maximum_size = Vector2(16, 16)
|
||||
propagate_maximum_size = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
texture = ExtResource("2_nqp5d")
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer" unique_id=4]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
text = "Weapon name"
|
||||
vertical_alignment = 1
|
||||
uppercase = true
|
||||
|
||||
[node name="Background" type="ColorRect" parent="." unique_id=2]
|
||||
z_index = -1
|
||||
layout_mode = 0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.4117647, 0.4117647, 0.41568628, 1)
|
||||
|
|
@ -19,10 +19,6 @@ 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,8 +46,3 @@ func _process(delta) -> void:
|
|||
# Read Movement Component
|
||||
movement_component.input = input_component.move_dir
|
||||
movement_component.tick(delta)
|
||||
|
||||
# Cycle weapon (testing key)
|
||||
if input_component.cycle_weapon:
|
||||
weapon_component.cycle_weapon()
|
||||
$EffectsComponent.apply_effect(flash_effect)
|
||||
|
|
|
|||
|
|
@ -6,16 +6,8 @@
|
|||
[ext_resource type="Script" uid="uid://dss0dbwr71y6m" path="res://scripts/input_component.gd" id="4_smehm"]
|
||||
[ext_resource type="Texture2D" uid="uid://b0iavxi8vaxtj" path="res://graphics/ship_thrusters.png" id="5_qlg0r"]
|
||||
[ext_resource type="Script" uid="uid://c0rikbakpcags" path="res://scripts/movement_component.gd" id="5_ur7pv"]
|
||||
[ext_resource type="Script" uid="uid://suynuijl68qp" path="res://scripts/shoot_component.gd" id="6_y4r1p"]
|
||||
[ext_resource type="Script" uid="uid://bgd1hwindc2ui" path="res://scripts/shoot_component.gd" id="6_y4r1p"]
|
||||
[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")
|
||||
|
|
@ -42,7 +34,7 @@ animations = [{
|
|||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fjrip")
|
||||
}],
|
||||
"loop": 1,
|
||||
"loop": true,
|
||||
"name": &"banked",
|
||||
"speed": 15.0
|
||||
}, {
|
||||
|
|
@ -53,7 +45,7 @@ animations = [{
|
|||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ur7pv")
|
||||
}],
|
||||
"loop": 1,
|
||||
"loop": true,
|
||||
"name": &"fwd",
|
||||
"speed": 15.0
|
||||
}]
|
||||
|
|
@ -82,7 +74,7 @@ animations = [{
|
|||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_d2wvv")
|
||||
}],
|
||||
"loop": 1,
|
||||
"loop": true,
|
||||
"name": &"stock",
|
||||
"speed": 15.0
|
||||
}]
|
||||
|
|
@ -96,10 +88,11 @@ 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")
|
||||
can_shoot = null
|
||||
is_shooting = null
|
||||
muzzle_flash = null
|
||||
|
||||
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -152,26 +145,14 @@ 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")
|
||||
metadata/_custom_type_script = "uid://bgd1hwindc2ui"
|
||||
|
||||
[node name="WeaponComponent" type="Node" parent="." unique_id=1648685183]
|
||||
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"), 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"]
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
[gd_scene format=3 uid="uid://clpyd8qfwthk2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c5blhfopjpfny" path="res://scenes/player_weapons/weapon_stock.gd" id="1_nx6aw"]
|
||||
[ext_resource type="Texture2D" uid="uid://bnpm8b62n1pr5" path="res://graphics/shot_stock_og.png" id="2_s6ult"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5bykt"]
|
||||
atlas = ExtResource("2_s6ult")
|
||||
region = Rect2(0, 0, 7, 11)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vsqoq"]
|
||||
atlas = ExtResource("2_s6ult")
|
||||
region = Rect2(7, 0, 7, 11)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yqx5m"]
|
||||
atlas = ExtResource("2_s6ult")
|
||||
region = Rect2(14, 0, 7, 11)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_fdubj"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_5bykt")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vsqoq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_yqx5m")
|
||||
}],
|
||||
"loop": 1,
|
||||
"name": &"default",
|
||||
"speed": 24.0
|
||||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
|
||||
size = Vector2(6.666667, 14)
|
||||
|
||||
[node name="StockWeapon" type="Area2D" unique_id=1832200900]
|
||||
script = ExtResource("1_nx6aw")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1831184252]
|
||||
scale = Vector2(1.5, 1.5)
|
||||
sprite_frames = SubResource("SpriteFrames_fdubj")
|
||||
autoplay = "default"
|
||||
frame_progress = 0.35886022
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1890946059]
|
||||
shape = SubResource("RectangleShape2D_mvdrj")
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="." unique_id=985862716]
|
||||
rect = Rect2(-3, -7, 6, 14)
|
||||
|
||||
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
extends Area2D
|
||||
|
||||
# Data to be set externally when this bullet is instantiated
|
||||
var bullet_scene: PackedScene = null
|
||||
var shot_data: WeaponShot = null
|
||||
@onready var shot_data = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
|
||||
|
||||
# Time offset when this bullet was fired (relative to other bullets in the same shot)
|
||||
var time_offset: float = 0.5
|
||||
|
|
@ -10,12 +8,15 @@ 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
|
||||
|
||||
# Angle at which this bullet should fire (in degrees)
|
||||
var angle: float = 0.0
|
||||
|
||||
# Whether to rotate bullet to face its movement direction
|
||||
var rotate_to_velocity: bool = true
|
||||
|
||||
func _process(delta):
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
|
||||
|
|
@ -23,47 +24,31 @@ func _process(delta):
|
|||
if !is_active and current_time >= fire_time:
|
||||
activate()
|
||||
|
||||
# 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
|
||||
# Calculate the movement vector based on speed, angle, and delta
|
||||
var angle_rad = deg_to_rad(angle)
|
||||
var move_x = cos(angle_rad) * shot_data.speed * delta
|
||||
var move_y = sin(angle_rad) * shot_data.speed * delta
|
||||
|
||||
# Move the bullet
|
||||
position.x += move_x
|
||||
position.y += move_y
|
||||
|
||||
# Rotate to face movement direction - ensure proper rotation calculation
|
||||
if rotate_to_velocity:
|
||||
var velocity = Vector2(cos(angle_rad) * shot_data.speed, sin(angle_rad) * shot_data.speed)
|
||||
rotation = velocity.angle()
|
||||
|
||||
# Debug output - this will show you what's really happening
|
||||
print("Bullet angle: ", angle, "Velocity angle:", velocity.angle(), "Rotation set to:", rotation)
|
||||
|
||||
# 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
|
||||
visible = true
|
||||
|
||||
# # Emit signal for hit detection
|
||||
# emit_signal("activate")
|
||||
|
||||
func _on_visible_on_screen_notifier_2d_screen_exited():
|
||||
queue_free()
|
||||
|
||||
# Set fire_time for the next shot (staggered firing)
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
fire_time = current_time + shot_data.stagger_offset
|
||||
|
||||
# Function to set the bullet data (called from parent scene)
|
||||
func set_weapon_data(bullet_scene_param: PackedScene, shot_data_param: WeaponShot):
|
||||
bullet_scene = bullet_scene_param
|
||||
shot_data = shot_data_param
|
||||
|
||||
# Function to offset animation playback for staggered visual effect
|
||||
func set_animation_offset(offset: float) -> void:
|
||||
var sprite = $AnimatedSprite2D
|
||||
if sprite:
|
||||
var frames = sprite.sprite_frames
|
||||
if frames:
|
||||
var animation = sprite.animation
|
||||
var frame_count = frames.get_frame_count(animation)
|
||||
if frame_count > 0:
|
||||
# Calculate average frame duration from actual frame timings
|
||||
var total_duration = 0.0
|
||||
for i in range(frame_count):
|
||||
total_duration += frames.get_frame_duration(animation, i)
|
||||
var avg_frame_duration = total_duration / frame_count
|
||||
# Convert time offset to frame offset, wrap within animation length
|
||||
var frame_offset = fposmod(offset / avg_frame_duration, float(frame_count))
|
||||
sprite.frame = int(frame_offset)
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ animations = [{
|
|||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_yqx5m")
|
||||
}],
|
||||
"loop": 1,
|
||||
"loop": true,
|
||||
"name": &"default",
|
||||
"speed": 24.0
|
||||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
|
||||
size = Vector2(10, 16)
|
||||
size = Vector2(6.666667, 14)
|
||||
|
||||
[node name="StockWeapon" type="Area2D" unique_id=1832200900]
|
||||
script = ExtResource("1_u1d5o")
|
||||
|
|
|
|||
54
scenes/player_weapons/weapon_stock_fixed.gd
Normal file
54
scenes/player_weapons/weapon_stock_fixed.gd
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
extends Area2D
|
||||
|
||||
@onready var shot_data = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
|
||||
|
||||
# Time offset when this bullet was fired (relative to other bullets in the same shot)
|
||||
var time_offset: float = 0.5
|
||||
|
||||
# When this bullet should fire (absolute time)
|
||||
var fire_time: float = 0.0
|
||||
|
||||
# Track if this bullet is currently active in the shot
|
||||
var is_active: bool = false
|
||||
|
||||
# Angle at which this bullet should fire (in degrees)
|
||||
var angle: float = 0.0
|
||||
|
||||
# Whether to rotate bullet to face its movement direction
|
||||
var rotate_to_velocity: bool = true
|
||||
|
||||
func _process(delta):
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
|
||||
# Fire if it's time and bullet isn't already active
|
||||
if !is_active and current_time >= fire_time:
|
||||
activate()
|
||||
|
||||
# Calculate the movement vector based on speed, angle, and delta
|
||||
var angle_rad = deg_to_rad(angle)
|
||||
var move_x = cos(angle_rad) * shot_data.speed * delta
|
||||
var move_y = sin(angle_rad) * shot_data.speed * delta
|
||||
|
||||
# Move the bullet
|
||||
position.x += move_x
|
||||
position.y += move_y
|
||||
|
||||
# Rotate to face movement direction - ensure proper rotation calculation
|
||||
if rotate_to_velocity:
|
||||
var velocity = Vector2(cos(angle_rad) * shot_data.speed, sin(angle_rad) * shot_data.speed)
|
||||
rotation = velocity.angle()
|
||||
|
||||
# Debug output - this will show you what's really happening
|
||||
print("Bullet angle: ", angle, "Velocity angle:", velocity.angle(), "Rotation set to:", rotation)
|
||||
|
||||
|
||||
func activate():
|
||||
is_active = true
|
||||
visible = true
|
||||
|
||||
func _on_visible_on_screen_notifier_2d_screen_exited():
|
||||
queue_free()
|
||||
|
||||
# Set fire_time for the next shot (staggered firing)
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
fire_time = current_time + shot_data.stagger_offset
|
||||
1
scenes/player_weapons/weapon_stock_fixed.gd.uid
Normal file
1
scenes/player_weapons/weapon_stock_fixed.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://7wuopfptd3qe
|
||||
54
scenes/player_weapons/weapon_stock_fixed2.gd
Normal file
54
scenes/player_weapons/weapon_stock_fixed2.gd
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
extends Area2D
|
||||
|
||||
@onready var shot_data = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
|
||||
|
||||
# Time offset when this bullet was fired (relative to other bullets in the same shot)
|
||||
var time_offset: float = 0.5
|
||||
|
||||
# When this bullet should fire (absolute time)
|
||||
var fire_time: float = 0.0
|
||||
|
||||
# Track if this bullet is currently active in the shot
|
||||
var is_active: bool = false
|
||||
|
||||
# Angle at which this bullet should fire (in degrees)
|
||||
var angle: float = 0.0
|
||||
|
||||
# Whether to rotate bullet to face its movement direction
|
||||
var rotate_to_velocity: bool = true
|
||||
|
||||
func _process(delta):
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
|
||||
# Fire if it's time and bullet isn't already active
|
||||
if !is_active and current_time >= fire_time:
|
||||
activate()
|
||||
|
||||
# Calculate the movement vector based on speed, angle, and delta
|
||||
var angle_rad = deg_to_rad(angle)
|
||||
var move_x = cos(angle_rad) * shot_data.speed * delta
|
||||
var move_y = sin(angle_rad) * shot_data.speed * delta
|
||||
|
||||
# Move the bullet
|
||||
position.x += move_x
|
||||
position.y += move_y
|
||||
|
||||
# Rotate to face movement direction - ensure proper rotation calculation
|
||||
if rotate_to_velocity:
|
||||
var velocity = Vector2(cos(angle_rad) * shot_data.speed, sin(angle_rad) * shot_data.speed)
|
||||
rotation = velocity.angle()
|
||||
|
||||
# Debug output - this will show you what's really happening
|
||||
print("Bullet angle: ", angle, "Velocity angle:", velocity.angle(), "Rotation set to:", rotation)
|
||||
|
||||
|
||||
func activate():
|
||||
is_active = true
|
||||
visible = true
|
||||
|
||||
func _on_visible_on_screen_notifier_2d_screen_exited():
|
||||
queue_free()
|
||||
|
||||
# Set fire_time for the next shot (staggered firing)
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
fire_time = current_time + shot_data.stagger_offset
|
||||
1
scenes/player_weapons/weapon_stock_fixed2.gd.uid
Normal file
1
scenes/player_weapons/weapon_stock_fixed2.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c1u6yrjkp26i5
|
||||
|
|
@ -1,34 +1,20 @@
|
|||
[gd_scene format=3 uid="uid://bj4fytc3sy482"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://14fhj8834pkq" path="res://scenes/ui.tscn" id="1_nnsk1"]
|
||||
[ext_resource type="Script" uid="uid://boce4kgerpff2" path="res://scripts/notification_manager.gd" id="2_k0juu"]
|
||||
[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]
|
||||
|
||||
[node name="UI" parent="." unique_id=480295610 instance=ExtResource("1_nnsk1")]
|
||||
|
||||
[node name="NotificationManager" type="Node" parent="UI" unique_id=1222543367]
|
||||
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="UI" parent="Level" unique_id=480295610 instance=ExtResource("1_nnsk1")]
|
||||
|
||||
[node name="Background" type="Node2D" parent="Level" unique_id=485120278]
|
||||
z_index = -1
|
||||
|
||||
[node name="BaseBackground" type="ColorRect" parent="Level/Background" unique_id=1360709800]
|
||||
offset_right = 208.0
|
||||
offset_right = 217.0
|
||||
offset_bottom = 410.0
|
||||
color = Color(0.2899925, 0.5692833, 0.9110645, 1)
|
||||
|
||||
|
|
@ -46,7 +32,7 @@ hframes = 4
|
|||
frame = 1
|
||||
|
||||
[node name="CloudRight" type="Sprite2D" parent="Level/Background/Back" unique_id=1729409543]
|
||||
position = Vector2(168, 32)
|
||||
position = Vector2(177, 32)
|
||||
texture = ExtResource("3_4wyf3")
|
||||
flip_h = true
|
||||
hframes = 4
|
||||
|
|
@ -66,7 +52,7 @@ hframes = 4
|
|||
frame = 2
|
||||
|
||||
[node name="CloudRight" type="Sprite2D" parent="Level/Background/Mid" unique_id=702118355]
|
||||
position = Vector2(168, 32)
|
||||
position = Vector2(177, 32)
|
||||
texture = ExtResource("3_4wyf3")
|
||||
flip_h = true
|
||||
hframes = 4
|
||||
|
|
@ -85,7 +71,7 @@ hframes = 4
|
|||
frame = 3
|
||||
|
||||
[node name="CloudRight" type="Sprite2D" parent="Level/Background/Fore" unique_id=1798342457]
|
||||
position = Vector2(176, 32)
|
||||
position = Vector2(185, 32)
|
||||
texture = ExtResource("3_4wyf3")
|
||||
flip_h = true
|
||||
hframes = 4
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
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 +0,0 @@
|
|||
uid://cs7xpxd1vpl56
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
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 +0,0 @@
|
|||
uid://cj4grtaun2h5a
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
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 +0,0 @@
|
|||
uid://deak7vcr7ss5l
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
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 +0,0 @@
|
|||
uid://65d3hbrpm21x
|
||||
|
|
@ -2,6 +2,5 @@ extends Node
|
|||
|
||||
@warning_ignore_start("unused_signal") # since otherwise Godot will throw a warning that the signal is unused in current scope
|
||||
|
||||
signal weapon_changed(weapon_name: String, player_node: Node2D, player_sprite_size: Vector2, origin_offset: float)
|
||||
|
||||
@warning_ignore_restore("unused_signal")
|
||||
@warning_ignore_restore("unused_signal") # put any future signals you add between the two ignore annotations
|
||||
|
|
|
|||
|
|
@ -3,12 +3,9 @@ class_name InputComponent extends Node
|
|||
var move_dir: Vector2 = Vector2.ZERO
|
||||
var shoot_pressed: bool = false
|
||||
var shooting: bool = false
|
||||
var cycle_weapon: bool = false
|
||||
|
||||
|
||||
func update() -> void:
|
||||
move_dir = Input.get_vector("left", "right", "up", "down")
|
||||
shoot_pressed = Input.is_action_just_pressed("shoot")
|
||||
shooting = Input.is_action_pressed("shoot")
|
||||
|
||||
# Development Keys
|
||||
cycle_weapon = Input.is_action_just_pressed("cycle")
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ func tick(delta: float):
|
|||
if player == null: return
|
||||
|
||||
# Shorten variable for accessing weapon_component for clarity
|
||||
var weapon_system = weapon_component.weapon_data
|
||||
var weapon_system = weapon_component.data
|
||||
|
||||
# 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.projectile_vertical_spacing)
|
||||
player.travel = clamp(player.travel, 0, 1.9 * weapon_system.spacing)
|
||||
|
||||
# Thruster animation in relation to player movement
|
||||
if input.x > 0:
|
||||
|
|
@ -30,19 +30,16 @@ 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
|
||||
|
|
|
|||
|
|
@ -1,170 +0,0 @@
|
|||
class_name NotificationDisplay extends Control
|
||||
|
||||
@export var icon: TextureRect
|
||||
@export var label: Label
|
||||
@onready var _container: HBoxContainer = $HBoxContainer
|
||||
|
||||
var _player: Node2D = null
|
||||
var _sprite_size: Vector2 = Vector2.ZERO
|
||||
var _origin_offset: float = 0.0
|
||||
var _follow_player: bool = false
|
||||
|
||||
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
|
||||
|
||||
# Auto-load icon from graphics folder matching the weapon name
|
||||
var icon_path = "res://graphics/" + weapon_name.to_lower() + ".png"
|
||||
if ResourceLoader.exists(icon_path):
|
||||
icon.texture = load(icon_path)
|
||||
else:
|
||||
icon.texture = null
|
||||
|
||||
_player = player_node
|
||||
_player.tree_exiting.connect(queue_free)
|
||||
_sprite_size = player_sprite_size
|
||||
_origin_offset = origin_offset
|
||||
_follow_player = false # Disable movement for testing
|
||||
|
||||
# Wait one frame for layout to resolve shrink-to-fit widths
|
||||
await get_tree().process_frame
|
||||
|
||||
# Use container's natural width, but fix height at 16px
|
||||
size = Vector2(_container.size.x, 16.0)
|
||||
|
||||
# Calculate target position
|
||||
_update_position()
|
||||
var target_pos = position
|
||||
|
||||
# Start 10px above destination (already transparent from line 17)
|
||||
position.y = target_pos.y - 10.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 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)
|
||||
|
||||
# Wait for fade-in to finish, then resume following
|
||||
await tween.finished
|
||||
_follow_player = true
|
||||
|
||||
# Stay fully visible for a moment before fading
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
|
||||
# Record current position as the fade-out starting point
|
||||
await get_tree().process_frame
|
||||
var fade_start_y = position.y
|
||||
|
||||
# Fade out and drift downward with steady acceleration
|
||||
_follow_player = false
|
||||
var fade_out = create_tween().set_parallel()
|
||||
fade_out.tween_property(self, "modulate:a", 0.0, .35)
|
||||
var drift = fade_out.tween_property(self, "position:y", fade_start_y + 7, .3)
|
||||
drift.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
await fade_out.finished
|
||||
queue_free()
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if _follow_player and _player:
|
||||
_update_position()
|
||||
if _connector_visible and _player:
|
||||
_update_connector()
|
||||
|
||||
|
||||
func _update_position() -> void:
|
||||
if _player == null:
|
||||
return
|
||||
|
||||
var player_pos = _player.position
|
||||
|
||||
# Y position uses the weapon origin offset from player center
|
||||
var notif_y = player_pos.y + _origin_offset - (size.y / 2.0)
|
||||
|
||||
# X position is 10px to the right of player's sprite edge
|
||||
var right_edge = player_pos.x + (_sprite_size.x / 2.0)
|
||||
var notif_x = right_edge + 10.0
|
||||
|
||||
var is_flipped = false
|
||||
|
||||
# Clamp to screen bounds — flip to left if it would go off-screen right
|
||||
var viewport_size = get_viewport_rect().size
|
||||
if notif_x + size.x > viewport_size.x:
|
||||
is_flipped = true
|
||||
var left_edge = player_pos.x - (_sprite_size.x / 2.0)
|
||||
notif_x = left_edge - 10.0 - size.x
|
||||
|
||||
# Swap icon/label order so the icon is always closest to the player
|
||||
if is_flipped:
|
||||
_container.move_child(label, 0)
|
||||
_container.move_child(icon, 1)
|
||||
else:
|
||||
_container.move_child(icon, 0)
|
||||
_container.move_child(label, 1)
|
||||
|
||||
# Final clamp: ensure the entire notification is within screen bounds
|
||||
notif_x = clamp(notif_x, 0, viewport_size.x - size.x)
|
||||
notif_y = clamp(notif_y, 0, viewport_size.y - size.y)
|
||||
|
||||
position = Vector2(notif_x, notif_y)
|
||||
|
||||
|
||||
func _update_connector() -> void:
|
||||
if _connector_line == null or _player == null:
|
||||
return
|
||||
|
||||
# Icon position in the notification's local space
|
||||
var icon_pos = _container.position + icon.position
|
||||
var icon_mid_y = icon_pos.y + icon.size.y / 2.0
|
||||
|
||||
# Point 0: edge of the container closest to the icon, at icon's vertical midpoint
|
||||
var point0: Vector2
|
||||
var direction: float
|
||||
|
||||
if _container.get_child(0) == icon:
|
||||
# Icon on the left (not flipped) — container's left edge, line goes left toward player
|
||||
point0 = Vector2(_container.position.x, icon_mid_y)
|
||||
direction = -1.0
|
||||
else:
|
||||
# Icon on the right (flipped) — container's right edge, line goes right toward player
|
||||
point0 = Vector2(_container.position.x + _container.size.x, icon_mid_y)
|
||||
direction = 1.0
|
||||
|
||||
# Point 1: 8px straight from point 0 toward the player
|
||||
const SEGMENT_ORIGIN: float = 8.0 # length of initial segment from origin
|
||||
var point1 = Vector2(point0.x + SEGMENT_ORIGIN * direction, icon_mid_y)
|
||||
|
||||
# Point 2: player's origin + ENDPOINT_OFFSET, converted to notification's local space
|
||||
const ENDPOINT_OFFSET = Vector2(4, 7) # offset from player's origin to connector endpoint
|
||||
var target = _player.position + Vector2(+ENDPOINT_OFFSET.x, _origin_offset + ENDPOINT_OFFSET.y)
|
||||
var point2 = target - position
|
||||
|
||||
_connector_line.points = PackedVector2Array([point0, point1, point2])
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://3a0cypjsx5cq
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
class_name NotificationManager extends Node
|
||||
|
||||
@export var notification_scene: PackedScene
|
||||
|
||||
var _active_notification: NotificationDisplay = null
|
||||
|
||||
func _ready() -> void:
|
||||
EventBus.weapon_changed.connect(_on_weapon_changed)
|
||||
|
||||
|
||||
func _on_weapon_changed(weapon_name: String, player_node: Node2D, player_sprite_size: Vector2, origin_offset: float) -> void:
|
||||
if notification_scene == null:
|
||||
return
|
||||
|
||||
# Free any existing notification so the new one can fade in cleanly
|
||||
if _active_notification:
|
||||
_active_notification.queue_free()
|
||||
_active_notification = null
|
||||
|
||||
var notification = notification_scene.instantiate()
|
||||
add_child(notification)
|
||||
_active_notification = notification
|
||||
notification.show_notification(weapon_name, player_node, player_sprite_size, origin_offset)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://boce4kgerpff2
|
||||
|
|
@ -1,90 +1,67 @@
|
|||
class_name ShootComponent extends Node
|
||||
|
||||
@export var stagger_offset: float = 0.5 # Time delay per projectile index (seconds)
|
||||
@export var horizontal_offset: float = 1.0 # Horizontal distance per projectile index
|
||||
|
||||
@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 weapon_data = weapon_component.data # WeaponShot resource configuration
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
var total_projectiles = weapon_data.projectiles
|
||||
|
||||
if player.travel > weapon_data.projectile_vertical_spacing:
|
||||
_shoot_standard(weapon_data, current_time)
|
||||
_shoot_grouped(weapon_data, current_time)
|
||||
if player.travel > weapon_data.spacing:
|
||||
|
||||
# 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
|
||||
# Calculate center index for symmetrical staggering
|
||||
var center_index = (total_projectiles - 1) / 2.0
|
||||
|
||||
if total_projectiles > 0:
|
||||
for b in range(total_projectiles):
|
||||
var bullet := weapon_data.bullet_scene.instantiate() as Area2D
|
||||
var bullet_scene = weapon_data.bullet_scene
|
||||
var bullet := bullet_scene.instantiate() as Node2D
|
||||
get_tree().root.add_child(bullet)
|
||||
|
||||
# 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
|
||||
# Calculate index relative to center (0 = center, -1/+1 = first from center)
|
||||
var index_from_center: float = b - center_index
|
||||
|
||||
# Set the bullet data
|
||||
bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)
|
||||
# Calculate timing offset for staggered firing
|
||||
var time_offset: float = index_from_center * weapon_data.stagger_offset
|
||||
|
||||
# Offset animation playback per projectile if enabled
|
||||
if weapon_data.stagger_animation:
|
||||
bullet.set_animation_offset(props.animation_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 fixed vertical offset from weapon origin
|
||||
bullet.position = player.position + Vector2(bullet_horizontal_offset, weapon_data.origin)
|
||||
|
||||
# Set timing properties on the bullet
|
||||
bullet.time_offset = time_offset
|
||||
bullet.fire_time = current_time + time_offset
|
||||
|
||||
# Set bullet rotation properties
|
||||
bullet.rotate_to_velocity = weapon_data.rotate_to_velocity # This should be true if you want rotation
|
||||
|
||||
|
||||
# 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)
|
||||
# Set the angle for bullets - symmetrical spread around vertical (straight up = -90°)
|
||||
if weapon_data.angle == 0:
|
||||
# If angle is 0, all projectiles fire straight up
|
||||
bullet.angle = -90.0
|
||||
else:
|
||||
# Set angle for bullets - symmetrical spread around vertical (straight up = -90°)
|
||||
if index_from_center == 0:
|
||||
# Center projectile fires straight up
|
||||
bullet.angle = -90.0
|
||||
else:
|
||||
# Left projectiles: positive angle (up and to the left), Right projectiles: negative angle (up and to the right)
|
||||
bullet.angle = -90.0 + weapon_data.angle * sign(index_from_center)
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
# Subtract projectile spacing from current Player travel for next shot
|
||||
player.travel -= weapon_data.spacing
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://suynuijl68qp
|
||||
uid://bgd1hwindc2ui
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
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 +0,0 @@
|
|||
uid://eblemtukrey6
|
||||
|
|
@ -1,62 +1,9 @@
|
|||
class_name WeaponComponent extends Node
|
||||
|
||||
@export var weapon_data: WeaponShot = null
|
||||
@export var available_weapons: Array[WeaponShot] = []
|
||||
@export var weapon_change_flash: BaseEffect = null
|
||||
@export var loaded_weapon: PackedScene = load("res://scenes/player_weapons/weapon_stock.tscn")
|
||||
var data : WeaponShot = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
|
||||
|
||||
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
|
||||
if weapon_data and not available_weapons.is_empty():
|
||||
for i in range(available_weapons.size()):
|
||||
if available_weapons[i] == weapon_data:
|
||||
_current_weapon_index = i
|
||||
return
|
||||
|
||||
|
||||
func _emit_weapon_changed() -> void:
|
||||
var ship: Sprite2D = get_parent().get_node("Ship")
|
||||
var sprite_size = ship.get_rect().size
|
||||
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)
|
||||
|
||||
|
||||
func get_bullet_scene() -> PackedScene:
|
||||
return weapon_data.bullet_scene if weapon_data else null
|
||||
|
||||
func get_weapon_resource() -> Resource:
|
||||
return weapon_data
|
||||
|
||||
func select_weapon_by_name(weapon_name: String) -> bool:
|
||||
for i in range(available_weapons.size()):
|
||||
if available_weapons[i].shot_name == weapon_name:
|
||||
_current_weapon_index = i
|
||||
weapon_data = available_weapons[i]
|
||||
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():
|
||||
return
|
||||
|
||||
_current_weapon_index = (_current_weapon_index + 1) % available_weapons.size()
|
||||
weapon_data = available_weapons[_current_weapon_index]
|
||||
print("Switched to: ", weapon_data.shot_name)
|
||||
|
||||
_emit_weapon_changed()
|
||||
_trigger_change_flash()
|
||||
return data.weapon_shot # Reference to the Shot scene from the resource
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
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 +0,0 @@
|
|||
uid://bpcv2ojtyityc
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
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 +0,0 @@
|
|||
uid://d0ios82vubijg
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
class_name WeaponShot
|
||||
extends Resource
|
||||
|
||||
|
||||
@export_group("Weapon")
|
||||
|
||||
|
||||
# Human-readable name for reference in UI and logs.
|
||||
@export var shot_name: String
|
||||
|
||||
# PackedScene reference to the bullet / projectile scene instantiated on fire.
|
||||
@export var bullet_scene: PackedScene
|
||||
|
||||
|
||||
@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] = []
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
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 +0,0 @@
|
|||
uid://dp4svqyxg1dum
|
||||
25
test_rotation.gd
Normal file
25
test_rotation.gd
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
extends Area2D
|
||||
|
||||
# Simple test to verify rotation behavior
|
||||
var test_angle: float = 0.0
|
||||
var rotate_to_velocity: bool = true
|
||||
|
||||
func _process(delta):
|
||||
# Move in a straight line at 100 pixels per second
|
||||
var move_x = cos(deg_to_rad(test_angle)) * 100 * delta
|
||||
var move_y = sin(deg_to_rad(test_angle)) * 100 * delta
|
||||
|
||||
position.x += move_x
|
||||
position.y += move_y
|
||||
|
||||
# Rotate to face movement direction (this is the key fix)
|
||||
if rotate_to_velocity:
|
||||
var velocity = Vector2(cos(deg_to_rad(test_angle)) * 100, sin(deg_to_rad(test_angle)) * 100)
|
||||
rotation = velocity.angle()
|
||||
|
||||
# Debug output
|
||||
print("Test angle: ", test_angle, "Velocity angle:", velocity.angle(), "Rotation set to:", rotation)
|
||||
|
||||
func _ready():
|
||||
# Set initial rotation for testing
|
||||
test_angle = 0.0
|
||||
1
test_rotation.gd.uid
Normal file
1
test_rotation.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b1bhb673ef5po
|
||||
6
test_rotation.tscn
Normal file
6
test_rotation.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene format=3 uid="uid://d4ls4srw6qyap"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1rwqotmrag1r" path="res://test_rotation.gd" id="1_kx6bj"]
|
||||
|
||||
[node name="TestRotation" type="Area2D" unique_id=1832200900]
|
||||
script = ExtResource("1_kx6bj")
|
||||
Loading…
Add table
Add a link
Reference in a new issue