draw orbital paths

This commit is contained in:
2025-11-27 22:04:47 -07:00
parent b794fdf4f7
commit a53c19b350
+9 -8
View File
@@ -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)