-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHUD.gd
68 lines (52 loc) · 1.56 KB
/
HUD.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
extends Node2D
# Global Vars
var game_over = false
# Export vars
export var win_score : int
export var GREEN : Color = Color(0.19, 0.67, 0.17, 1.0)
export var ORANGE : Color = Color(0.83, 0.72, 0.16, 1.0)
# Called when the node enters the scene tree for the first time.
func _ready():
print("hud ready!!")
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_tank_hit(dead_tank, live_tank):
if game_over:
return
var score
var score_board
#print("A tank was hit!: ",dead_tank)
if live_tank.name == "Tank1":
score_board = $Player1Score
else:
score_board = $Player2Score
score = score_board.text.to_int() + 1
if score < 10:
score_board.text = "0" + str(score)
else:
score_board.text = str(score)
if score == win_score:
dead_tank.set_game_over(true)
live_tank.set_game_over(true)
game_over = true
if live_tank.name == "Tank1":
#$PlayerWins.set("custom_colors/font_color",GREEN)
$PlayerWins.add_color_override("font_color", GREEN)
$PlayerWins.text = "Green Wins"
else:
#$PlayerWins.set("custom_colors/font_color",ORANGE)
$PlayerWins.add_color_override("font_color", ORANGE)
$PlayerWins.text = "Orange Wins"
$TimerSetup.start()
$PlayerWins.show()
$GameOver.show()
func _on_TimerSetup_timeout():
var myroot = get_tree().get_root()
var tscreen = myroot.get_node("World")
myroot.remove_child(tscreen)
tscreen.call_deferred("free")
# Add the world scene
var world_scene = load("res://TitleScreen.tscn")
var world = world_scene.instance()
myroot.add_child(world)