2015-06-11 12:55:38 +00:00
|
|
|
|
|
|
|
extends Area2D
|
|
|
|
|
2015-11-21 15:13:43 +00:00
|
|
|
# Member variables
|
|
|
|
const SPEED = -200
|
|
|
|
|
|
|
|
var destroyed=false
|
2015-06-11 12:55:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _process(delta):
|
2015-11-21 15:13:43 +00:00
|
|
|
get_parent().translate(Vector2(SPEED*delta, 0))
|
2015-06-11 12:55:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
func is_enemy():
|
|
|
|
return not destroyed
|
|
|
|
|
|
|
|
|
|
|
|
func destroy():
|
|
|
|
if (destroyed):
|
2015-11-21 15:13:43 +00:00
|
|
|
return
|
|
|
|
destroyed = true
|
2015-06-11 12:55:38 +00:00
|
|
|
get_node("anim").play("explode")
|
2015-11-21 15:13:43 +00:00
|
|
|
set_process(false)
|
2015-06-11 12:55:38 +00:00
|
|
|
get_node("sfx").play("sound_explode")
|
2015-11-21 15:13:43 +00:00
|
|
|
# Accumulate points
|
|
|
|
get_node("/root/game_state").points += 5
|
|
|
|
|
2015-06-11 12:55:38 +00:00
|
|
|
|
|
|
|
func _on_visibility_enter_screen():
|
|
|
|
set_process(true)
|
2015-11-21 15:13:43 +00:00
|
|
|
get_node("anim").play("zigzag")
|
|
|
|
get_node("anim").seek(randf()*2.0) # Make it start from any pos
|
|
|
|
|
2015-06-11 12:55:38 +00:00
|
|
|
|
|
|
|
func _on_visibility_exit_screen():
|
|
|
|
queue_free()
|