Basic structure stuff for player health

This commit is contained in:
karl committed 2020-02-01 12:10:36 +01:00
1 parent 9d0bf18030
commit 3646d1efb1
2 files changed
+106

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
extends Node
var max_health = 100.0
var player_healths = []
var player_count: int
signal player_win(player_id)
signal player_count_updated(new_player_count)
func set_player_count(new_player_count: int):
assert(new_player_count <= 4)
player_count = new_player_count
player_healths = []
for i in range(0, player_count):
player_healths.append(max_health)
emit_signal("player_count_updated", new_player_count)
func subtract_player_health(player_id, subtractor):
assert(player_id < player_count)
assert(player_id >= 0)
player_healths[player_id] -= subtractor
if player_healths[player_id] < 0.0:
emit_signal("player_win", player_id)