spaceship/Planet.gd
Loïc Wisniewski 85814ce88c 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>
2026-08-10 18:41:58 +02:00

39 lines
1.6 KiB
GDScript

extends Node2D
# A landable world-object - unlike regular Asteroid.gd, planets are
# stationary ("Big Stable Asteroid" - stable means it doesn't drift or
# destroy ships on touch). Whether the fleet counts as "landed" is decided
# by PlanetField comparing the fleet's CENTROID distance to landing_radius,
# not per-ship Area2D collision - a single stable number, immune to the
# constant minor jostling of individual ships holding formation, which
# used to make the "enter atmosphere" prompt flicker on/off as ships
# drifted in and out of the boundary independently of each other even
# while the fleet as a whole was clearly sitting on the planet.
@export var planet_name: String = ""
@export var planet_type: String = "big_stable_asteroid"
@export var landing_radius: float = 140.0
# Set by whoever spawns this planet (PlanetField, seeded from the chunk's
# own coordinates) so the outline shape is stable across respawns of the
# same chunk, instead of reading as a "different" planet every time.
@export var shape_seed: int = 0
var shape_points: PackedVector2Array = PackedVector2Array()
func _ready() -> void:
add_to_group("planets")
z_index = -1
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
rng.seed = shape_seed
var point_count: int = 10
for i in range(point_count):
var angle: float = (float(i) / point_count) * TAU
var radius: float = rng.randf_range(70.0, 100.0)
shape_points.append(Vector2(cos(angle), sin(angle)) * radius)
queue_redraw()
func _draw() -> void:
NeonDraw.draw_glowing_polygon(self, shape_points, Color(0.6, 0.55, 0.5), 1.0)