2017-07-30 19:46:44 +01:00
|
|
|
extends KinematicBody2D
|
|
|
|
|
2017-07-30 21:25:42 +01:00
|
|
|
var velocity = Vector2(1, 0)
|
|
|
|
var lifetime = 16 # seconds
|
|
|
|
|
|
|
|
onready var sprite = get_node("Sprite")
|
|
|
|
|
2017-07-30 19:46:44 +01:00
|
|
|
func _ready():
|
|
|
|
set_fixed_process(true)
|
|
|
|
|
2017-07-30 21:49:58 +01:00
|
|
|
func fire(delta, vel, dir, speed):
|
2017-07-30 22:47:29 +01:00
|
|
|
velocity = (vel.length() * dir + (dir * speed * delta))
|
2017-07-30 21:49:58 +01:00
|
|
|
sprite.rotate(dir.angle())
|
2017-08-01 22:28:11 +01:00
|
|
|
|
|
|
|
func type():
|
2017-08-09 21:54:24 +01:00
|
|
|
return "Bullet"
|
2017-07-30 22:47:29 +01:00
|
|
|
|
2017-07-30 19:46:44 +01:00
|
|
|
func _fixed_process(delta):
|
2017-08-01 22:28:11 +01:00
|
|
|
|
2017-07-30 21:49:58 +01:00
|
|
|
move(velocity)
|
2017-07-30 21:25:42 +01:00
|
|
|
lifetime -= delta
|
2017-08-01 22:28:11 +01:00
|
|
|
|
|
|
|
if is_colliding():
|
|
|
|
var e = get_collider()
|
|
|
|
|
2017-07-30 21:25:42 +01:00
|
|
|
if lifetime <= 0:
|
2017-07-30 21:49:58 +01:00
|
|
|
queue_free()
|