blob: 204995c05d13b260a5b73d5e9061ab18db51a056 (
plain)
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
|
extends Area2D
# Member variables
const SPEED = -200
var destroyed=false
func _process(delta):
get_parent().translate(Vector2(SPEED*delta, 0))
func is_enemy():
return not destroyed
func destroy():
if (destroyed):
return
destroyed = true
get_node("anim").play("explode")
set_process(false)
get_node("sfx").play("sound_explode")
# Accumulate points
get_node("/root/game_state").points += 5
func _on_visibility_enter_screen():
set_process(true)
get_node("anim").play("zigzag")
get_node("anim").seek(randf()*2.0) # Make it start from any pos
func _on_visibility_exit_screen():
queue_free()
|