summaryrefslogtreecommitdiffstats
path: root/relic.gd
diff options
context:
space:
mode:
Diffstat (limited to 'relic.gd')
-rw-r--r--relic.gd36
1 files changed, 36 insertions, 0 deletions
diff --git a/relic.gd b/relic.gd
new file mode 100644
index 0000000..6af3405
--- /dev/null
+++ b/relic.gd
@@ -0,0 +1,36 @@
+extends Sprite2D
+
+@onready var top: Top = get_tree().root.get_node("Top")
+@onready var ordinal = int(name.replace("Relic", ""))
+
+var t: float = 0
+const w: float = 5
+const A: float = 1
+
+var oscing = true
+var already_got = false
+
+func _ready():
+ for existing in top.inventory.relics:
+ if existing == ordinal:
+ turn_transparent()
+ already_got = true
+ break
+
+func turn_transparent():
+ modulate.a = 0.3
+
+func _physics_process(delta: float) -> void:
+ if oscing: t += delta
+ offset.y = A * sin(w * t)
+
+func _on_area_2d_body_entered(player: Player) -> void:
+ top.inventory.add_relic(ordinal)
+ top.game_save()
+
+ if already_got:
+ queue_free()
+ else:
+ var dia = DialogueRelicGet.new(self)
+ dia.process_mode = Node.PROCESS_MODE_ALWAYS
+ get_parent().add_child(dia)