/
Main.gd
59 lines (32 loc) · 892 Bytes
/
Main.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
extends Node2D
export (PackedScene) var Player
export (PackedScene) var Zombie
var score
func _ready():
# connect('update_health', $Player, update_health)
new_game()
# randomize()
func _process(delta):
pass
func new_game():
score = 0
$HUD.update_score(score)
# $HUD/StartButton.hide()
# $StartTimer.start()
var player = Player.instance()
add_child(player)
player.start($StartPosition.position)
$HUD.update_health(player.health)
player.connect('update_health', self, 'on_update_health')
player.connect('death', self, 'on_death')
# $HUD.show_message("Get Ready")
var zombie = Zombie.instance()
add_child(zombie)
zombie.player_collision_shapes = player.PLAYER_COLLISION_SHAPES
func game_over():
$HUD.show_game_over()
func on_update_health(value):
# print('on_update_health'+str(value))
$HUD.update_health(value)
func on_death():
game_over()