Comets.gd/scripts/bullet.gd

23 lines
501 B
GDScript

extends Area2D
@export var speed := 1400.00
var direction := Vector2.UP
var life_span = 0.5
func _ready() -> void:
$LifeTimer.wait_time = life_span
func _physics_process(delta: float) -> void:
# Movement
position += direction.rotated(rotation) * speed * delta
print(rotation)
# Screenwrap
var viewport_size := get_viewport_rect().size
position.x = wrap(position.x, 0, viewport_size.x)
position.y = wrap(position.y, 0,viewport_size.y)
func _on_life_timer_timeout() -> void:
queue_free()