-
Notifications
You must be signed in to change notification settings - Fork 0
/
boss.gd
53 lines (40 loc) · 1.09 KB
/
boss.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
extends CharacterBody2D
### easy to kill on a higher level
@export var health = 30
var speed = 200
@onready var player = get_node("/root/Game/%player")
@onready var win = %won_the_game/win
#@onready var win = get_node("/root/Game/%won_the_game/win")
func _ready():
# TODO %Boss.play_walk()
smoke_anim()
func _physics_process(_delta):
call_deferred("_update_player_direction")
%bossBar.value = health
func _update_player_direction():
var direction = global_position.direction_to(player.global_position)
velocity = direction * speed
move_and_slide()
func take_damage():
smoke_anim()
SceneSwitcher.score += 100
health -= 1
### %Boss.play_hurt()
if health <= 0:
killed_the_boss()
die()
func die():
for i in range(0, 10):
smoke_anim()
#queue_free()
func smoke_anim():
const SMOKE_SCENE = preload("res://smoke_explosion/smoke_explosion.tscn")
var smoke = SMOKE_SCENE.instantiate()
get_parent().add_child.call_deferred(smoke)
smoke.global_position = global_position
func restart():
smoke_anim()
queue_free()
func killed_the_boss():
# TODO play You have won animation
win.won_game()