AugGodotGameCourse/augustgamecourse/scripts/game_controller.gd

32 lines
594 B
GDScript3
Raw Normal View History

2024-10-01 10:04:10 +00:00
extends Node
var coinsCollected:int = 0
var player:Resource
signal playerDeath
2024-10-07 18:24:38 +00:00
signal playerHurt
2024-10-01 10:04:10 +00:00
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))
func resetPlayer():
player.health = player.max_health
func playerDamage():
2024-10-02 00:16:45 +00:00
#one can not kill what is dead....
2024-10-01 23:56:32 +00:00
if player.health >0:
player.health -= 20
2024-10-02 00:16:45 +00:00
#is the player dead?
if player.health <= 0:
#kill him
playerDeath.emit()
2024-10-07 18:24:38 +00:00
else:
playerHurt.emit()
2024-10-01 10:04:10 +00:00