NovemberGodotGame2024/novembergame/scripts/game_controller.gd

35 lines
716 B
GDScript

extends Node
var coinsCollected:int = 0
var player:Resource
signal playerHurt(amt)
signal playerDeath()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
player = load("res://scripts/res/playerstats.tres")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func coinCollected():
coinsCollected += 1
print("Total coins collecte " + str(coinsCollected))
func playerDamage():
if player.health > 0:
player.health -= 20
if player.health <= 0:
## kill him
playerDeath.emit()
else:
## damage him
playerHurt.emit(20)
func reset():
player.health = player.max_health
coinsCollected = 0