Initial commit: SpaceshipTest, a top-down space RTS in Godot 4.7.1
A fleet of neon-outlined ships explores a procedurally generated, seeded infinite world: tap/joystick steering, pinch zoom, formation pivoting, planet landings, an ore economy with extractors and haulers, and player built structures (mothership, ship crafter, command centre). All art is hand-drawn with draw_* calls rather than textures, and the backgrounds are camera-relative shaders so they stay precise at large world coordinates. Includes a 35-test headless suite (tests/run_tests.sh) plus screenshot tooling that renders real frames through Xvfb and Mesa softpipe, since --headless has no GPU. Excluded from version control: .godot/ (import cache, and it holds export credentials), builds/, android/build/ and packaged APKs - all regenerable, and ~325 MB combined. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
85814ce88c
192 changed files with 9602 additions and 0 deletions
64
Enemy.gd
Normal file
64
Enemy.gd
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
extends Area2D
|
||||
|
||||
signal destroyed
|
||||
|
||||
@export var speed: float = 140.0
|
||||
@export var acceleration: float = 260.0
|
||||
@export var rotation_speed: float = 6.0
|
||||
@export var max_hp: int = 3
|
||||
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
var hp: int
|
||||
|
||||
@onready var fleet: Node2D = get_node("../Fleet")
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
hp = max_hp
|
||||
add_to_group("enemies")
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var target_pos: Vector2 = _nearest_ship_position()
|
||||
var to_target: Vector2 = target_pos - position
|
||||
|
||||
if to_target.length() > 1.0:
|
||||
var desired_velocity: Vector2 = to_target.normalized() * speed
|
||||
velocity = velocity.move_toward(desired_velocity, acceleration * delta)
|
||||
position += velocity * delta
|
||||
|
||||
if velocity.length() > 5.0:
|
||||
var target_angle: float = velocity.angle() + PI / 2.0
|
||||
rotation = lerp_angle(rotation, target_angle, rotation_speed * delta)
|
||||
|
||||
|
||||
func _nearest_ship_position() -> Vector2:
|
||||
if fleet.ships.is_empty():
|
||||
return position
|
||||
|
||||
var nearest: Node2D = fleet.ships[0]
|
||||
var best_dist: float = position.distance_to(nearest.position)
|
||||
for ship in fleet.ships:
|
||||
var d: float = position.distance_to(ship.position)
|
||||
if d < best_dist:
|
||||
best_dist = d
|
||||
nearest = ship
|
||||
return nearest.position
|
||||
|
||||
|
||||
func take_damage(amount: int) -> void:
|
||||
hp -= amount
|
||||
if hp <= 0:
|
||||
EnemyExplosionVFX.spawn(get_tree().root, position)
|
||||
destroyed.emit()
|
||||
queue_free()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var points: PackedVector2Array = PackedVector2Array([
|
||||
Vector2(0, -16), Vector2(12, 0), Vector2(0, 16), Vector2(-12, 0)
|
||||
])
|
||||
# Constant glow - see Ship.gd. Nothing animates, so no per-frame redraw.
|
||||
NeonDraw.draw_glowing_polygon(self, points, Color(1.0, 0.15, 0.2), 1.0)
|
||||
Loading…
Reference in a new issue