orbit trails, and cool stuff
This commit is contained in:
parent
c92bfd7f6b
commit
11ae0f2c66
30
main.lua
30
main.lua
@ -19,6 +19,7 @@ function love.load()
|
|||||||
VIEW.x = 0
|
VIEW.x = 0
|
||||||
VIEW.y = 0
|
VIEW.y = 0
|
||||||
VIEW.prints = {}
|
VIEW.prints = {}
|
||||||
|
VIEW.orbit_prints = {}
|
||||||
|
|
||||||
require "class"
|
require "class"
|
||||||
require "body"
|
require "body"
|
||||||
@ -44,7 +45,7 @@ function love.load()
|
|||||||
newBody(
|
newBody(
|
||||||
{0, 20000, 0},
|
{0, 20000, 0},
|
||||||
{-200000, 0, 0},
|
{-200000, 0, 0},
|
||||||
3000,
|
300,
|
||||||
{0,1,1}
|
{0,1,1}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -79,6 +80,7 @@ function love.draw()
|
|||||||
for n, body in pairs(BodyList) do
|
for n, body in pairs(BodyList) do
|
||||||
addPrint(body)
|
addPrint(body)
|
||||||
end
|
end
|
||||||
|
drawObitPrints()
|
||||||
drawPrints()
|
drawPrints()
|
||||||
-- draw info
|
-- draw info
|
||||||
love.graphics.setColor(1,1,1)
|
love.graphics.setColor(1,1,1)
|
||||||
@ -100,6 +102,21 @@ function addPrint(body)
|
|||||||
color = body.color,
|
color = body.color,
|
||||||
time = VIEW.print_time
|
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
|
end
|
||||||
|
|
||||||
function drawPrints()
|
function drawPrints()
|
||||||
@ -110,3 +127,14 @@ function drawPrints()
|
|||||||
if print.time < 1 then VIEW.prints[n] = nil end
|
if print.time < 1 then VIEW.prints[n] = nil end
|
||||||
end
|
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
|
Loading…
x
Reference in New Issue
Block a user