Compare commits
2 Commits
display_ge
...
main
Author | SHA1 | Date | |
---|---|---|---|
78b94bc0a3 | |||
|
2f2503b876 |
@ -13,3 +13,13 @@ NO Grabs all position and orbit components with a specific system.
|
|||||||
- note: L4/L5 positions are stored as their own orbits
|
- note: L4/L5 positions are stored as their own orbits
|
||||||
* id:
|
* id:
|
||||||
* x,y,system_id: position in a system
|
* x,y,system_id: position in a system
|
||||||
|
|
||||||
|
# Notes
|
||||||
|
|
||||||
|
- Model populations as their own entities.
|
||||||
|
- Minerals on a body can be mined.
|
||||||
|
- Minerals on a population have already been mined, and can be used.
|
||||||
|
- Consider splitting MapDisplay's version of bodies from the reality?
|
||||||
|
- Reason A: It will also need to store contacts, and should not always have all info
|
||||||
|
- Reason B: Orbital positions should only be updated by an orbital processor when needed
|
||||||
|
- Reason C: Reduce duplication by making the orbital processor the only thing that updates positions?
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
import graphics from love
|
|
||||||
import cos, sin from math
|
|
||||||
|
|
||||||
w, h = graphics.getDimensions!
|
|
||||||
|
|
||||||
tiny = require "tiny"
|
|
||||||
IDTracker = require "systems/IDTracker"
|
|
||||||
|
|
||||||
MapDisplay = (system_id) ->
|
|
||||||
return tiny.sortedSystem {
|
|
||||||
compare: (a, b) =>
|
|
||||||
if a.orbit and b.orbit
|
|
||||||
a.orbit.hierarchy <= b.orbit.hierarchy
|
|
||||||
else
|
|
||||||
true
|
|
||||||
filter: tiny.requireAny "orbit", tiny.requireAll("x", "y", system_id)
|
|
||||||
draw: (t) =>
|
|
||||||
graphics.translate w / 2, h / 2
|
|
||||||
for entity in *@entities
|
|
||||||
if orbit = entity.orbit
|
|
||||||
orbit = entity.orbit
|
|
||||||
-- orbital period
|
|
||||||
-- real: T = 2pi * sqrt(a^3 / G*M)
|
|
||||||
-- sim: T = 2pi * speed_parameter
|
|
||||||
entity.x = orbit.radius * cos(t / orbit.speed_parameter) + orbit.offset
|
|
||||||
entity.y = orbit.radius * sin(t / orbit.speed_parameter) + orbit.offset
|
|
||||||
if orbit.parent_id
|
|
||||||
parent = IDTracker[orbit.parent_id]
|
|
||||||
entity.x += parent.x
|
|
||||||
entity.y += parent.y
|
|
||||||
graphics.circle "fill", entity.x, entity.y, 5 -- TEMP radius
|
|
||||||
}
|
|
||||||
|
|
||||||
return MapDisplay
|
|
19
src/generators/stellar_body.moon
Normal file
19
src/generators/stellar_body.moon
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-- TODO defined globals need to be created somewhere else
|
||||||
|
export stefan_boltzmann_constant = 5.670374419e-8 -- W / (m^2 * K^4)
|
||||||
|
|
||||||
|
parameters = {
|
||||||
|
temperature: love.math.randomNormal 1000, 6000 -- [2000 to 10000] K
|
||||||
|
}
|
||||||
|
|
||||||
|
parameters.absolute_magnitude = 35.4631241560502 * math.exp(-0.000353006569939 * parameters.temperature) -- Mv
|
||||||
|
parameters.luminosity = 100 * math.exp -0.943865141164545 * (parameters.absolute_magnitude - 0.99^parameters.absolute_magnitude) -- L(sun)
|
||||||
|
-- TODO calculate B-V value ? Or color directly? Or spectrum?
|
||||||
|
|
||||||
|
-- TODO this needs to be multiplied by the star's surface area to get its total power emission
|
||||||
|
parameters.surface_power_emission = stefan_boltzmann_constant * parameters.temperature^4 -- W / m^2
|
||||||
|
-- NOTE then for measuring power input into a planet, find the surface area of
|
||||||
|
-- its orbital radius, divide total power by that, then multiply that by the
|
||||||
|
-- circular cross-section of that planet to get the total power being emitted
|
||||||
|
-- into that planet, which must equal its emission, allowing you to calculate
|
||||||
|
-- its surface temperature*
|
||||||
|
-- * if it had no atmosphere, or albedo
|
29
src/generators/terrestrial_body.moon
Normal file
29
src/generators/terrestrial_body.moon
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
-- TODO defined globals need to be created somewhere else
|
||||||
|
export gravitational_constant = 6.6743e-11 -- m^3 / (kg * s^2)
|
||||||
|
export magic_pressure_constant = 1.1701572e-4 -- s^2 / m^2
|
||||||
|
|
||||||
|
parameters = {
|
||||||
|
surface_radius: love.math.randomNormal 1100, 5500 -- [1.1e3, 9.9e3 km]
|
||||||
|
solid_density: love.math.randomNormal 0.675, 5.2 -- [2.5, 7.9 g/cm^3]
|
||||||
|
}
|
||||||
|
|
||||||
|
parameters.solid_volume = 4/3 * math.pi * parameters.surface_radius^3 -- km^3
|
||||||
|
parameters.solid_mass = parameters.solid_density * parameters.solid_volume * 1e12 -- kg
|
||||||
|
parameters.surface_gravity = gravitational_constant * parameters.solid_mass / parameters.surface_radius^2 * 1e-6 -- m/s^2
|
||||||
|
parameters.atmosphere_reduction_rate = parameters.surface_gravity * magic_pressure_constant -- m^-1
|
||||||
|
parameters.atmosphere_halving_height = math.log(2) / parameters.atmosphere_reduction_rate -- m
|
||||||
|
-- volume containing the first half of the entire atmosphere is assumed to be
|
||||||
|
-- half of the volume of the entire atmosphere if it was at surface pressure
|
||||||
|
parameters.simulated_atmosphere_volume = (4/3 * math.pi * (parameters.surface_radius + parameters.atmosphere_halving_height / 1000)^3 - parameters.solid_volume) * 2 -- km^3
|
||||||
|
|
||||||
|
-- TODO better (based on distance from star / temperature from star)
|
||||||
|
parameters.surface_atmosphere_pressure = 101325 * math.max 0, love.math.randomNormal 0.125, 0.5 -- [0, 202650 kPa]
|
||||||
|
-- TODO verify this will generate in meters
|
||||||
|
parameters.minimum_orbital_height = math.log(1.4e-11 / parameters.surface_atmosphere_pressure) / parameters.atmosphere_reduction_rate -- m
|
||||||
|
parameters.atmosphere_volume = 4/3 * math.pi * (parameters.surface_radius + parameters.minimum_orbital_height / 1000)^3 - parameters.solid_volume -- km^3
|
||||||
|
-- TODO atmospheric composition?
|
||||||
|
-- TODO albedo
|
||||||
|
-- TODO surface_average_temperature (based on greenhouse gases or lack thereof, albedo, and base temperature from distance to star)
|
||||||
|
|
||||||
|
-- unused at this time?
|
||||||
|
parameters.surface_area = 4 * math.pi * parameters.surface_radius^2
|
@ -1,5 +1,4 @@
|
|||||||
tiny = require "tiny"
|
tiny = require "tiny"
|
||||||
MapDisplay = require "generators/MapDisplay"
|
|
||||||
|
|
||||||
systems = {}
|
systems = {}
|
||||||
for name in *love.filesystem.getDirectoryItems "systems"
|
for name in *love.filesystem.getDirectoryItems "systems"
|
||||||
@ -18,16 +17,14 @@ makeEntity = (tab) ->
|
|||||||
return tab
|
return tab
|
||||||
|
|
||||||
world = tiny.world game, unpack systems
|
world = tiny.world game, unpack systems
|
||||||
local map
|
|
||||||
|
|
||||||
system = ->
|
system = ->
|
||||||
system_id = "someuuidthing"
|
|
||||||
sun = makeEntity {
|
sun = makeEntity {
|
||||||
x: 0,
|
x: 0, y: 0
|
||||||
y: 0
|
radius: 5
|
||||||
[system_id]: true
|
|
||||||
}
|
}
|
||||||
planet = makeEntity {
|
planet = makeEntity {
|
||||||
|
radius: 1
|
||||||
orbit: {
|
orbit: {
|
||||||
hierarchy: 1
|
hierarchy: 1
|
||||||
radius: 20
|
radius: 20
|
||||||
@ -35,11 +32,8 @@ system = ->
|
|||||||
offset: love.math.random!
|
offset: love.math.random!
|
||||||
speed_parameter: 0.5
|
speed_parameter: 0.5
|
||||||
}
|
}
|
||||||
[system_id]: true
|
|
||||||
}
|
}
|
||||||
map = MapDisplay system_id
|
|
||||||
world\add sun, planet
|
world\add sun, planet
|
||||||
world\add map
|
|
||||||
|
|
||||||
system!
|
system!
|
||||||
|
|
||||||
@ -47,7 +41,7 @@ love.update = (dt) ->
|
|||||||
world\update dt
|
world\update dt
|
||||||
|
|
||||||
love.draw = ->
|
love.draw = ->
|
||||||
map\draw game.time
|
systems.MapDisplay\draw game.time
|
||||||
|
|
||||||
love.keypressed = (key) ->
|
love.keypressed = (key) ->
|
||||||
if key == "escape" love.event.quit!
|
if key == "escape" love.event.quit!
|
||||||
|
@ -20,14 +20,14 @@ MapDisplay = tiny.sortedSystem {
|
|||||||
orbit = entity.orbit
|
orbit = entity.orbit
|
||||||
-- orbital period
|
-- orbital period
|
||||||
-- real: T = 2pi * sqrt(a^3 / G*M)
|
-- real: T = 2pi * sqrt(a^3 / G*M)
|
||||||
-- sim: T = 2pi * speed_parameter
|
-- sim: T = 2pi / speed_parameter
|
||||||
entity.x = orbit.radius * cos(t / orbit.speed_parameter) + orbit.offset
|
entity.x = orbit.radius * cos(t * orbit.speed_parameter) + orbit.offset
|
||||||
entity.y = orbit.radius * sin(t / orbit.speed_parameter) + orbit.offset
|
entity.y = orbit.radius * sin(t * orbit.speed_parameter) + orbit.offset
|
||||||
if orbit.parent_id
|
if orbit.parent_id
|
||||||
parent = IDTracker[orbit.parent_id]
|
parent = IDTracker[orbit.parent_id]
|
||||||
entity.x += parent.x
|
entity.x += parent.x
|
||||||
entity.y += parent.y
|
entity.y += parent.y
|
||||||
graphics.circle "fill", entity.x, entity.y, 5 -- TEMP radius
|
graphics.circle "fill", entity.x, entity.y, entity.radius
|
||||||
}
|
}
|
||||||
|
|
||||||
return MapDisplay
|
return MapDisplay
|
@ -1,59 +0,0 @@
|
|||||||
import graphics from love
|
|
||||||
import cos, sin from math
|
|
||||||
|
|
||||||
w, h = graphics.getDimensions!
|
|
||||||
|
|
||||||
tiny = require "tiny"
|
|
||||||
IDTracker = require "systems/IDTracker"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MapDisplayManager = tiny.system {
|
|
||||||
known: {}
|
|
||||||
filter: tiny.requireAll "system_id"
|
|
||||||
onAdd: (entity) =>
|
|
||||||
unless @known[entity.system_id]
|
|
||||||
@known[entity.system_id] = true
|
|
||||||
makeDisplay entity.system_id
|
|
||||||
onRemove: (entity) =>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IDTracker = tiny.system {
|
|
||||||
filter: tiny.requireAll "id"
|
|
||||||
onAdd: (entity) =>
|
|
||||||
@[entity.id] = entity
|
|
||||||
onRemove: (entity) =>
|
|
||||||
@[entity.id] = nil
|
|
||||||
}
|
|
||||||
return MapDisplayManager
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MapDisplay = tiny.sortedSystem {
|
|
||||||
compare: (a, b) =>
|
|
||||||
if a.orbit and b.orbit
|
|
||||||
a.orbit.hierarchy <= b.orbit.hierarchy
|
|
||||||
else
|
|
||||||
true
|
|
||||||
filter: tiny.requireAny "orbit", tiny.requireAll("x", "y")
|
|
||||||
draw: (t) =>
|
|
||||||
graphics.translate w / 2, h / 2
|
|
||||||
for entity in *@entities
|
|
||||||
if orbit = entity.orbit
|
|
||||||
orbit = entity.orbit
|
|
||||||
-- orbital period
|
|
||||||
-- real: T = 2pi * sqrt(a^3 / G*M)
|
|
||||||
-- sim: T = 2pi * speed_parameter
|
|
||||||
entity.x = orbit.radius * cos(t / orbit.speed_parameter) + orbit.offset
|
|
||||||
entity.y = orbit.radius * sin(t / orbit.speed_parameter) + orbit.offset
|
|
||||||
if orbit.parent_id
|
|
||||||
parent = IDTracker[orbit.parent_id]
|
|
||||||
entity.x += parent.x
|
|
||||||
entity.y += parent.y
|
|
||||||
graphics.circle "fill", entity.x, entity.y, 5 -- TEMP radius
|
|
||||||
}
|
|
||||||
|
|
||||||
return MapDisplay
|
|
Loading…
Reference in New Issue
Block a user