AugGodotGameCourse/augustgamecourse/scripts/game_controller.gd

33 lines
675 B
GDScript

extends Node
var coinsCollected:int = 0
var player:Resource
signal playerDeath
signal coinsUpdate(amt)
signal playerHealth(currentHealth)
func _ready() -> void:
print("Game controller is ready")
player = load("res://scripts/resources/player.tres")
func coinCollected():
coinsCollected +=1
print("Game Controller Coin Collected : "+str(coinsCollected))
coinsUpdate.emit(coinsCollected)
func resetPlayer():
player.health = player.max_health
func playerDamage():
#one can not kill what is dead....
if player.health >0:
player.health -= 20
playerHealth.emit(player.health)
#is the player dead?
if player.health <= 0:
#kill him
playerDeath.emit()