mirror of
https://codeberg.org/Melon-Bread/Comets.gd.git
synced 2025-07-06 22:54:36 -04:00
Initial Commit
This commit is contained in:
8
scripts/bullet.gd
Normal file
8
scripts/bullet.gd
Normal file
@ -0,0 +1,8 @@
|
||||
extends Area2D
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _on_life_timer_timeout() -> void:
|
||||
queue_free()
|
26
scripts/ship.gd
Normal file
26
scripts/ship.gd
Normal file
@ -0,0 +1,26 @@
|
||||
extends Area2D
|
||||
|
||||
@export var max_speed := 1200.0
|
||||
@export var steering_factor := 3.0
|
||||
|
||||
var velocity := Vector2.ZERO
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# TODO: Maybe look into tank controls like classic Astroids
|
||||
var direction := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
if direction.length() > 1.0:
|
||||
direction.normalized()
|
||||
|
||||
var desired_velocity := max_speed * direction
|
||||
var steering := desired_velocity - velocity
|
||||
velocity += steering * steering_factor * delta
|
||||
position += velocity * delta
|
||||
|
||||
if velocity.length() > 0.0:
|
||||
$Sprite2D.rotation = velocity.angle()
|
||||
|
||||
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 fire_gun() -> void:
|
Reference in New Issue
Block a user