orbit trails, and cool stuff

This commit is contained in:
UndeadMaelys 2022-06-03 06:33:29 +02:00
parent c92bfd7f6b
commit 11ae0f2c66

View File

@ -19,6 +19,7 @@ function love.load()
VIEW.x = 0
VIEW.y = 0
VIEW.prints = {}
VIEW.orbit_prints = {}
require "class"
require "body"
@ -44,7 +45,7 @@ function love.load()
newBody(
{0, 20000, 0},
{-200000, 0, 0},
3000,
300,
{0,1,1}
)
end
@ -79,6 +80,7 @@ function love.draw()
for n, body in pairs(BodyList) do
addPrint(body)
end
drawObitPrints()
drawPrints()
-- draw info
love.graphics.setColor(1,1,1)
@ -100,6 +102,21 @@ function addPrint(body)
color = body.color,
time = VIEW.print_time
})
VIEW.orbit_print_time = 1200
local trail_color = {
(1 + body.color[1])/2,
(1 + body.color[2])/2,
(1 + body.color[3])/2
}
table.insert(VIEW.orbit_prints,{
pos = {
x = body.x,
y = body.y
},
mass = 1,
color = trail_color,
time = VIEW.orbit_print_time
})
end
function drawPrints()
@ -110,3 +127,14 @@ function drawPrints()
if print.time < 1 then VIEW.prints[n] = nil end
end
end
function drawObitPrints()
for n, print in pairs(VIEW.orbit_prints) do
love.graphics.setColor(print.color[1],print.color[2],print.color[3],print.time/VIEW.orbit_print_time)
love.graphics.circle("line",(VIEW.x+print.pos.x)/VIEW.size+SCREEN_WIDTH/2,(VIEW.y+print.pos.y)/VIEW.size+SCREEN_HEIGHT/2,(print.time/VIEW.orbit_print_time)*print.mass/VIEW.size)
print.time = print.time - 1
if print.time < 1 then VIEW.orbit_prints[n] = nil end
end
end