33 lines
868 B
GDScript
33 lines
868 B
GDScript
extends Node2D
|
|
|
|
var hp : int = 6
|
|
@export var hp_bar : AnimatedSprite2D
|
|
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
|
|
|
|
# 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
|
|
|
|
combo_level = clampi(floori(float(combo)/10),0,4)
|
|
Storyteller.current_coin_color = combo_colors[combo_level]
|
|
score_label.text = str(score)
|
|
|
|
|
|
func _on_lander_got_hit() -> void:
|
|
hp -= 1
|
|
combo = 0
|
|
|
|
|
|
func _on_lander_got_points() -> void:
|
|
score += combo_level + 1
|
|
combo += 1
|