-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemyBullet.gd
38 lines (32 loc) · 903 Bytes
/
EnemyBullet.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
extends Area2D
var speed = 1000
var travelling = true;
func _ready():
var bullet_types = $Sprite.frames.get_animation_names()
$Sprite.animation = bullet_types[randi() % bullet_types.size()]
$Rocket.play()
yield(get_tree().create_timer(1.0), "timeout")
$Rocket.stop()
func _physics_process(delta):
if travelling:
position -= transform.x * speed * delta
func _on_EnemyBullet_body_entered(body):
$CollisionShape2D.set_deferred("disabled", true)
$Sprite.hide()
body.plane_died()
travelling = false
$Explosion.play()
$ExplosionSound.play()
yield(get_tree().create_timer(2.0), "timeout")
queue_free()
func _on_EnemyBullet_area_entered(area):
if area.is_in_group("enemies"):
pass
else:
$CollisionShape2D.set_deferred("disabled", true)
$Sprite.hide()
travelling = false
$Explosion.play()
$ExplosionSound.play()
yield(get_tree().create_timer(2.0), "timeout")
queue_free()