Compare commits
2 commits
ddf3590c96
...
8eb39f4a70
| Author | SHA1 | Date | |
|---|---|---|---|
| 8eb39f4a70 | |||
| 08763960ca |
9 changed files with 85 additions and 30 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=17 format=3 uid="uid://dxsp66qpvm65b"]
|
[gd_scene load_steps=15 format=3 uid="uid://dxsp66qpvm65b"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://q2fys6o0jy6w" path="res://objects/starfield/starfield.tscn" id="1_4oowd"]
|
[ext_resource type="PackedScene" uid="uid://q2fys6o0jy6w" path="res://objects/starfield/starfield.tscn" id="1_4oowd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c714s5d7d5765" path="res://objects/player/player.tscn" id="2_j8ivh"]
|
[ext_resource type="PackedScene" uid="uid://c714s5d7d5765" path="res://objects/player/player.tscn" id="2_j8ivh"]
|
||||||
|
|
@ -7,9 +7,8 @@
|
||||||
[ext_resource type="Script" uid="uid://dntp60my5f65m" path="res://systems/bullets/bullet_behaviors/linear_motion_behavior.gd" id="4_t1bs8"]
|
[ext_resource type="Script" uid="uid://dntp60my5f65m" path="res://systems/bullets/bullet_behaviors/linear_motion_behavior.gd" id="4_t1bs8"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c21fe72aym3fe" path="res://graphics/bullets/normal_bullet/test_bullet.png" id="5_4oowd"]
|
[ext_resource type="Texture2D" uid="uid://c21fe72aym3fe" path="res://graphics/bullets/normal_bullet/test_bullet.png" id="5_4oowd"]
|
||||||
[ext_resource type="Script" uid="uid://vus1a0flwtnm" path="res://systems/bullets/bullet_preset.gd" id="6_sle1e"]
|
[ext_resource type="Script" uid="uid://vus1a0flwtnm" path="res://systems/bullets/bullet_preset.gd" id="6_sle1e"]
|
||||||
[ext_resource type="Script" uid="uid://dtuc6qerbfset" path="res://systems/bullets/spawn_patterns/ring_pattern.gd" id="6_uu3sg"]
|
|
||||||
[ext_resource type="Script" uid="uid://ckedfcjjnv7dq" path="res://systems/bullets/spawn_patterns/spawn_pattern_randomizer.gd" id="7_4oowd"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cgqgb84k38tbe" path="res://graphics/bullets/normal_bullet/test_bullet_overlay.png" id="7_sle1e"]
|
[ext_resource type="Texture2D" uid="uid://cgqgb84k38tbe" path="res://graphics/bullets/normal_bullet/test_bullet_overlay.png" id="7_sle1e"]
|
||||||
|
[ext_resource type="Script" uid="uid://t5lnmlng1vey" path="res://systems/bullets/spawn_patterns/spread_pattern.gd" id="8_sle1e"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_c0i5a"]
|
[sub_resource type="Resource" id="Resource_c0i5a"]
|
||||||
script = ExtResource("4_4oowd")
|
script = ExtResource("4_4oowd")
|
||||||
|
|
@ -20,7 +19,6 @@ metadata/_custom_type_script = "uid://0ognvvq2ncd7"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_t1bs8"]
|
[sub_resource type="Resource" id="Resource_t1bs8"]
|
||||||
script = ExtResource("4_t1bs8")
|
script = ExtResource("4_t1bs8")
|
||||||
initial_speed = 120.0
|
|
||||||
metadata/_custom_type_script = "uid://dntp60my5f65m"
|
metadata/_custom_type_script = "uid://dntp60my5f65m"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_1xo0o"]
|
[sub_resource type="Resource" id="Resource_1xo0o"]
|
||||||
|
|
@ -30,21 +28,12 @@ frames = 2
|
||||||
fps = 10.0
|
fps = 10.0
|
||||||
metadata/_custom_type_script = "uid://0ognvvq2ncd7"
|
metadata/_custom_type_script = "uid://0ognvvq2ncd7"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_4oowd"]
|
[sub_resource type="Resource" id="Resource_uu3sg"]
|
||||||
script = ExtResource("6_uu3sg")
|
script = ExtResource("8_sle1e")
|
||||||
radius = 32.0
|
bullet_count = 3
|
||||||
metadata/_custom_type_script = "uid://dtuc6qerbfset"
|
bullet_speed = 60.0
|
||||||
|
spread = 1.0471975511965976
|
||||||
[sub_resource type="Resource" id="Resource_sle1e"]
|
metadata/_custom_type_script = "uid://t5lnmlng1vey"
|
||||||
script = ExtResource("7_4oowd")
|
|
||||||
pattern = SubResource("Resource_4oowd")
|
|
||||||
property_min_values = Dictionary[StringName, float]({
|
|
||||||
&"direction_rotation": -3.142
|
|
||||||
})
|
|
||||||
property_max_values = Dictionary[StringName, float]({
|
|
||||||
&"direction_rotation": 3.142
|
|
||||||
})
|
|
||||||
metadata/_custom_type_script = "uid://ckedfcjjnv7dq"
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_hxqcc"]
|
[sub_resource type="Resource" id="Resource_hxqcc"]
|
||||||
script = ExtResource("6_sle1e")
|
script = ExtResource("6_sle1e")
|
||||||
|
|
@ -53,9 +42,9 @@ hitbox_size = Vector2i(6, 6)
|
||||||
base_graphics = Array[ExtResource("4_4oowd")]([SubResource("Resource_c0i5a")])
|
base_graphics = Array[ExtResource("4_4oowd")]([SubResource("Resource_c0i5a")])
|
||||||
overlay_graphics = Array[ExtResource("4_4oowd")]([SubResource("Resource_1xo0o")])
|
overlay_graphics = Array[ExtResource("4_4oowd")]([SubResource("Resource_1xo0o")])
|
||||||
colors = Array[Color]([Color(1, 0, 0, 1), Color(0, 0, 1, 1), Color(0, 1, 0, 1), Color(1, 1, 0, 1)])
|
colors = Array[Color]([Color(1, 0, 0, 1), Color(0, 0, 1, 1), Color(0, 1, 0, 1), Color(1, 1, 0, 1)])
|
||||||
pattern = SubResource("Resource_sle1e")
|
pattern = SubResource("Resource_uu3sg")
|
||||||
rounds = 99999999
|
rounds = 99999999
|
||||||
round_delay = 0.5
|
round_delay = 0.2
|
||||||
metadata/_custom_type_script = "uid://vus1a0flwtnm"
|
metadata/_custom_type_script = "uid://vus1a0flwtnm"
|
||||||
|
|
||||||
[node name="TestScene" type="Node"]
|
[node name="TestScene" type="Node"]
|
||||||
|
|
@ -72,6 +61,7 @@ position = Vector2(122, 283)
|
||||||
|
|
||||||
[node name="BulletSet" type="Node2D" parent="."]
|
[node name="BulletSet" type="Node2D" parent="."]
|
||||||
position = Vector2(122, 92)
|
position = Vector2(122, 92)
|
||||||
|
rotation = 1.5707964
|
||||||
script = ExtResource("3_cf1so")
|
script = ExtResource("3_cf1so")
|
||||||
preset = SubResource("Resource_hxqcc")
|
preset = SubResource("Resource_hxqcc")
|
||||||
metadata/_custom_type_script = "uid://cj2fj7snls8aa"
|
metadata/_custom_type_script = "uid://cj2fj7snls8aa"
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,9 @@ static var _hitbox_shapes: Dictionary[Vector2i, RectangleShape2D] = {}
|
||||||
_hitbox_shapes[hitbox_size] = new_shape
|
_hitbox_shapes[hitbox_size] = new_shape
|
||||||
_hitbox.shape = _hitbox_shapes[hitbox_size]
|
_hitbox.shape = _hitbox_shapes[hitbox_size]
|
||||||
|
|
||||||
|
## The speed at which the bullet should travel.
|
||||||
|
@export var speed: float
|
||||||
|
|
||||||
## The direction that the bullet is travelling.
|
## The direction that the bullet is travelling.
|
||||||
@export_custom(0, "direction") var direction: Vector2 = Vector2.RIGHT
|
@export_custom(0, "direction") var direction: Vector2 = Vector2.RIGHT
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,6 @@ extends BulletBehavior
|
||||||
## Makes bullets move in [member Bullet.direction], potentially accelerating.
|
## Makes bullets move in [member Bullet.direction], potentially accelerating.
|
||||||
|
|
||||||
|
|
||||||
## Initial speed of the bullet when it is spawned.
|
|
||||||
@export_custom(0, "suffix:px/s") var initial_speed: float = 0.0
|
|
||||||
|
|
||||||
## Rate at which the bullet will speed up.
|
## Rate at which the bullet will speed up.
|
||||||
@export_custom(0, "suffix:px/s²") var acceleration: float = 0.0
|
@export_custom(0, "suffix:px/s²") var acceleration: float = 0.0
|
||||||
|
|
||||||
|
|
@ -25,7 +22,6 @@ var _bullet_data: Dictionary[Bullet, Data] = {}
|
||||||
|
|
||||||
func _init_bullet(bullet: Bullet) -> void:
|
func _init_bullet(bullet: Bullet) -> void:
|
||||||
var data = Data.new()
|
var data = Data.new()
|
||||||
data.speed = initial_speed
|
|
||||||
_bullet_data[bullet] = data
|
_bullet_data[bullet] = data
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,15 +33,14 @@ func _process_bullet(bullet: Bullet, delta: float) -> void:
|
||||||
if not _bullet_data.has(bullet):
|
if not _bullet_data.has(bullet):
|
||||||
return
|
return
|
||||||
var data = _bullet_data[bullet]
|
var data = _bullet_data[bullet]
|
||||||
data.speed += acceleration * delta
|
bullet.speed += acceleration * delta
|
||||||
if not data.already_clamped and (data.speed <= min_speed or data.speed >= max_speed):
|
if not data.already_clamped and (bullet.speed <= min_speed or bullet.speed >= max_speed):
|
||||||
data.already_clamped = true
|
data.already_clamped = true
|
||||||
if action_speed_clamped:
|
if action_speed_clamped:
|
||||||
action_speed_clamped.perform(bullet)
|
action_speed_clamped.perform(bullet)
|
||||||
data.speed = clampf(data.speed, min_speed, max_speed)
|
bullet.speed = clampf(bullet.speed, min_speed, max_speed)
|
||||||
bullet.position += bullet.direction * data.speed * delta
|
bullet.position += bullet.direction * bullet.speed * delta
|
||||||
|
|
||||||
|
|
||||||
class Data:
|
class Data:
|
||||||
var speed: float
|
|
||||||
var already_clamped: bool = false
|
var already_clamped: bool = false
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ extends BulletSpawnPattern
|
||||||
|
|
||||||
## Number of bullets to spawn along the line.
|
## Number of bullets to spawn along the line.
|
||||||
@export var bullet_count: int
|
@export var bullet_count: int
|
||||||
|
## The speed that bullets will start with.
|
||||||
|
@export var bullet_speed: float
|
||||||
## Distance between the first and last bullet in the line.
|
## Distance between the first and last bullet in the line.
|
||||||
@export var line_width: float
|
@export var line_width: float
|
||||||
## The direction that spawned bullets will travel, orthogonal to the line of bullets.
|
## The direction that spawned bullets will travel, orthogonal to the line of bullets.
|
||||||
|
|
@ -14,6 +16,7 @@ extends BulletSpawnPattern
|
||||||
func _spawn_bullets(bullet_set: BulletSet, preset: BulletPreset) -> void:
|
func _spawn_bullets(bullet_set: BulletSet, preset: BulletPreset) -> void:
|
||||||
for i in bullet_count:
|
for i in bullet_count:
|
||||||
var bullet = Bullet.create(preset, line_normal.rotated(bullet_set.spawn_rotation))
|
var bullet = Bullet.create(preset, line_normal.rotated(bullet_set.spawn_rotation))
|
||||||
|
bullet.speed = bullet_speed
|
||||||
|
|
||||||
var line = line_normal.orthogonal().rotated(bullet_set.spawn_rotation)
|
var line = line_normal.orthogonal().rotated(bullet_set.spawn_rotation)
|
||||||
var weight = float(i) / float(bullet_count - 1)
|
var weight = float(i) / float(bullet_count - 1)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ extends BulletSpawnPattern
|
||||||
|
|
||||||
## The number of bullets to spawn along the circle.
|
## The number of bullets to spawn along the circle.
|
||||||
@export var bullet_count: int = 3
|
@export var bullet_count: int = 3
|
||||||
|
## The speed that bullets will start with.
|
||||||
|
@export var bullet_speed: float
|
||||||
## Radius of the circle that bullets spawn along the edge of.
|
## Radius of the circle that bullets spawn along the edge of.
|
||||||
@export var radius: float
|
@export var radius: float
|
||||||
## Rotation of the entire ring pattern.
|
## Rotation of the entire ring pattern.
|
||||||
|
|
@ -17,5 +19,6 @@ func _spawn_bullets(bullet_set: BulletSet, preset: BulletPreset) -> void:
|
||||||
for i in bullet_count:
|
for i in bullet_count:
|
||||||
var angle = (float(i) / float(bullet_count)) * TAU + angle_offset + bullet_set.spawn_rotation
|
var angle = (float(i) / float(bullet_count)) * TAU + angle_offset + bullet_set.spawn_rotation
|
||||||
var bullet = Bullet.create(preset, Vector2.from_angle(angle + direction_rotation))
|
var bullet = Bullet.create(preset, Vector2.from_angle(angle + direction_rotation))
|
||||||
|
bullet.speed = bullet_speed
|
||||||
bullet.position = bullet_set.spawn_offset + Vector2.from_angle(angle) * radius
|
bullet.position = bullet_set.spawn_offset + Vector2.from_angle(angle) * radius
|
||||||
bullet_set.add_bullet(bullet)
|
bullet_set.add_bullet(bullet)
|
||||||
|
|
|
||||||
32
systems/bullets/spawn_patterns/spawn_pattern_stacker.gd
Normal file
32
systems/bullets/spawn_patterns/spawn_pattern_stacker.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
@tool
|
||||||
|
class_name SpawnPatternStacker
|
||||||
|
extends BulletSpawnPattern
|
||||||
|
## Spawns a pattern in a "stack". The pattern will be spawned multiple
|
||||||
|
## times at once with a varying [code]bullet_speed[/code].
|
||||||
|
|
||||||
|
|
||||||
|
## The subpattern to stack.
|
||||||
|
@export var pattern: BulletSpawnPattern
|
||||||
|
## The number of times to "stack" up the pattern.
|
||||||
|
@export_range(1, 1, 1, "or_greater") var stack_count: int = 1
|
||||||
|
## The minimum speed of the stacked patterns.
|
||||||
|
@export var min_speed: float:
|
||||||
|
set(value):
|
||||||
|
if min_speed != value:
|
||||||
|
min_speed = value
|
||||||
|
max_speed = maxf(min_speed, max_speed)
|
||||||
|
## The maximum speed of the stacked patterns.
|
||||||
|
@export var max_speed: float:
|
||||||
|
set(value):
|
||||||
|
if max_speed != value:
|
||||||
|
max_speed = value
|
||||||
|
min_speed = minf(min_speed, max_speed)
|
||||||
|
|
||||||
|
|
||||||
|
func _spawn_bullets(bullet_set: BulletSet, preset: BulletPreset) -> void:
|
||||||
|
for i in stack_count:
|
||||||
|
pattern.set(
|
||||||
|
&"bullet_speed",
|
||||||
|
remap(float(i), 0.0, float(stack_count - 1), min_speed, max_speed)
|
||||||
|
)
|
||||||
|
pattern.spawn_bullets(bullet_set, preset)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://drxrjgbmeglwp
|
||||||
27
systems/bullets/spawn_patterns/spread_pattern.gd
Normal file
27
systems/bullets/spawn_patterns/spread_pattern.gd
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
class_name SpreadPattern
|
||||||
|
extends BulletSpawnPattern
|
||||||
|
|
||||||
|
|
||||||
|
## Number of bullets to spawn along the spread.
|
||||||
|
@export_range(1, 1, 1, "or_greater") var bullet_count: int
|
||||||
|
## The speed that bullets will start with.
|
||||||
|
@export var bullet_speed: float
|
||||||
|
|
||||||
|
## Angular distance between first and last bullet.
|
||||||
|
@export_range(0.0, 360.0, 0.1, "radians_as_degrees") var spread
|
||||||
|
## Radius of the arc that bullets spawn along the edge of.
|
||||||
|
@export var radius: float
|
||||||
|
## Rotation of the entire pattern.
|
||||||
|
@export_custom(0, "radians_as_degrees") var angle_offset: float
|
||||||
|
## Rotation of each bullet's travel direction.
|
||||||
|
@export_custom(0, "radians_as_degrees") var direction_rotation: float
|
||||||
|
|
||||||
|
|
||||||
|
func _spawn_bullets(bullet_set: BulletSet, preset: BulletPreset) -> void:
|
||||||
|
for i in bullet_count:
|
||||||
|
var angle = remap(float(i), 0.0, float(bullet_count - 1), -spread * 0.5, spread * 0.5)
|
||||||
|
angle += angle_offset + bullet_set.spawn_rotation
|
||||||
|
var bullet = Bullet.create(preset, Vector2.from_angle(angle + direction_rotation))
|
||||||
|
bullet.speed = bullet_speed
|
||||||
|
bullet.position = bullet_set.spawn_offset + Vector2.from_angle(angle) * radius
|
||||||
|
bullet_set.add_bullet(bullet)
|
||||||
1
systems/bullets/spawn_patterns/spread_pattern.gd.uid
Normal file
1
systems/bullets/spawn_patterns/spread_pattern.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://t5lnmlng1vey
|
||||||
Loading…
Add table
Add a link
Reference in a new issue