Comets.gd/scenes/comet.gd

33 lines
963 B
GDScript3
Raw Normal View History

2024-05-12 00:47:14 -04:00
extends Area2D
# TODO: Have a list of "sizes" a comet can be
# TODO: Have speeds be determined on a rage based on its "size"
# TODO: Provide a specific score based on the "size"
# TODO: Have the comet spawn 2 of the next "size" when hit
# TODO: Have the comet disapear if shot at is smallest "size"
2024-05-12 00:47:14 -04:00
@export var movement_speed := 600
var rotation_speed : int
var rotaion_direction : int
func _ready() -> void:
rotaion_direction = randi_range(-1, 1)
rotation_speed = randi_range(50, 250)
func _physics_process(delta: float) -> void:
rotate(deg_to_rad(rotaion_direction * rotation_speed * delta))
# TODO: Add "floating in space" movement
2024-05-12 01:03:18 -04:00
# 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-12 01:03:18 -04:00
func _on_body_entered(body: Node2D) -> void:
print(body)
# TODO: Add "explosion" logic if bullet hits me
2024-05-12 01:03:18 -04:00
if body.is_in_group("ship"):
body.crash()