add bpm slider

This commit is contained in:
jill 2021-09-18 13:53:57 +03:00
parent 24647a50a6
commit 2237128a84
2 changed files with 17 additions and 1 deletions

View file

@ -37,7 +37,7 @@ function self.update(dt)
local mx, my = love.mouse.getPosition()
if not (love.mouse.isDown(1) and mx > x and mx < x + w and my > y and my < y + h) then
timer = (timer + dt) % 2
timer = (timer + dt * (slider.kvalue('bpm')/120)) % 2
else
timer = mix(timer, (mx - x) / w, dt * 14)
end

View file

@ -29,6 +29,9 @@ local function insertSlider(tab, f)
f.oldvalue = (self.kget(f.name) or {oldvalue = f.value}).oldvalue
f.spintimer = (self.kget(f.name) or {spintimer = 0}).spintimer
f.spin = (self.kget(f.name) or {spin = 0}).spin
if f.snap then
f.value = math.floor(f.value / f.snap) * f.snap
end
return table.insert(tab, f)
end
function self.createSliders()
@ -47,6 +50,19 @@ function self.createSliders()
displayname = 'Mix'
})
end
if mode == 1 or mode == 2 then -- bpm slider
insertSlider(s, {
x = outerpadding,
y = love.graphics.getHeight() - outerpadding - fontHeight * 3 - padding,
width = dropdownWidth,
min = 80,
max = 220,
default = 120,
name = 'bpm',
displayname = 'BPM',
snap = 1,
})
end
local ease1 = ease.eases[dropdown.kselected('ease1')]
local ease2 = ease.eases[dropdown.kselected('ease2')]