cabin-fever/Bullet.gd

24 lines
447 B
GDScript

extends Node2D
var velocity : Vector2 = Vector2.ZERO
var lifetime : float = 3.0
const speed = 300
func _ready():
pass
func init(p_velocity : Vector2):
velocity = p_velocity
func _process(delta):
position += velocity * delta * speed
lifetime -= delta
if lifetime < 0:
queue_free()
func _on_BulletArea_body_entered(body):
if body.has_method("is_player"):
return
if body.has_method("take_damage"):
body.take_damage(1)
queue_free()