bm-frontend-defence/Source/attacker.gd

27 lines
700 B
GDScript3

extends Sprite
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
export (Vector2) var target = null
export (int) var speed = 1
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if target != null:
position = position.move_toward(target, delta * speed)
if (position - target).length() < 50:
get_tree().change_scene("res://gameover.tscn")
func _input(event):
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
if (event.position - position).length() < 50:
remove_and_skip()