Fronter/Laser.gd

54 lines
1.0 KiB
GDScript3
Raw Normal View History

extends Area2D
signal hit
export (int) var SPEED
export (int) var DAMAGE
var plasma = false
var current_pen = 0
var friendly_laser = true
func _on_Visibility_screen_exited():
prints("byebye laser boi")
queue_free()
func _ready():
$AnimatedSprite.play()
connect("area_entered", self, "hit")
pass
func hit(who):
prints(who)
if plasma == true:
pass
elif current_pen > 0:
current_pen -= 1
else:
hide()
queue_free()
func _process(delta):
var velocity = Vector2()
if friendly_laser == true:
velocity.x += 1
else:
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