From a53c19b350938736eb5b381118e28d3ef6ef4283 Mon Sep 17 00:00:00 2001 From: Tangent Date: Thu, 27 Nov 2025 22:04:47 -0700 Subject: [PATCH] draw orbital paths --- src/main.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.lua b/src/main.lua index 5932c9f..7bbeed3 100644 --- a/src/main.lua +++ b/src/main.lua @@ -78,10 +78,6 @@ local ore_types = { "iron ore", "copper ore", "warp fuel", } -- cargo_types[cargo_types[i]] = i -- end --- TODO review my previous orbits code to add extremely slow background orbits to this --- planets/stars/stations always have fixed orbits; ships have a fixed orbital acceleration but have their own additional --- the "zero relative velocity" key will be a burn whatever amount of fuel/acceleration necessary to match local acceleration --- which.. since the currently stored velocity is a COMPLETELY SEPARATE SYSTEM - is literally just zeroing velocity which makes it even simpler to execute local player_ship = { position_x = 100, position_y = 100, @@ -101,6 +97,7 @@ local player_ship = { -- TODO fuel capacity and use (idle and while acceleration) -- TODO cargo / mass affects acceleration } +player_ship.orbital_radius = math.sqrt(player_ship.position_x^2 + player_ship.position_y^2) local resource_points = {} -- NOTE they're "planets" but I intend for them to be multiple things tbh local function make_resource_point(x, y) @@ -183,11 +180,11 @@ function love.update(dt) player_ship.position_x = player_ship.position_x + player_ship.velocity_x * dt player_ship.position_y = player_ship.position_y + player_ship.velocity_y * dt - local player_radius = math.sqrt(player_ship.position_x^2 + player_ship.position_y^2) + player_ship.orbital_radius = math.sqrt(player_ship.position_x^2 + player_ship.position_y^2) local player_rotation_offset = math.atan2(player_ship.position_y, player_ship.position_x) - local x, y = math.cos(dt / player_radius / (1 / orbital_speed_constant) + player_rotation_offset), math.sin(dt / player_radius / (1 / orbital_speed_constant) + player_rotation_offset) - player_ship.position_x = x * player_radius - player_ship.position_y = y * player_radius + local x, y = math.cos(dt / player_ship.orbital_radius / (1 / orbital_speed_constant) + player_rotation_offset), math.sin(dt / player_ship.orbital_radius / (1 / orbital_speed_constant) + player_rotation_offset) + player_ship.position_x = x * player_ship.orbital_radius + player_ship.position_y = y * player_ship.orbital_radius for i = 1, #resource_points do local current_point = resource_points[i] @@ -244,7 +241,11 @@ function love.draw() for i = 1, #resource_points do local current_point = resource_points[i] love.graphics.circle("line", current_point.position_x, current_point.position_y, current_point.radar_size) + + -- TODO make this "behind" other objects (and toggleable? and a different color?) + love.graphics.circle("line", 0, 0, current_point.orbital_radius) end + love.graphics.circle("line", 0, 0, player_ship.orbital_radius) love.graphics.translate(-camera_offset.x, -camera_offset.y) love.graphics.print(last_message, 1, 1)