50 lines
938 B
GDScript
50 lines
938 B
GDScript
extends Area2D
|
|
|
|
signal hit
|
|
|
|
export (int) var SPEED
|
|
export (int) var DAMAGE
|
|
var plasma = false
|
|
var current_pen = 0
|
|
|
|
func _on_Visibility_screen_exited():
|
|
prints("byebye laser boi")
|
|
queue_free()
|
|
|
|
func _ready():
|
|
$AnimatedSprite.play()
|
|
connect("area_entered", self, "hit")
|
|
pass
|
|
|
|
func hit(who):
|
|
|
|
if plasma == true:
|
|
pass
|
|
elif current_pen > 0:
|
|
current_pen -= 1
|
|
else:
|
|
hide()
|
|
queue_free()
|
|
|
|
func _process(delta):
|
|
var velocity = Vector2()
|
|
velocity.x += 1
|
|
velocity = velocity.normalized() * SPEED
|
|
position += velocity * delta
|
|
|
|
func _on_Laser_body_entered(body):
|
|
emit_signal("hit")
|
|
if plasma == false:
|
|
$CollisionShape2D.disabled = true
|
|
queue_free()
|
|
else:
|
|
var timer = null
|
|
timer = Timer.new()
|
|
timer.set_one_shot(true)
|
|
timer.set_wait_time(0.1)
|
|
timer.connect("timeout", self, "on_timeout_complete")
|
|
add_child(timer)
|
|
$CollisionShape2D.disabled = true
|
|
|
|
func on_timeout_complete():
|
|
$CollisionShape2D.disabled = false |