Lunar/logic.gd

34 lines
868 B
GDScript3
Raw Normal View History

2025-07-20 17:33:13 +10:00
extends Node2D
var hp : int = 6
@export var hp_bar : AnimatedSprite2D
2025-11-30 00:49:23 +11:00
var score : int = 0
var combo : int = 0 # number of coins collected without taking damage
var combo_level : int = 0 # 0-4, coins worth: 1, 2, 3, 4, 5
# combo levels: 10/20/30/40/50 (max)
@export var combo_colors : Array[Color]
@export var score_label : Label
2025-07-20 17:33:13 +10:00
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
hp_bar.frame = hp
2025-11-30 00:49:23 +11:00
combo_level = clampi(floori(float(combo)/10),0,4)
Storyteller.current_coin_color = combo_colors[combo_level]
score_label.text = str(score)
2025-07-20 17:33:13 +10:00
func _on_lander_got_hit() -> void:
hp -= 1
2025-11-30 00:49:23 +11:00
combo = 0
func _on_lander_got_points() -> void:
score += combo_level + 1
combo += 1