ld-39-jam/Bullet.gd

19 lines
386 B
GDScript3
Raw Normal View History

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):
velocity = (dir * (speed * delta)) + (dir * vel.length())
sprite.rotate(dir.angle())
2017-07-30 21:25:42 +01:00
2017-07-30 19:46:44 +01:00
func _fixed_process(delta):
2017-07-30 21:49:58 +01:00
move(velocity)
2017-07-30 21:25:42 +01:00
lifetime -= delta
if lifetime <= 0:
2017-07-30 21:49:58 +01:00
queue_free()