summaryrefslogtreecommitdiff
path: root/fireball.gd
blob: 74df7b54862b470848e324c1f88642f42c36c65b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
extends Area2D

var velocity: Vector2

func _ready() -> void:
	$ShotSound.play()


func type() -> String: return "arrow"


func damage(other: Area2D) -> void:
	other.damage(1.5)
	queue_free()
	get_node("../FireballHit").play()


func _physics_process(_delta: float) -> void:
	position += velocity
	velocity *= 0.9
	rotation += velocity.length()
	if velocity.length() < 0.001: queue_free()
	if position.x < -Globals.WIDTH / 2. or position.y < -Globals.HEIGHT / 2. or \
	   position.x > Globals.WIDTH / 2. or position.y > Globals.HEIGHT / 2.:
		queue_free()