Comets.gd/scripts/bullet.gd

23 lines
526 B
GDScript3
Raw Permalink Normal View History

2024-05-09 22:42:55 -04:00
extends Area2D
2024-05-12 00:07:06 -04:00
@export var speed := 1400.00
var direction := Vector2.UP
var life_span = 0.5
2024-05-16 14:05:08 -04:00
var screen_wrap = true
func _ready() -> void:
$LifeTimer.wait_time = life_span
2024-05-09 22:42:55 -04:00
2024-05-12 00:07:06 -04:00
func _physics_process(delta: float) -> void:
# Movement
position += direction.rotated(rotation) * speed * delta
2024-05-10 20:42:22 -04:00
2024-05-12 00:07:06 -04:00
# Screenwrap
2024-05-16 14:05:08 -04:00
if screen_wrap:
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)
2024-05-09 22:42:55 -04:00
func _on_life_timer_timeout() -> void:
queue_free()