ld-39-jam/Bullet.gd

19 lines
386 B
GDScript

extends KinematicBody2D
var velocity = Vector2(1, 0)
var lifetime = 16 # seconds
onready var sprite = get_node("Sprite")
func _ready():
set_fixed_process(true)
func fire(delta, vel, dir, speed):
velocity = (dir * (speed * delta)) + (dir * vel.length())
sprite.rotate(dir.angle())
func _fixed_process(delta):
move(velocity)
lifetime -= delta
if lifetime <= 0:
queue_free()