local screen_width, screen_height = 960, 540 love.window.setMode(screen_width, screen_height) local game_time = os.time() love.math.setRandomSeed(game_time) local star = { x = 0, y = 0, orbital_radius = 0, children = { { orbital_radius = 100, children = { { orbital_radius = 10, } } }, { orbital_radius = 50 }, { orbital_radius = 200, children = { { orbital_radius = 25, children = { { orbital_radius = 5 } } } } } } } local set_offsets set_offsets = function(object) object.rotation_offset = math.pi * 2 * love.math.random() if object.children then for i = 1, #object.children do set_offsets(object.children[i]) end end end set_offsets(star) function love.update(dt) game_time = game_time + dt local update_object_position update_object_position = function(object, parent_x, parent_y) local temporary_speed_up = 100 local argument = game_time / object.orbital_radius^1.337 * temporary_speed_up + object.rotation_offset if (argument == math.huge) or (argument ~= argument) then argument = 0 end object.x, object.y = parent_x + object.orbital_radius * math.cos(argument), parent_y + object.orbital_radius * math.sin(argument) if object.children then for i = 1, #object.children do update_object_position(object.children[i], object.x, object.y) end end end update_object_position(star, 0, 0) end function love.draw() love.graphics.setColor(1, 1, 1, 1) love.graphics.translate(screen_width / 2, screen_height / 2) local draw_object draw_object = function(object, parent_x, parent_y) love.graphics.circle("fill", object.x, object.y, 3) love.graphics.circle("line", parent_x, parent_y, object.orbital_radius) if object.children then for i = 1, #object.children do draw_object(object.children[i], object.x, object.y) end end end draw_object(star, 0, 0) end function love.keypressed(key) if key == "escape" then love.event.quit() end end