Adds lightning projectile
Implements a lightning projectile with visual effects. The lightning is created using a series of bolt components that dynamically adjust their shape. Also refactors the projectile system to use a base class. Removes unused modifiers from player script.
This commit is contained in:
parent
ff62d67f54
commit
d0c2a7b3c8
12 changed files with 239 additions and 103 deletions
|
|
@ -31,7 +31,7 @@ func _init() -> void:
|
|||
add_child(fire_timer)
|
||||
fire_timer.one_shot = true
|
||||
|
||||
projectile_scene = preload("res://assets/projectiles/basic_projectile.tscn")
|
||||
projectile_scene = preload("res://assets/projectiles/projectile_lightning.tscn")
|
||||
|
||||
func _ready():
|
||||
stats.connect("stats_updated", _on_stats_updated)
|
||||
|
|
@ -40,16 +40,16 @@ func _ready():
|
|||
# Initial update
|
||||
_on_stats_updated()
|
||||
|
||||
func fire(direction: Vector2):
|
||||
func fire(direction: Vector2, target_position: Vector2):
|
||||
if !can_fire:
|
||||
return
|
||||
|
||||
_spawn_projectile(global_position, direction)
|
||||
_spawn_projectile(global_position, direction, target_position)
|
||||
|
||||
can_fire = false
|
||||
fire_timer.start(1.0 / stats.get_stat("fire_rate"))
|
||||
|
||||
func _spawn_projectile(spawn_position: Vector2, spawn_direction: Vector2):
|
||||
func _spawn_projectile(spawn_position: Vector2, spawn_direction: Vector2, target_position: Vector2):
|
||||
# Get projectile quantity and spread from stats
|
||||
var quantity = stats.get_stat("projectile_quantity")
|
||||
var spread_angle = stats.get_stat("projectile_spread")
|
||||
|
|
@ -66,6 +66,7 @@ func _spawn_projectile(spawn_position: Vector2, spawn_direction: Vector2):
|
|||
for i in range(quantity):
|
||||
var projectile = projectile_scene.instantiate()
|
||||
projectile.global_position = spawn_position
|
||||
projectile.target_position = target_position
|
||||
|
||||
# Calculate the direction with spread
|
||||
var direction = spawn_direction
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue