silly sparks thing

This commit is contained in:
Haze Weathers 2025-03-17 04:43:58 -04:00
parent 638495f4a3
commit 68b3e1132f
11 changed files with 172 additions and 8 deletions

View file

@ -0,0 +1,35 @@
extends RigidBody2D
@export var scale_min: float
@export var scale_max: float
@export var velocity_min: float
@export var velocity_max: float
@export_custom(0, "radians_as_degrees") var spin_min: float
@export_custom(0, "radians_as_degrees") var spin_max: float
@export var decay_speed_threshold: float
@export var decay_time: float
var _tween: Tween = null
func _ready() -> void:
var rnd_scale = randf_range(scale_min, scale_max)
$Sprite2D.scale = Vector2.ONE * rnd_scale
linear_velocity = Vector2.from_angle(randf() * TAU) * randf_range(velocity_min, velocity_max)
angular_velocity = randf_range(spin_min, spin_max)
func _physics_process(delta: float) -> void:
if linear_velocity.length() <= decay_speed_threshold:
if _tween:
return
_tween = create_tween().set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
_tween.tween_property(self, ^"scale", Vector2.ZERO, decay_time)
_tween.tween_callback(queue_free)
func _on_solid_detector_body_entered(body: Node2D) -> void:
print("BLEP")