NovemberGodotGame/fabigame/scripts/game_controller.gd

35 lines
707 B
GDScript

extends Node
var coinsCollected:int = 0
var player:Resource
signal playerHurt()
signal playerDeath()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
player = load("res://scripts/res/dudestats.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 collected "+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