aboutsummaryrefslogtreecommitdiff
path: root/toxicinvaders_misc/musicplayer/update_music.lua
blob: 3e79211ffe57adb545a7706d4dd0d48af915ca9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--similar math elements grouped to lower tokens
flashtime = (ceil(t()*10%2) == 1) --for flashing elements (ship, score)
circletimex = sin(t())*3 -- for elements that move in a circle (respawn timer)
circletimey = cos(t())*3

gt += scrollspeed + 1/600
fadeouttimer -= ft

if t() < 2 then -- weird if because of freezing bubbles in the menu
    updateobjs() --update all objects
end

if tracknumber < 0 then
    tracknumber = 4
elseif tracknumber > 4 then
    tracknumber = 0
end

if btnp(0) then
    tracknumber-=1
    updatetracktitlepos()
    fadeoutsong()
elseif btnp(1) then
    tracknumber+=1
    updatetracktitlepos()
    fadeoutsong()
end

if fadeouttimer <= 0 then
    fadeouttimer = 0
    selectmusic()
    updatetracktitlepos()
end

if autoplay then
    autoplaytimer -= ft
    if autoplaytimer <= 0 then
        autoplaytimer = 90
        tracknumber+=1
        fadeoutsong()
    end
    autoplaymenutext = "(♪) autoplay"
else 
    autoplaymenutext = "(◆) autoplay"
end
menuitem(2, autoplaymenutext, function() autoplay = not autoplay end)


if btnp(4) and btnp(5) then music(-1,3000) end

tracktitleposition = lerp(tracktitleposition,newtracktitleposition,0.03)