Multiple steps per frame, set random seed

main
mat ess 2022-09-11 09:18:20 -04:00
parent 7cd25c4408
commit 31b3dec460
2 changed files with 32 additions and 27 deletions

View File

@ -31,6 +31,8 @@ end
local function initColors(rules)
rules = rules:lower()
local colorbrewer = require("colorbrewer")
-- set a specific random seed to avoid picking the same palette every time
math.randomseed(os.time())
local scheme = colorbrewer.random()
local variant = scheme[#rules]
COLORS = {}
@ -52,7 +54,6 @@ local function initScreen()
love.graphics.setColor(color)
love.graphics.rectangle("fill", 0, 0, WIDTH, HEIGHT)
end)
UNITS = 8
end
local function initAnt()
@ -81,6 +82,8 @@ end
function love.load(args)
local rules = args[1] or "RL"
UNITS = args[2] or 8
STEPS_PER_FRAME = args[3] or 5
initColors(rules)
initScreen()
initAnt()
@ -117,6 +120,7 @@ end
function love.update()
require("lurker").update()
for _ = 1, STEPS_PER_FRAME do
local c = nextColor()
ANT.direction = rotate(ANT.direction, c.clockwise)
CANVAS:renderTo(function()
@ -144,6 +148,7 @@ function love.update()
elseif ANT.y < 0 then
ANT.y = (HEIGHT - 1) - ((HEIGHT - 1) % UNITS)
end
end
end
function love.draw()

View File

@ -22,7 +22,7 @@
name = "love";
packages = [ love ];
shellHook = ''
mkdir vendor
mkdir -p vendor
ln -snf ${lume}/lume.lua vendor/lume.lua
ln -snf ${lurker}/lurker.lua vendor/lurker.lua
'';