2015-06-11 12:55:38 +00:00
|
|
|
|
|
|
|
extends Area2D
|
|
|
|
|
2015-11-21 15:13:43 +00:00
|
|
|
# Member variables
|
2015-06-11 12:55:38 +00:00
|
|
|
const SPEED = 800
|
|
|
|
|
2015-11-21 15:13:43 +00:00
|
|
|
var hit = false
|
|
|
|
|
|
|
|
|
2015-06-11 12:55:38 +00:00
|
|
|
func _process(delta):
|
2015-11-21 15:13:43 +00:00
|
|
|
translate(Vector2(delta*SPEED, 0))
|
|
|
|
|
2015-06-11 12:55:38 +00:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
set_process(true)
|
|
|
|
|
|
|
|
|
|
|
|
func _hit_something():
|
|
|
|
if (hit):
|
|
|
|
return
|
2015-11-21 15:13:43 +00:00
|
|
|
hit = true
|
2015-06-11 12:55:38 +00:00
|
|
|
set_process(false)
|
|
|
|
get_node("anim").play("splash")
|
|
|
|
|
2015-11-21 15:13:43 +00:00
|
|
|
|
2015-06-11 12:55:38 +00:00
|
|
|
func _on_visibility_exit_screen():
|
|
|
|
queue_free()
|
|
|
|
|
|
|
|
|
2015-11-21 15:13:43 +00:00
|
|
|
func _on_shot_area_enter(area):
|
|
|
|
# Hit an enemy or asteroid
|
2015-06-11 12:55:38 +00:00
|
|
|
if (area.has_method("destroy")):
|
2015-11-21 15:13:43 +00:00
|
|
|
# Duck typing at it's best
|
2015-06-11 12:55:38 +00:00
|
|
|
area.destroy()
|
|
|
|
_hit_something()
|
|
|
|
|
|
|
|
|
2015-11-21 15:13:43 +00:00
|
|
|
func _on_shot_body_enter(body):
|
|
|
|
# Hit the tilemap
|
2015-06-11 12:55:38 +00:00
|
|
|
_hit_something()
|