1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-25 00:54:19 +00:00
swear-jar/converters/converter.gd

47 lines
1.1 KiB
GDScript3
Raw Normal View History

2023-10-02 00:53:12 +00:00
extends StaticBody2D
2023-10-02 01:14:45 +00:00
class_name Converter
2023-10-02 00:53:12 +00:00
var coda : int = 0
@export var sprite_front: AnimatedSprite2D
2023-10-02 14:32:23 +00:00
@export var sprite_back: AnimatedSprite2D
2023-10-02 00:53:12 +00:00
@export var conversion_timer: Timer
@export var sound_working: AudioStreamPlayer
@export var sound_complete: AudioStreamPlayer
@export var spawner: Spawner
func _on_collector_goal():
coda+=1
func _process(_delta):
if coda>=1 and conversion_timer.is_stopped():
sprite_front.play()
2023-10-02 15:10:23 +00:00
if not sprite_back==null:
sprite_back.play()
2023-10-02 00:53:12 +00:00
conversion_timer.start()
sound_working.play()
func _on_timer_timeout():
coda-=1
sprite_front.stop()
2023-10-02 15:10:23 +00:00
if not sprite_back==null:
sprite_back.stop()
2023-10-02 00:53:12 +00:00
sound_working.stop()
sound_complete.play()
spawner.spawn()
2023-10-02 18:06:28 +00:00
var is_pending_deletion: bool = false
func pending_deletion():
sprite_front.modulate = Color.RED
is_pending_deletion = true
func ending_deletion():
sprite_front.modulate = Color.WHITE
is_pending_deletion = false
2023-10-02 19:42:07 +00:00
func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int):
2023-10-02 18:06:28 +00:00
if is_pending_deletion:
if event is InputEventMouseButton or event is InputEventScreenTouch:
queue_free()